Free Hosting Online for WorkStations

< Previous | Contents | Next >

More Fun With ls

The ls command is probably the most used command, and for good reason. With it, we can see directory contents and determine a variety of important file and directory at- tributes. As we have seen, we can simply enter ls to see a list of files and subdirectories contained in the current working directory:



[me@linuxbox ~]$ ls

Desktop Documents Music Pictures Public Templates Videos

[me@linuxbox ~]$ ls

Desktop Documents Music Pictures Public Templates Videos


Besides the current working directory, we can specify the directory to list, like so:



me@linuxbox ~]$ ls /usr

bin games kerberos libexec sbin src etc include lib local share tmp

me@linuxbox ~]$ ls /usr

bin games kerberos libexec sbin src etc include lib local share tmp


Or even specify multiple directories. In this example we will list both the user's home di- rectory (symbolized by the “~” character) and the /usr directory:


[me@linuxbox ~]$ ls ~ /usr

/home/me:

[me@linuxbox ~]$ ls ~ /usr

/home/me:


Desktop Documents Music Pictures Public Templates Videos


/usr:

bin games kerberos libexec sbin src etc include lib local share tmp

Desktop Documents Music Pictures Public Templates Videos


/usr:

bin games kerberos libexec sbin src etc include lib local share tmp


We can also change the format of the output to reveal more detail:



[me@linuxbox ~]$ ls -l

total 56

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Desktop

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Documents

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Music

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Pictures

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Public

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Templates

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Videos

[me@linuxbox ~]$ ls -l

total 56

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Desktop

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Documents

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Music

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Pictures

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Public

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Templates

drwxrwxr-x 2 me me 4096 2007-10-26 17:20 Videos


By adding “-l” to the command, we changed the output to the long format.


 

Top OS Cloud Computing at OnWorks: