ls command
(List directory contents)
The ls command will list the files and directories within the current working directory (the directory you are currently in).
There are a few options you can use with ls, and the format, or syntax of the command is....
ls [options] [file]
EXAMPLE
>ls -l /home/rich/www
Lets break that down....
ls is the command
-l is the option which will give you a long listing format (which shows
more info than just the file names - the owner, size, date last modified
etc)
/home/rich/www is the directory we want to see a listing of (if you
omit this part, ls will print the contents of the directory you
are in).
Options
Some useful options are -l, -a, -s, -h and -R
-l will give you a long listing (as explained above)
-a will show you ALL the files in the directory, including hidden files
-R will the subdirectories recursively, which means it will show all the
directories and files within the specified directory.
-s will also show you the size of the files (in blocks, not bytes)
-h will show the size in "human readable format" (ie: 4K, 16M,
1G etc). Of course you must use this option in conjunction with the -s
option.
You can combine as many of these options as you wish.
EXAMPLES
>ls -la /home
Lists ALL the files and directories in the /home directory, in the long listing format.
>ls -ash
Lists ALL the files in the current directory (no directory was specified so it lists the contents of the current directory), and the size of the files/directories, written in 'human readable' format.
There are many more options for ls, but these are a few you may want to use. To see the total list of options for the ls command, you can type man ls at the prompt.