(LiSt) The command in Unix/Linux, including Mac OS X, that displays file names in the directory (folder). It is the counterpart to the DIR command in Windows and DOS. Following are some brief examples. Note that commands are case sensitive; for example, file names with upper case extensions must be expressed with upper case characters in the command; the same for lower case.
ls list all files ls -l list all files and details ls *.GIF list GIF files ls *.gif list gif files ls *.gif -l list gif files and details ls | wc -l count all files ls *.GIF | wc -l count GIF files ls *.gif | ws -l count gif files wc = word count
Download Computer Desktop Encyclopedia to your PC, iPhone or Android.
|
|
This article includes a list of references, related reading or external links, but its sources remain unclear because it lacks inline citations. Please improve this article by introducing more precise citations. (June 2011) |
| This article relies on references to primary sources or sources affiliated with the subject, rather than references from independent authors and third-party publications. Please add citations from reliable sources. (June 2011) |
In computing, ls is a command to list files in Unix and Unix-like operating systems. ls is specified by POSIX and the Single UNIX Specification.
|
Contents
|
An ls utility appeared in the original version of AT&T UNIX. Today, two popular versions of ls are the Free Software Foundation's (part of the GNU coreutils package) and the one released by various BSD variants, such as FreeBSD, OpenBSD, NetBSD, and Apple Computer's Darwin. Both are free software and open source.
Unix and Unix-like operating systems maintain the idea of a current working directory, that is, where one is currently positioned in the hierarchy of directories.
When invoked without any arguments, ls lists the files in the current working directory. A directory that is not the current working directory can be specified and ls will list the files there. The user also may specify any list of files and directories. In this case, all files and all contents of specified directories will be listed.
Files whose names start with "." are not listed, unless the -a flag is specified, the -A flag is specified, or the files are specified explicitly.
Without options, ls displays files in a bare format. This bare format however makes it difficult to establish the type, permissions, and size of the files. The most common options to reveal this information or change the list of files are:
In some environments, providing the option --color (for GNU ls) or -G (FreeBSD ls) causes ls to highlight different types of files with different colors, instead of with characters as -F would. To determine what color to use for a file, GNU ls checks the Unix file type, the file permissions, and the file extension, while FreeBSD ls checks only the Unix file type and file permissions.
When the option to use color to indicate file types is selected, the output might look like:
brw-r--r-- 1 unixguy staff 64, 64 Jan 27 05:52 block
crw-r--r-- 1 unixguy staff 64, 255 Jan 26 13:57 character
-rw-r--r-- 1 unixguy staff 290 Jan 26 14:08 compressed.gz
-rw-r--r-- 1 unixguy staff 331836 Jan 26 14:06 data.ppm
drwxrwx--x 2 unixguy staff 48 Jan 26 11:28 directory
-rwxrwx--x 1 unixguy staff 29 Jan 26 14:03 executable
prw-r--r-- 1 unixguy staff 0 Jan 26 11:50 fifo
lrwxrwxrwx 1 unixguy staff 3 Jan 26 11:44 link -> dir
-rw-rw---- 1 unixguy staff 217 Jan 26 14:08 regularfile
ls has a large number of other options (see: man ls). It is a frequently used tool that provides an interface to the file system via the command line.
On some systems (e.g. PCLinuxOS), ls has an alias of just l. Many systems[which?] also alias ls -l to ll or ls -la to la (e.g. PC-BSD).[citation needed]
The following example demonstrates the output of the ls command given two different arguments:
$ pwd /home/fred $ ls -l drwxr--r-- 1 fred editors 4096 drafts -rw-r--r-- 1 fred editors 30405 edition-32 -r-xr-xr-x 1 fred fred 8460 edit $ ls -F drafts/ edition-32 edit*
In this example, the user fred has a directory named drafts, a regular file called edition-32, and an executable named edit in his home directory. ls uses unix file permission notation to indicate which users or groups are allowed to access each file or directory.
This means, in short, that the first column lists permissions for: user (u), owning group (g), and others (o)
drwxr--r-- 1 fred editors 4096 Mar 1 2007 drafts
which maps to
duuugggooo (hard link count) owner group size modification_date name
meaning that drafts is a directory, the user has rwx, group members have r, and others have r (read) access. See unix file permission notation for a more detailed description.
|
||||||||||||||||||||||||||||||||
This entry is from Wikipedia, the leading user-contributed encyclopedia. It may not have been reviewed by professional editors (see full disclaimer)