What Is the Command to List Files in Unix and Unix-like Operating Systems?

ls
Ls --color=auto -ls linux.png

long file listing with "ls --color=machine -fifty" in linux showing various modes, appointment formats, colors and appended indicators (executables and directories).

Original author(south) Richard Stallman and David MacKenzie
Operating organisation Multics, Unix, Unix-like, Plan 9, Inferno, MSX-DOS, Mac Os
Type Command
License
  • coreutils: GPLv3+
  • BusyBox: GPL-2.0-only
  • Toybox: 0BSD

In computing, ls is a command to list calculator files in Unix and Unix-similar operating systems. ls is specified by POSIX and the Single UNIX Specification. When invoked without any arguments, ls lists the files in the current working directory. The command is also available in the EFI shell.[1] In other environments, such as DOS, OS/ii, and Microsoft Windows, similar functionality is provided by the dir command. The numerical computing environments MATLAB and GNU Octave include an ls part with like functionality.[ii] [3]

History [edit]

An ls 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".[4] [5] [6] ls is part of the X/Open Portability Guide since event ii of 1987. It was inherited into the beginning version of POSIX.ane and the Single Unix Specification.[7]

An ls command is also part of ASCII'south MSX-DOS2 Tools for MSX-DOS version two.[eight]

Today, the ii popular versions of ls are the one provided with the GNU coreutils bundle, and that released by diverse BSD variants. Both are free software and open up source, and have merely pocket-size syntax differences. The version of ls bundled in GNU coreutils was written past Richard Stallman and David MacKenzie.[9]

The command is bachelor as a split up package for Microsoft Windows as office of the UnxUtils collection of native Win32 ports of common GNU Unix-similar utilities.[10]

Beliefs [edit]

Unix and Unix-similar operating systems maintain the thought of a current working directory, that is, where ane is currently positioned in the bureaucracy of directories. When invoked without any arguments, ls lists the files in the current working directory. If another directory is specified, then ls will listing the files in that location, and in fact the user may specify any list of files and directories to be listed.

Files names starting with "." are not listed unless -a (show all) is specified, -A (show all except "." and "..") is specified, or the files are specified explicitly.

Without options, ls displays files names only. The about common options to display additional information are:

  • -50 long format, displaying Unix file types, permissions, number of hard links, owner, group, size, last-modified engagement and filename
  • -F append a "/" to directory names and a "*" to executable files.
  • -m brandish group merely not owner
  • -o display possessor merely non group (when combined with -g both group and possessor are suppressed)
  • -d shows information most a symbolic link or directory, rather than near the link's target or listing the contents of a directory.
  • -h output sizes in human being readable format. (eastward.g., 1K, 234M, 2G, etc.) This option is not part of the POSIX standard, although implemented in several systems, e.thousand., GNU coreutils in 1997,[11] FreeBSD 4.v in 2002,[12] and Solaris 9 in 2002.[13]

Additional options controlling how files are displayed include:

  • -f practise not sort. Useful for directories containing large numbers of files.
  • -t sort the listing of files by modification fourth dimension. (default is alphabetically)
  • -1 (i) force output to be ane entry per line.
  • -R recursively list files in subdirectories and their subdirectories …
  • --full-time to evidence times with seconds and milliseconds instead of downwardly to the minute.

Information technology is ofttimes possible to highlight different types of files with dissimilar colors, instead of with characters every bit -F would. This is an expanse where the 2 main ls versions differ:

  • GNU ls uses the --color option; checks the Unix file type, the file permissions and the file extension and uses its own database to control colors maintained using dircolors.
  • FreeBSD ls uses the -1000 option; checks only the Unix file type and file permissions. and uses the termcap database[14]

When the selection to use colour to indicate file types is selected, the output might look similar:

-rw-r--r-- one tsmitt nregion 26650 December 20 11:xvi audio.ogg brw-r--r-- ane tsmitt nregion 64 Jan 27 05:52 bd-block-device crw-r--r-- i tsmitt nregion 255 Jan 26 13:57 cd-character-device -rw-r--r-- ane tsmitt nregion 290 Jan 26 14:08 paradigm.png drwxrwxr-x ii 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 December 20 09:39 fi-regular-file lrwxrwxrwx 1 tsmitt nregion three Jan 26 11:44 ln-soft-link -> dir lrwxrwxrwx 1 tsmitt nregion 15 Dec 20 x:57 or-orphan-link -> mi-missing-link drwxr-xrwx 2 tsmitt nregion 4096 Dec xx 10:58 ow-other-writeable-dir prw-r--r-- 1 tsmitt nregion 0 Jan 26 11:fifty pi-pipe -rwxr-sr-ten 1 tsmitt nregion 0 Dec 20 xi:05 sg-setgid srw-rw-rw- 1 tsmitt nregion 0 Jan 26 12:00 so-socket drwxr-xr-t two tsmitt nregion 4096 December twenty x: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 two tsmitt nregion 4096 Dec xx 11:ten tw-gummy-other-writeable-dir

Sample usage [edit]

The following example demonstrates the output of the ls control given two different arguments:

                        $            ls -l            drwxr--r--   i fjones editors    4096  drafts            -rw-r--r--   1 fjones editors   30405  edition-32            -r-xr-xr-10   1 fjones bookeepers 8460  edit.sh            $            ls -F            drafts/            edition-32            edit.sh*          

In the above example, the user fjones has a directory named drafts, a regular file named edition-32, and an executable named edit.sh in his home directory. ls uses Unix file permission notation to define the access for the user(i.e. himself), group members for various groups and other users.

                        drwxr--r--   i fred  editors   4096  Mar 1  2007 drafts          

In this case, drafts is a directory (denoted by the file descriptor d), and the characters after this indicate the permissions:

  • rwx: the owner (fjones) has the correct to read (r), write (west) and execute (x)
  • r--: users who are members of the editors group have read-but permissions; write and execute are non permitted, equally denoted by the hyphen characters (-)
  • r--: others (users aside from the owner or members of editors) take read-only permissions; write and execute are not permitted

See also [edit]

  • chown
  • chgrp
  • du (Unix)
  • mdls
  • User identifier (Unix)
  • Group identifier (Unix)
  • List of Unix commands
  • Unix directory structure

References [edit]

  1. ^ "EFI Shells and Scripting". Intel. Retrieved 2013-09-25 .
  2. ^ "List folder contents - MATLAB ls".
  3. ^ "Function Reference: Ls".
  4. ^ Multics manual page for ls or listing control
  5. ^ "A Brief History of the 'ls' command", Eric Fischer, The Linux Documentation Project
  6. ^ "Multics developer's manual - Commands and active functions" (PDF). p. 397.
  7. ^ ls  – Commands & Utilities Reference, The Unmarried UNIX Specification, Issue 7 from The Open Group
  8. ^ MSX-DOS2 Tools User'due south Manual by ASCII Corporation
  9. ^ ls(one)  – Linux General Commands Transmission; ls(ane)  – FreeBSD General Commands Manual
  10. ^ "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.
  11. ^ "(decode_switches): -h and -H override output units". coreutils.git. 1997-12-31.
  12. ^ "[base] Log of /stable/10/bin/ls/ls.c". 2001-12-28.
  13. ^ What'south New in the Solaris ix Operating Environment, Lord's day Microsystems, 2002
  14. ^ "FreeBSD Homo Pages — ls". Retrieved June 23, 2013.

External links [edit]

  • ls  – Commands & Utilities Reference, The Single UNIX Specification, Outcome 7 from The Open Group
  • ls(ane)  – FreeBSD General Commands Manual
  • ls(1)  – NetBSD General Commands Manual
  • ls(ane)  – OpenBSD General Commands Transmission
  • ls(one)  – Solaris 10 User Commands Reference Manual
  • ls(1)  – Linux User Commands Manual
  • ls(1)  – Program 9 Developer's Transmission, Book 1
  • ls(i)  – Inferno Full general commands Manual
  • GNU ls source code (equally part of coreutils)
  • ls at the LinuxQuestions.org wiki

pelletierourch1969.blogspot.com

Source: https://en.wikipedia.org/wiki/Ls

0 Response to "What Is the Command to List Files in Unix and Unix-like Operating Systems?"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel