Member Sign In
Not a member?

A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.


It's fast and free.

Webmonkey is a property of Wired Digital.
processing...
Join Webmonkey

Please send me occasional e-mail updates about new features and special offers from Wired/Webmonkey.
Yes No

Please send occasional e-mail offers from Wired/Webmonkey affiliated web sites and publications, and carefully selected companies.
Yes No

I understand and agree that registration on or use of this site constitutes agreement to Webmonkey's User Agreement and Privacy Policy.
Webmonkey is a property of Wired Digital.
processing...

Retrieve Sign In

Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.

or
Webmonkey is a property of Wired Digital.
processing...

Welcome to Webmonkey

A private profile page has been created for you.
As a member of Webmonkey, you can now:
  • edit articles
  • add to the code library
  • design and write a tutorial
  • comment on any Webmonkey article
Close
Webmonkey is a property of Wired Digital.

Sign In Information Sent

An e-mail has been sent to the e-mail address registered in this account.
If you cannot find it in your in-box, please check your bulk or junk folders.
Sign In
Webmonkey is a property of Wired Digital.

Ls

/skill level/
/viewed/
0 Times

If no filenames are given, ls will list files in the current directory. If one or more files are given, ls will display the files contained within "name" or list all the files with the same name as "name." The files can be displayed in a variety of formats.

Structure:ls [options] [names]

ls is a command you'll end up using all the time. It simply stands for list. If you are in a directory and you want to know what files and directories are inside that directory, type ls. Sometimes the list of files is very long and it flies past your screen so quickly you miss the file you want. A handy trick to combat this problem (besides enlarging your screen) is to type | more after the ls command, like so:

ls | more

The character | (called pipe) is typed by using shift and the \ key. | more will show as many files as will fit on your screen, and then display a highlighted "more" at the bottom. If you want to see the next screen, hit enter (for moving one line at a time) or the spacebar (to move a screen at a time). | more can be used anytime you wish to view the output of a command in this way.

A useful option to use with ls command is -l. This will list the files and directories in long format. This means it will display the permissions (see chmod), owners, group, size, date and time the file was last modified, and the filename.

webmonkey.com:[/eighties]% <tt>ls</tt> -l

drwxrwxr-x  meghan   staff  512  Oct 5 09:34 john_hughes
 -rwx-rw-r-- meghan   staff  4233 Oct 1 10:20 boy_george.html 
-rwx-r--r-- meghan   staff  4122 Oct 1 12:01 legwarmers.html 

There are several other options that can be used to modify the ls command, and many of these options can be combined. -a will list all files in a directory, including those files normally hidden. -F will flag filenames by putting / on directories, @ on symbolic links, and * on executable files.

Back to Unix Guide

  • This page was last modified 01:06, 16 May 2008.
Edit this article
Reddit Digg
 
Subscribe now

Special Offer For Webmonkey Users

WIRED magazine:
The first word on how technology is changing our world.

Subscribe for just $10 a year