Thursday, 28th August 2008
ls [option] [file]
Probably the most used command of them all, the "ls" command (stands for "list") allows you to list the contents of a directory. While it all sounds very trivial, this is your main method for navigating through the system.
roryd@frink:~$ ls
backup compsoc include mbox dev it
mp3 public_html http_logs mail personal resources
Here we get a listing of all files in my home directory. But we can't see which are directories and which are files.
Ah now this is a little better, the directories have a slash at the end of them, the files (only one in this case, mbox) have none.
The "-l" argument gives a more detailed listing. This might all look very scary now, but you'll understand it all pretty quickly. The two highlighted above are the owner of the file and the date last modified. But what's the one before the date?
roryd@frink:~$ ls -lh mbox
-rw------- 1 roryd users 3.1M Jun 26 15:23 mbox
It's the size of the file. Here we use one more argument, a "h" to give us a "humanly readable" file size. This time we've also added the file name we want to check the listing of, and we find it is 3.1 Megabytes. So as well as being able to list the contents of directories, the "ls" command can also give us the attributes of any file.
Finally there are hidden files in your home directory. They are used for configuring the various programs you learn to use as you develop a broader knowledge of what you can do. To see the one's that are created by default by the system or us for you:
You'll notice the hidden files have a "." before them. You don't have to know what any of these do, but just be aware they are there. One of the most common config files is the ".bashrc" which you'll learn more about in Configuring the Shell. Now lets find out how to get copy and move files.