Contents
Ls
In** computing, **** **** is a command to list computer files and directories in Unix and Unix-like operating **systems. It is specified by POSIX and the Single UNIX Specification. It is available in the EFI shell, as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities, or as part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2. The numerical computing environments MATLAB and GNU Octave include an function with similar functionality. In other environments, such as DOS, OS/2, TempleOS, Microsoft Windows, similar functionality is provided by the command.
History
An utility appeared in the first version of AT&T UNIX, the name inherited from a similar command in Multics also named 'ls', short for the word "list". ls is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification.
Behavior
Unix and Unix-like operating systems maintain the idea of a working directory. When invoked without arguments, lists the files in the working directory. If a directory is specified as an argument, the files in that directory are listed; if a file is specified, that file is listed. Multiple directories and files may be specified. In many Unix-like systems, names starting with a dot are hidden. Examples are, which refers to the working directory, and , which refers to its parent directory. Hidden names are not shown by default. With, all names, including all hidden names, are shown. Using shows all names, including hidden names, except for and. File names specified explicitly (for example ) are always listed. Without options, displays names only. The different implementations have different options, but common options include: Additional options controlling how items are displayed include: It may be possible to highlight different types of items with different colors. This is an area where implementations differ: When the option to use color to indicate item types is selected, the output might look like: -rw-r--r-- 1 tsmitt nregion 26650 Dec 20 11:16 audio.ogg brw-r--r-- 1 tsmitt nregion 64 Jan 27 05:52 bd-block-device crw-r--r-- 1 tsmitt nregion 255 Jan 26 13:57 cd-character-device -rw-r--r-- 1 tsmitt nregion 290 Jan 26 14:08 image.png drwxrwxr-x 2 tsmitt nregion 48 Jan 26 11:28 di-directory -rwxrwxr-x 1 tsmitt nregion 29 Jan 26 14:03 ex-executable -rw-r--r-- 1 tsmitt nregion 0 Dec 20 09:39 fi-regular-file lrwxrwxrwx 1 tsmitt nregion 3 Jan 26 11:44 ln-soft-link -> dir lrwxrwxrwx 1 tsmitt nregion 15 Dec 20 10:57 or-orphan-link -> mi-missing-link drwxr-xrwx 2 tsmitt nregion 4096 Dec 20 10:58 ow-other-writeable-dir prw-r--r-- 1 tsmitt nregion 0 Jan 26 11:50 pi-pipe -rwxr-sr-x 1 tsmitt nregion 0 Dec 20 11:05 sg-setgid srw-rw-rw- 1 tsmitt nregion 0 Jan 26 12:00 so-socket drwxr-xr-t 2 tsmitt nregion 4096 Dec 20 10:58 st-sticky-dir -rwsr-xr-x 1 tsmitt nregion 0 Dec 20 11:09 su-setuid -rw-r--r-- 1 tsmitt nregion 10240 Dec 20 11:12 compressed.gz drwxrwxrwt 2 tsmitt nregion 4096 Dec 20 11:10 tw-sticky-other-writeable-dir
Sample usage
The following example demonstrates the output of the command: Each line shows the (directory) or (file) indicator, Unix file permission notation, number of hard links (1 or 3), the file's owner, the file's group, the file size, the modification date/time, and the file name. In the working directory, the owner has a directory named , a regular file named , and an executable named which is "old", i.e. modified more than 6 months ago as indicated by the display of the year.
This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.
Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc.
Bliptext is not
affiliated with or endorsed by Wikipedia or the
Wikimedia Foundation.