ls command in linux
ls - is the list command in Linux Operating System. ls command will show the full list of files or entries of the directory. type ls and press the enter key in the terminal window. The file list will be displayed.
// type ls and press enter at putty/terminal prompt
freedomtutorials:~> ls
// type "ls -lh" and press enter at putty/terminal prompt
ls -lh
option | description |
---|---|
-a, --all | display all files, not to ignore entries starting with . (dot / period) , in other words include hidden files in list. |
-A, --almost-all | display all file apart from . and .. |
-l --author | use this option with -l option to display author of each file. |
-b, --escape | display octal escapes for nongraphic characters |
-B, --ignore-backups | this option will not list implied entries ending with ~ |
-c | use this option with -lt option to display to sort by ctime. |
-C | displays entries by columns |
-d, --directory | display directory entries instead of contents |
-D, --dired | display output designed for Emacs' dired mode |
-f | this command will not sort entries and will enable -aU and disable -ls --color |
-F, --classify | will append indicator (one of */=>@ |
-g | same as -l but will not list owner. |
-G, --no-group | this option will not include group name in display when using long listing option. |
-h, --human-readable | when using -l option, this option will display entries size in in human readable format eg 2K, 2M, 3G. |
--si | when using -l option, this option will display with powers of 1000 not 1024. |
-i, --inode | displays the index number of each file. |
-I, --ignore=PATTERN | will not displays implied entries matching shell PATTERN |
-k | displays shell PATTERN like --block-size=1K |
-l | displays long listing format. |
-L, --dereference | while showing file information for a symbolic link, display information for the file the link references rather than for the link itself |
-m | displays comma separated list of entries. |
-n, --numeric-uid-gid | displays like -l, but displays list numeric user and group IDs. |
-N, --literal | displays raw entry names |
-o | displays like -l, but will not displays group information |
-p, --indicator-style=slash | when listing directories this option append / indicator to directories |
-q, --hide-control-chars | display ? instead of non graphic characters |
-Q, --quote-name | display entry names in double quotes |
-r, --reverse | display reverse order while sorting |
-R, --recursive | display sub-directories recursively |
-s, --size | display the allocated size of each file, in blocks |
-t | sort entries by modification time |
-T, --tabsize=COLS | displays tab stops at each COLS instead of 8 chars |
-u | displays sort by access time |
-U | this option will not sort, displays entries in directory order |
-v | displays with version sort and numbers within text |
-w, --width=COLS | displays within screen width instead of current value |
-x | displays entries by lines instead of by columns |
-X | displays by sorting alphabetically by entry extension |
-1 | displays entries one file per line |
ls --version | displays version of ls command and author information. |
// type "ls -d */" and press enter at putty/terminal prompt
ls -d */
// type "ls -l" and press enter at putty/terminal prompt
ls -l
// type "ls -lrth" and press enter at putty/terminal prompt
ls -lrth