Linux commands to display the lists of files and directories
ls command with options
codeaft@codeaft:~$ ls a.out Codeaft.class Codeaft.java Desktop Downloads Pictures Templates Weekdays codeaft.c codeaft.csv codeaft.py Documents Music Public Videos codeaft@codeaft:~$ ls -a . codeaft.csv .mozilla .ssh .. Codeaft.java Music .sudo_as_admin_successful a.out codeaft.py Pictures Templates .bash_history Desktop .pki .theano .bundle Documents Public Videos .cache Downloads .python_history Weekdays .config .gnupg .r codeaft.c .keras .Rhistory Codeaft.class .local .rstudio-desktop codeaft@codeaft:~$ ls -A a.out codeaft.csv .keras .python_history .theano .bash_history Codeaft.java .local .r Videos .bundle codeaft.py .mozilla .Rhistory Weekdays .cache Desktop Music .rstudio-desktop .config Documents Pictures .ssh codeaft.c Downloads .pki .sudo_as_admin_successful Codeaft.class .gnupg Public Templates codeaft@codeaft:~$ ls -1 a.out codeaft.c Codeaft.class codeaft.csv Codeaft.java codeaft.py Desktop Documents Downloads Music Pictures Public Templates Videos Weekdays codeaft@codeaft:~$
Display the permissions of files/directories
codeaft@codeaft:~$ ls -l total 72 -rwxr-xr-x 1 codeaft codeaft 13968 May 16 2019 a.out -rw-r--r-- 1 codeaft codeaft 90 Jun 13 11:17 codeaft.c -rw-rw-r-- 1 codeaft codeaft 411 Aug 28 14:42 Codeaft.class -rw-rw-r-- 1 codeaft codeaft 404 Jul 19 11:48 codeaft.csv -rw-r--r-- 1 codeaft codeaft 179 Feb 24 2020 Codeaft.java -rw-r--r-- 1 codeaft codeaft 1608 Aug 15 12:16 codeaft.py drwxr-xr-x 2 codeaft codeaft 4096 Apr 2 2019 Desktop drwxr-xr-x 2 codeaft codeaft 4096 Aug 28 17:08 Documents drwxr-xr-x 3 codeaft codeaft 4096 Jun 27 23:05 Downloads drwxr-xr-x 2 codeaft codeaft 4096 Jun 6 09:06 Music drwxr-xr-x 3 codeaft codeaft 4096 Aug 14 15:14 Pictures drwxr-xr-x 2 codeaft codeaft 4096 Apr 2 2019 Public drwxr-xr-x 2 codeaft codeaft 4096 Apr 2 2019 Templates drwxr-xr-x 2 codeaft codeaft 4096 Jun 4 20:38 Videos -rw-rw-r-- 1 codeaft codeaft 84 May 31 11:23 Weekdays
Display the inode (index number) of files/directories
codeaft@codeaft:~$ ls -li total 72 3408466 -rwxr-xr-x 1 codeaft codeaft 13968 May 16 2019 a.out 3408372 -rw-r--r-- 1 codeaft codeaft 90 Jun 13 11:17 codeaft.c 3411453 -rw-rw-r-- 1 codeaft codeaft 411 Aug 28 14:42 Codeaft.class 3412502 -rw-rw-r-- 1 codeaft codeaft 404 Jul 19 11:48 codeaft.csv 3413037 -rw-r--r-- 1 codeaft codeaft 179 Feb 24 2020 Codeaft.java 3419358 -rw-r--r-- 1 codeaft codeaft 1608 Aug 15 12:16 codeaft.py 3407940 drwxr-xr-x 2 codeaft codeaft 4096 Apr 2 2019 Desktop 3407944 drwxr-xr-x 2 codeaft codeaft 4096 Aug 28 17:08 Documents 3407941 drwxr-xr-x 3 codeaft codeaft 4096 Jun 27 23:05 Downloads 3407945 drwxr-xr-x 2 codeaft codeaft 4096 Jun 6 09:06 Music 3407946 drwxr-xr-x 3 codeaft codeaft 4096 Aug 14 15:14 Pictures 3407943 drwxr-xr-x 2 codeaft codeaft 4096 Apr 2 2019 Public 3407942 drwxr-xr-x 2 codeaft codeaft 4096 Apr 2 2019 Templates 3407947 drwxr-xr-x 2 codeaft codeaft 4096 Jun 4 20:38 Videos 3408355 -rw-rw-r-- 1 codeaft codeaft 84 May 31 11:23 Weekdays codeaft@codeaft:~$ ls -i 3408466 a.out 3413037 Codeaft.java 3407941 Downloads 3407942 Templates 3408372 codeaft.c 3419358 codeaft.py 3407945 Music 3407947 Videos 3411453 Codeaft.class 3407940 Desktop 3407946 Pictures 3408355 Weekdays 3412502 codeaft.csv 3407944 Documents 3407943 Public
Explore the ls command with man page(s)
codeaft@codeaft:~$ man ls LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐ fied. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE with -l, scale sizes by SIZE when printing them; e.g., '--block-size=M'; see SIZE format below -B, --ignore-backups do not list implied entries ending with ~ ...
Explore the ls command with info page(s)
codeaft@codeaft:~$ info ls Next: dir invocation, Up: Directory listing 10.1 ‘ls’: List directory contents ================================== The ‘ls’ program lists information about files (of any type, including directories). Options and file arguments can be intermixed arbitrarily, as usual. For non-option command-line arguments that are directories, by default ‘ls’ lists the contents of directories, not recursively, and omitting files with names beginning with ‘.’. For other non-option arguments, by default ‘ls’ lists just the file name. If no non-option argument is specified, ‘ls’ operates on the current directory, acting as if it had been invoked with a single argument of ‘.’. ...
Explore the ls command with help option(s)
codeaft@codeaft:~$ ls --help Usage: ls [OPTION]... [FILE]... List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE with -l, scale sizes by SIZE when printing them; e.g., '--block-size=M'; see SIZE format below -B, --ignore-backups do not list implied entries ending with ~ ...
Comments and Reactions