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.
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.
processing...Welcome to Webmonkey
- edit articles
- add to the code library
- design and write a tutorial
- comment on any Webmonkey article
Sign In Information Sent
Ls
/skill level/
/viewed/
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.
/related_articles/
Special Offer For Webmonkey Users
WIRED magazine:
The first word on how technology is changing our world.