Linux commands to display the lists of files and directories
ls command with options
kodingwindow@kw:~$ ls a.out KW.class KW.java Desktop Downloads Pictures Templates Weekdays kw.c kw.csv kw.py Documents Music Public Videos kodingwindow@kw:~$ ls -a . kw.csv .mozilla .ssh .. KW.java Music .sudo_as_admin_successful a.out kw.py Pictures Templates .bash_history Desktop .pki .theano .bundle Documents Public Videos .cache Downloads .python_history Weekdays .config .gnupg .r kw.c .keras .Rhistory KW.class .local .rstudio-desktop kodingwindow@kw:~$ ls -A a.out kw.csv .keras .python_history .theano .bash_history KW.java .local .r Videos .bundle kw.py .mozilla .Rhistory Weekdays .cache Desktop Music .rstudio-desktop .config Documents Pictures .ssh kw.c Downloads .pki .sudo_as_admin_successful KW.class .gnupg Public Templates kodingwindow@kw:~$ ls -1 a.out kw.c KW.class kw.csv KW.java kw.py Desktop Documents Downloads Music Pictures Public Templates Videos Weekdays kodingwindow@kw:~$
Display the permissions of files/directories
kodingwindow@kw:~$ ls -l total 72 -rwxr-xr-x 1 kodingwindow kodingwindow 13968 May 16 2019 a.out -rw-r--r-- 1 kodingwindow kodingwindow 90 Jun 13 11:17 kw.c -rw-rw-r-- 1 kodingwindow kodingwindow 411 Aug 28 14:42 KW.class -rw-rw-r-- 1 kodingwindow kodingwindow 404 Jul 19 11:48 kw.csv -rw-r--r-- 1 kodingwindow kodingwindow 179 Feb 24 2020 KW.java -rw-r--r-- 1 kodingwindow kodingwindow 1608 Aug 15 12:16 kw.py drwxr-xr-x 2 kodingwindow kodingwindow 4096 Apr 2 2019 Desktop drwxr-xr-x 2 kodingwindow kodingwindow 4096 Aug 28 17:08 Documents drwxr-xr-x 3 kodingwindow kodingwindow 4096 Jun 27 23:05 Downloads drwxr-xr-x 2 kodingwindow kodingwindow 4096 Jun 6 09:06 Music drwxr-xr-x 3 kodingwindow kodingwindow 4096 Aug 14 15:14 Pictures drwxr-xr-x 2 kodingwindow kodingwindow 4096 Apr 2 2019 Public drwxr-xr-x 2 kodingwindow kodingwindow 4096 Apr 2 2019 Templates drwxr-xr-x 2 kodingwindow kodingwindow 4096 Jun 4 20:38 Videos -rw-rw-r-- 1 kodingwindow kodingwindow 84 May 31 11:23 Weekdays
Display the inode (index number) of files/directories
kodingwindow@kw:~$ ls -li total 72 3408466 -rwxr-xr-x 1 kodingwindow kodingwindow 13968 May 16 2019 a.out 3408372 -rw-r--r-- 1 kodingwindow kodingwindow 90 Jun 13 11:17 kw.c 3411453 -rw-rw-r-- 1 kodingwindow kodingwindow 411 Aug 28 14:42 KW.class 3412502 -rw-rw-r-- 1 kodingwindow kodingwindow 404 Jul 19 11:48 kw.csv 3413037 -rw-r--r-- 1 kodingwindow kodingwindow 179 Feb 24 2020 KW.java 3419358 -rw-r--r-- 1 kodingwindow kodingwindow 1608 Aug 15 12:16 kw.py 3407940 drwxr-xr-x 2 kodingwindow kodingwindow 4096 Apr 2 2019 Desktop 3407944 drwxr-xr-x 2 kodingwindow kodingwindow 4096 Aug 28 17:08 Documents 3407941 drwxr-xr-x 3 kodingwindow kodingwindow 4096 Jun 27 23:05 Downloads 3407945 drwxr-xr-x 2 kodingwindow kodingwindow 4096 Jun 6 09:06 Music 3407946 drwxr-xr-x 3 kodingwindow kodingwindow 4096 Aug 14 15:14 Pictures 3407943 drwxr-xr-x 2 kodingwindow kodingwindow 4096 Apr 2 2019 Public 3407942 drwxr-xr-x 2 kodingwindow kodingwindow 4096 Apr 2 2019 Templates 3407947 drwxr-xr-x 2 kodingwindow kodingwindow 4096 Jun 4 20:38 Videos 3408355 -rw-rw-r-- 1 kodingwindow kodingwindow 84 May 31 11:23 Weekdays kodingwindow@kw:~$ ls -i 3408466 a.out 3413037 KW.java 3407941 Downloads 3407942 Templates 3408372 kw.c 3419358 kw.py 3407945 Music 3407947 Videos 3411453 KW.class 3407940 Desktop 3407946 Pictures 3408355 Weekdays 3412502 kw.csv 3407944 Documents 3407943 Public
Explore the ls command with man page(s)
kodingwindow@kw:~$ 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)
kodingwindow@kw:~$ 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)
kodingwindow@kw:~$ 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 ~ ...
What Next?
Linux commands to create and remove a file
Linux commands to create and remove the directories/sub-directories
Linux commands to copy and move the files
Advertisement