|
UNIX - The ls Command
Using ls for directory listings For those who are familiar with DOS commands, the ls
command is the Unix equivalent of DIR. This will show you the contents of the directory you are in. There are switches that
can be used to display the information you need. By typing ls from the command prompt, you will recieve
the following information (or something similar):
-l switch: More information can be displayed about the contents of the directory by using the -l
switch. This will display the permissions, number of items of a directory, owner, group, size, date, time, and name of each item in the directory (in that order). Here is an
example of what you might see:
-a switch: The -a switch is used to display hidden files. Hidden files are files that do not have a
prefix to it (example: .htaccess or .htpasswd are both hidden files). This command switch can be used in conjunction with the
-l switch as indicated in this next example:
If you were to use the -a switch by itself, you would receive output similar to the first example with the exception that
all files are shown (including the hidden files).
-r switch: It is unfortunate that the telnet client that comes with windows does not allow you to scroll what you have
already done in the session. The window cannot be expanded, and often, the contents of a directory scroll past the top
of the telnet window (there are some good telnet clients that will allow you to do so. A good one is CRT). The
-r switch will allow you to reverse the order of the directory listing. This is helpful if the
file you are looking for scrolls past the top of the screen. This switch can also be used in conjunction with other
switches. The following example shows the use of all three switches at the same time:
This concludes the lesson on using the ls command to display contents of directories.
|