Directory Listings: The ls
Command¶
Basic Usage¶
Displays directory content
Without any options ⟶ names only
No metadata, no nothing
When terminal supports color output, different file types are colored differently ⟶ minimal file type hintingx
No further arguments ⟶ current working directory (CWD)
$ pwd /home/jfasch $ ls Documents Downloads Homebrain Pictures tmp venv work
Displaying non CWD directory:
$ ls Documents/ Buchhaltung.csv python-3.10.0-docs-html python-doc.zip Umsatzsteuerbescheid1.pdf
Many Options¶
Option |
Description |
---|---|
|
Long listing ⟶ show metadata |
|
Show hidden files |
|
Show directory, not its content ( |
|
File sizes (and possibly others) in human readable form (e.g.,
|
|
Sort by timestamp |
|
Recurse into directories |
… |
Metadata¶
Showing names only is rarely sufficient
⟶ file type, timestamp, owner, group owner, permissions, …
$ ls -l /etc/passwd
-rw-r--r-- 1 root root 2746 Mar 3 14:12 /etc/passwd
|
File type ( |
|
|
|
Reference count (⟶ Symbolic Links, Hard Links) |
|
|
|
|
|
File size |
|
Last modification timestamp |
|
Entry name |
File Types¶
Everything is a file 😎
But there are different types of files 🙄
ls -l
, first characterType
-
Regular file
d
Directory
c
Character device
b
Block device
l
p
Named pipe
Examples …
$ ls -l /etc/passwd -rw-r--r--. 1 root root 2746 Mar 3 14:12 /etc/passwd
$ ls -ld Documents drwxr-xr-x. 1 jfasch jfasch 154 Mar 9 17:22 Documents
$ ls -l /dev/{zero,null} crw-rw-rw-. 1 root root 1, 3 Mar 7 12:10 /dev/null crw-rw-rw-. 1 root root 1, 5 Mar 7 12:10 /dev/zero
$ ls -al .emacs lrwxrwxrwx. 1 jfasch jfasch 42 Sep 27 12:16 .emacs -> /home/jfasch/Homebrain/local-config/.emacs