This command is used to list the contents of a directory, or for seeing detailed information about a particular file.
user@box ~$ ls
The above command will display all the files and sub-directories contained in the current directory, which is right now the user's home directory indicated by '~'.
The next step is to look at the contents of a directory, which is not the current one.
user@box ~$ ls /tmp
This should list the contents of the /tmp directory. Note that we are still in the user's home directory.
'ls' can also be used to check the size of a file.
user@box ~$ ls -sh /tmp/foo
This will print out the size of the file named 'foo' in the '/tmp' directory. The '-h' option is used to nicely convert the size into kilobytes (K), megabytes (M), gigabytes (G), etc.. Omitting it would display the size in multiples of blocks. On my system, the block size is 1024 bytes. Please note that if 'foo' was a sub-directory in '/tmp' instead of a file, then this would not show the total size of the contents of the directory. For that you would need to use the 'du' command. Since a directory is nothing but a particular type of file, you will get the size of the special file called 'foo' which is just a directory.
Some of the more common options that you might be interested in are:
-a Show hidden files and directories also. -h Print sizes in human readable format instead of blocks. -i Show the inode number of each file or directory. -l Use a long listing format. -s Show the sizes of the files in blocks.
You can see the manual page for the various options by giving the following commands:
user@box $~ info ls user@box $~ man ls