Ls

Ls is also the orbit angle from the vernal equinox for planet Mars, see Ls (astronomy)
The title of this article is incorrect because of technical limitations. The correct title is ls.

ls is a command specified by POSIX and the Single UNIX Specification, and is thus implemented in Unix and Unix-like operating systems. ls, an abbreviation of list, lists files.

Contents

History

An ls utility first appeared in Version 5 AT&T UNIX. Its name derives from a similar command in Multics which meant "list segments". Today, two popular versions of ls include the Free Software Foundation's (part of the GNU coreutils package) and the one released by various BSD distributions, such as FreeBSD, OpenBSD, NetBSD, and Apple Computer's Darwin. Both are free software and open source.

Behaviour

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.

ls when invoked without any arguments, 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. 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 name starts with "." are not listed, unless -a flag is specified or unless these 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:

  • -l: long format, displaying permissions, number of hard links owner, group, size, date, and filename
  • -F appends a character revealing the nature of a file, for example, * for an executable, or / for a directory. Regular files have no suffix.
  • -a lists all files in the given directory, including those whose name starts with "." By default, these files are excluded from the list.
  • -R recursively lists subdirectories. The command ls -R / would therefore list all files.
  • --color (for GNU ls) behaves akin to -F but highlights different types of files with different colors.

ls has a large number of other options, as can be discovered in the man page. It is one of the most frequently used tools, and is virtually the de-facto interface to the file system via the command line.

Sample usage

$ 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*

Here we can see that 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 a special permissions notation that describes what the user, group, and "world" (everyone else) can do to the file. The first character of the permissions line indicates type (d signifies a directory, for example), and the rest of the line is split into blocks of three characters each, with the presence of a r, w, and x signifying the ability to read, write, or execute respectively. The first block represents the permissions for the user, the second for the group, and the third for world. For example, the user fred can read and write the edition-32 file, but not execute it; members of the group editors can only read this file and not write or execute it, as can everyone else.


See also

  • dir—the command in DOS that lists files, similar to ls.

External links

  • ls (http://wiki.linuxquestions.org/wiki/Ls) at the LinuxQuestions.org wiki.
  • ls.c (http://minnie.tuhs.org/UnixTree/V5/usr/source/s1/ls.c.html) source code of the AT&T Version 5 UNIX source code.

man pages

  • ls (http://www.freebsd.org/cgi/man.cgi?query=ls&apropos=0&sektion=0&manpath=FreeBSD+5.3-RELEASE+and+Ports&format=html) man page (FreeBSD)
  • ls (http://www.gnu.org/software/coreutils/manual/html_chapter/coreutils_10.html#SEC52) man page (GNU ls)
  • ls (http://www.openbsd.org/cgi-bin/man.cgi?query=ls) man page (OpenBSD)es:Ls

nl:Ls (Unix) zh:Ls

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools