ebooksgratis.com

See also ebooksgratis.com: no banners, no cookies, totally FREE.

CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
ls - Wikipedia, the free encyclopedia

ls

From Wikipedia, the free encyclopedia

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

[edit] History

An ls utility appeared in the original version of AT&T UNIX. Its name derives from a similar command list segments in Multics, a system in which memory segments and files were synonyms. 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.

[edit] Behavior

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 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:

  • -l long format, displaying Unix file types, 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 names start with "." By default, these files are excluded from the list.
  • -R recursively lists subdirectories. The command ls -R / would therefore list all files.
  • -d shows information about a symbolic link or directory, rather than about the link's target or listing the contents of a directory.

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 can be abbreviated to just l. Many systems also allow ls -l to be abbreviated to ll.

[edit] Sample usage

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 what users or groups are allowed to access each file or directory.

This means, in short, that the first column lists user(u), owning group (g), and other's permission (o)

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

which maps to

duuugggooo   (hard link count) owner group    size  creation_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.

[edit] See also

[edit] External links


aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -