LS(1B)
π LS(1B) β the (BSD) list contents of directory bible ποΈβ¨
okay bestie, listen up β this is the BSD System Compatibility flavour of ls, living at /ucb/ls, and she is that girl. she lists stuff, she's got opinions about sorting, and she will absolutely colorize your filenames if you let her. let's get into it π«Ά
β¨ NAME β¨
ls β (BSD) list contents of directory. that's it, that's the whole job, and she does it iconically π
π SYNOPSIS π
/ucb/ls [-aAcCdfFgHilLqrRstu1hSUX] [file ...]
πΈ DESCRIPTION πΈ
so here's the vibe: for every directory argument you hand her, ls lists what's inside that directory. for every file argument, she just repeats the name back at you plus whatever other info you asked for. simple, clean, slay.
the output is sorted alphabetically by default β no cap, that's just how she rolls. if you give her no argument at all, she lists the current directory. and if you give her several arguments? she sorts the arguments appropriately first, but β important β file arguments show up before directories and their contents. periodt.
there are several options, and yes we're going through all of them:
-aβ list all the entries. usually files that begin with a.get suppressed, but not today bestie.-Aβ list all entries except.and... this is the default iflsis invoked by the super-user π.-cβ use the time of last modification to the inode (mode, etc.) instead of last modification to the file, for sorting (-t) or printing (-l).-Cβ output printed in multiple columns, sorted down the columns. this format is selected by default if standard output refers to a terminal.-dβ if the argument is a directory, list only its name, not its contents (mostly used with-lto get status on the directory itself).-fβ force each argument to be interpreted as a directory and list the name found in each slot. this option turns off-l,-t,-s, and-r, and turns on-a; the order is the order in which entries appear in the directory. chaotic? maybe. iconic? absolutely.-Fβ indicates the file type as a letter appended to each pathname:
/ directory
* executable file
@ symbolic link
| named pipe
= socket
> door
-gβ if combined with-l, the group ID is added to the output.-iβ print the i-number in the first column of the report for each file listed.-lβ list in long format, giving mode, number of links, owner, size in bytes, and time of last modification for each file (see below π). if the file is a special file, the size field will instead contain the major and minor device numbers. symbolic links specified as arguments are not followed with this option unless the-Hor-Loption is also present.-Lβ follow symbolic links in arguments.-qβ non-printable characters are printed as question marks?. this is the default if standard output refers to a terminal.-rβ reverse the order of sort, to get reverse alphabetic or oldest first as appropriate.-Rβ lists subdirectories recursively. she goes deep π³οΈ-sβ give size in blocks, including indirect blocks, for each entry.-tβ sort by time modified (latest first) instead of by name, as is normal.-uβ use time of last access instead of last modification for sorting (-t) or printing (-l).-1β print one filename per output line. this is the default if standard output does not refer to a terminal.
the following option was introduced with POSIX.1-2001:
-Hβ follow symbolic links given as arguments.
the following options are available as extensions:
-hβ print file sizes in human-readable powers of 1024, i.e.Kfor kilobyte,Mfor megabyte,Gfor gigabyte,Tfor terabyte,Pfor petabyte, andEfor exabyte. no more counting zeros bestie π₯-Sβ sort by file size.-Uβ do not sort at all. feral behaviour, honestly.-Xβ sort by file name extension, i.e. by the component of the file name following the last dot.
π§ the mode string, decoded π§
the mode printed under the -l option contains 10 characters, and here's how to read them. the first character is:
dif the entry is a directorybif the entry is a block-type special filecif the entry is a character-type special filepif the entry is a named pipelif the entry is a symbolic linkSif the entry is a socketsif the entry is a XENIX semaphoremif the entry is a XENIX shared data (memory) fileDif the entry is a door-if the entry is a plain file
the next 9 characters are interpreted as three sets of three bits each. the first set refers to owner permissions, the next to permissions to others in the same user-group, and the last to all others. within each set, the three characters indicate permission respectively to read, to write, or to execute the file as a program. and for a directory, execute permission is interpreted to mean permission to search the directory for a specified file. the permissions are indicated as follows:
rif the file is readablewif the file is writablexif the file is executable-if the indicated permission is not granted
the group-execute permission character is given as:
sif the file has set-group-ID modeSif the set-group-ID bit is set on the file but it is not executable
likewise, the user-execute permission character is given as:
sif the file has set-user-ID modeSif the set-user-ID bit is set on the file but it is not executable
the last character of the mode (normally x or -) is:
tif the sticky bit of the mode is onTif the sticky bit is on but the file is not executable
see chmod(1) for the meaning of this mode. iykyk π
when the sizes of the files in a directory are listed, a total count of blocks, including indirect blocks is printed.
π colors, because obviously π
if ls writes its output to a terminal that supports colors or boldface, the file names printed are colorized according to their types:
- blue/bold if the file is a directory
- yellow/bold if the file is a special file
- yellow if the file is a named pipe
- cyan if the file is a symbolic link
- magenta/bold if the file is a socket or a door
- magenta if the file is a XENIX special file
- green/bold if the file is executable
forlc, colors are enabled even if the output is not written to a terminal. this is mainly useful if the output is filtered through a pager which handles colors, such aspg(1). cute little pipeline queen behaviour π
π¦ FILES π¦
/etc/passwdβ to get user IDs./etc/groupβ to get group IDs.
π ENVIRONMENT VARIABLES π
COLUMNSβ overrides the auto-detected terminal width.LANG,LC_ALLβ seelocale(7).LC_COLLATEβ affects the order of printed items when sorting by name.LC_CTYPEβ determines whether a character is printable.LC_TIMEβ sets the format of time strings printed with the-loption.TERMβ used to determine the terminal type.
π SEE ALSO π
and that's the whole page, bestie π«Ά this one's brought to you by the Heirloom Toolchest, dated 1/29/05, filed under LS(1B) β go forth and list your directories with main character energy β¨π
πΈ
π¦ where this page comes from
- nixos 26.05: heirloom 070715
- nixpkgs unstable: heirloom 070715
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms