IT 1100 : Introduction to Operating Systems

Chapter 4


Viewing the Directory Tree

There are 2 commands we will learn for viewing our directory tree.

The first one is the ls command. We know that using this command will display the directories and files in our current directory. But we can also see down into the directories within our current directory using the -R option. Yes it is a capital R.

ls -R

ls -R /var/log

The second way is with the tree command. Simply calling the command without options or arguments will display the directory tree for our current directory and all of its children in a beautiful easy to read format.

tree

If we include an argument the tree command will display the directory tree of the directory we provide

tree /var/log

The tree command does not come pre-installed on Linux. So it is not available on some Linux installations. It is installed for your use on scratch.


Printing to the screen

Sometimes we want to say simply Repeat after me.

To do this we use the echo command. To print to the screen Hello World. It looks like this:

echo "Hello World"

The quotation marks are optional - but useful for avoiding errors. Try the command and see that it does exactly what you would think. It echoes whatever text you give it.

Later in the course, we will see some fun uses for the command.

Just for fun - try echo $HOME and see what it does.


Creating Files

To create files we are going to use the touch command. Creating files is not its primary purpose, but it is a handy side effect of the command.

This command requires only an argument. Usage looks like this; where myfile.txt is the name of the file you want to create:

touch myfile.txt

myfile.txt will be created in our current working directory


Saving your work on Scratch

How do I save my work on Scratch? is a question that gets asked every semester.

On your Windows or Mac computer (in your GUI) when you create a file or directory - do you have to do anything more than click the button that says: Add new Folder or Save file and then give it a name?

Linux works the same way - when you give the command to make a directory or create a file. Viola! It’s created. You don’t have to do anything more. You can exit and when you log back in all of your work is still there. And if we had a GUI interface you could see all the pretty icons too.


Textbook Time

Open up a terminal connection to scratch and then Read and Complete the Excercises in the Book


Last Updated 12/15/2017