Directory Listings
Now that you know where you are the next natural question is "Where can I go?" You might have a few subfolders, maybe even some files, or possibly nothing at all. To get a listing of all the files in the current directory use the ls command. That command will list the directory contents, but as you will soon see you can use options with the command to make it even more useful.
% ls
examples helloWorld.txt
My example code shows that in the current directory there are two things. One named 'examples' and the other named 'helloWorld.txt'. These things could be files or directories but right now we don't really know.
Using Options
The ls command has multiple options to make it more useful for you.
Options are normally found after the command behind a hyphen in this
format:
command -options
% ls -l
total 4
drwx------ 2 joe group 512 Dec 18 22:24 examples
-rwxr-xr-x 1 joe group 13 Dec 18 22:23 helloWorld.txt
This time executing ls with the -l option provides us with more information. The -l option turns on long formatting. The output is rather cryptic at first but it can be of good use.
For instance, the sequences at the start: "drwx------" and so on show the permission structure. The 'd' at the start shows that "examples" is a directory! The other nine spaces are 'r' for read, 'w' for write, and 'x' for executable, apply to the owner, group, and public domains. More on permissions later, but for now you can see that "examples" is a directory because of the 'd', and helloWorld.txt is not a directory (and therefore is a file).
Some of the text applies still to the permissions. Showing that the owner is "joe", and the group is "group", but at the end we see the file size, the date last modified, and the names! Clearly the output is much more useful then just the ls command, and this is formatted much nicer. Lets try a different option!
% ls -a
. .. examples helloWorld.txt
The -a option shows all files and folders, including hidden files. In Unix, files and directories that start with . are hidden. Using the -a option we can see that "." and ".." were found. These are special directories. The "." directory means the current directory you are in. The ".." directory means the parent directory. See for yourself that they are both directories by executing: ls -la. There you are using both the -l and -a options at the same time! These directories will be very useful to you when you explore the file system, which happens to be the next step!
change directories »