about


Scribe:

chrono

blog

Time

science!

book musings

gov

'punk

missle defense

jams

antiques

cultcha blog


Construct:

scripts & programs

on the town

snaps


Self:

creds (PDF)

key

missive


Linux: The LS Command

You can learn a lot from the the Unix "ls" command, once you know all the options. If you come from the world of Microsoft DOS, then ls is Unix's version of "dir." From the command prompt, type in
#ls
	...will return a list all the files and directories in the current directory are in. 
As in many Unix commands, there is a great deal you can do with the ls's additional options. Options are noted by the "-" sign, followed by a letter deisgnating which option to use. Note which case is used for the option, as they are case-sensitive. Here are some useful options:
#ls -l
    ....This of the verbose listing, offering, in addition to the name of each file/subdirectory, alkso offers (in this order): user permissions, the user permissions, owner, 
	and group that the item belong to size of file, last modified

	
#ls -a
     ....Lists hidden files, those files that start with a "." . Use this for finding system files.

#ls -F
     ....Appends each entry with either a "/" (to indicate it is a directory), a "*" (executable file) or "@" to show it is a symbolic link.

#ls -G
     ....Lists the group each file is owned by.

#ls -i
     ....Lists the innode (storage location on the disk) for each file.

#ls -L 
      ....Lists the files referenced by the symbolic link, ratherthanthe names of the links themselves (if using symbolic links. See future entry on symbolic links).

#ls -m
       ....Separates each file and directory with a comma.

#ls -n
       ....Lists each file along with group identifying (GID) and user-identifying (UID) numbers instead of the group/owner names, respectively.

#ls -o
     ....Show owner with names.

#ls -p
     ....Indicate the directories by appending "/" onto the end of their names.

#ls -r
     ....List in reverse alphabetic order.

#ls -R
     ....List the contents of all the subdirectories.

#ls -s
      ....List the size of each file in blocks.

#ls -t
      ....List files in order of when they were modified, starting from the newest (but no dates).

#ls -u
      ....List files in order of when they were accessed, starting from the newest (but no dates).

#ls -t
      ....List one per line.

Some end-notes:

1. Using multiple options at once: Multiple options can be used together, i.e.

     #ls -u1
      ...lists the files in order of when they were last accessed, one per line.
2. Piping ls results into a text file: Normally, when you use ls, it drops the input onto the screen. But you can also send the results (or "pipeline" them) to a file, using ">." i.e.
      #ls -a > [nameoffile]
If no file with that name exists, a new file is created with that name. The results can be piped into other commands as well.

3. Wildcards: Wildcards can be used to pick out only those files you are looking for. I.e.

     #ls S*
        ...Will return only those files that start with the letter S.

A full list of working commands can be found on the ls man page, here. More explanation can also be found here. Also, check out Unix in a Nutshell by Daniel Gilly (O'Reilly). --Joab Jackson