01. Your first Unix command
It’s important to note that you will always be inside a single directory when using the terminal. The default behavior is that when you open a new terminal you start in your own home directory (containing files and directories that only you can modify). To see what files and directories are in our home directory, we need to use the ls command. This command lists the contents of a directory. If we run the ls
command we should see something like:
learner@:~$ ls a_directory another_directory
There are three things that you should note here:
- The
learner@:~$
text that you see is the Unix command prompt. In this case, it contains a user name (‘learner’) and the name of the current directory (‘~’, more on that later). Note that the command prompt might not look the same on different Unix systems. In this case, the$
sign marks the end of the prompt. - The output of the
ls
command lists two things. In this case, they are both directories, but they could also be files. We’ll learn how to tell them apart later on. - After the
ls
command finishes it produces a new command prompt, ready for you to type your next command.
The ls
command is used to list the contents of any directory, not necessarily the one that you are currently in. Try the following:
learner@:~$ ls /
bin data dev etc home lib media mnt opt
proc root run sbin srv sys tmp usr var
learner@:~$ ls /etc/modprobe.d/ aliases.conf blacklist.conf i386.conf kms.conf