Living in the Shell #5; ls (List Files/Directories)

Living in the Shell #5; ls (List Files/Directories)

ยท

2 min read

ls ๐Ÿšš

Lists directory content.

Long list (detailed format) -l

cd ~ && ls -l
drwxr-xr-x 5 babak babak       4096 Nov  1 12:49 Desktop
drwxr-xr-x 9 babak babak       4096 Nov 21 18:49 Documents
drwxr-xr-x 2 babak babak      20480 Nov 23 17:21 Pictures
...

Show directories first --group-directories-first

cd ~ && ls --group-directories-first

List directory itself, not its content -d

cd ~ && ls -lhd Documents
drwxr-xr-x 9 babak babak 4.0K Nov 21 18:49 Documents

List all files (include dot-files) -a

cd ~ && ls -a

Print human-readable sizes -h

cd ~ && ls -lh
drwxr-xr-x 5 babak babak 4.0K Nov  1 12:49 Desktop
drwxr-xr-x 9 babak babak 4.0K Nov 21 18:49 Documents
drwxr-xr-x 2 babak babak  20K Nov 23 17:21 Pictures
...

Sort by time -t

cd ~ && ls -lht
drwxr-xr-x 2 babak babak  20K Nov 23 17:21 Pictures
drwxr-xr-x 9 babak babak 4.0K Nov 21 18:49 Documents
drwxr-xr-x 5 babak babak 4.0K Nov  1 12:49 Desktop

Sort by size -s

cd ~ && ls -lhs

Reverse sort order -r

cd ~ && ls -lhsr
drwxr-xr-x 2 babak babak  20K Nov 23 17:21 Pictures
drwxr-xr-x 9 babak babak 4.0K Nov 21 18:49 Documents
drwxr-xr-x 5 babak babak 4.0K Nov  1 12:49 Desktop
ย