ls
ls linux command cheatsheet by Thamizhiniyan C S
Introduction
Ls is short for “list”. This command lists information about directories and any type of files in the working directory.
Syntax
ls [OPTION]... [FILE]...
Important Flags
Flag | Description |
---|---|
| do not ignore entries starting with . |
| do not list implied . and .. |
| print C-style escapes for nongraphic characters |
| do not list implied entries ending with ~ |
| with -lt: sort by, and show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first |
| list entries by columns |
| list directories themselves, not their contents |
| generate output designed for Emacs' dired mode |
| list all entries in directory order |
| Add “/” at the end of each directory for distinguishing between files and directories |
| like -l, but do not list owner |
| in a long listing, don't print group names |
| with -l and -s, print sizes like 1K 234M 2G etc. |
| follow symbolic links listed on the command line |
| print the index number of each file |
| do not list implied entries matching shell PATTERN |
| default to 1024-byte blocks for file system usage |
| use a long listing format |
| when showing file information for a symbolic link, show information for the file the link references rather than for the link itself |
| fill width with a comma separated list of entries |
| like -l, but list numeric user and group IDs |
| print entry names without quoting |
| like -l, but do not list group information |
| append / indicator to directories |
| print ? instead of nongraphic characters |
| enclose entry names in double quotes |
| reverse order while sorting |
| list subdirectories recursively |
| print the allocated size of each file, in blocks |
| sort by file size, largest first |
| sort by time, newest first; see --time |
| assume tab stops at each COLS instead of 8 |
| with -lt: sort by, and show, access time |
| do not sort; list entries in directory order |
| natural sort of (version) numbers within text |
| set output width to COLS. 0 means no limit |
| list entries by lines instead of by columns |
| sort alphabetically by entry extension |
| print any security context of each file |
| list one file per line |
Examples
Command | Description |
---|---|
| Add “/” at the end of each directory for distinguishing between files and directories |
| Prints out directories and files separated by a comma |
| Add quotation marks to all directories and files |
| To get the Inode (index node) number of all directories and files |
| Sort directories and files in the reverse order |
| Sort directories and files by time and date of creation or modification |
| Sort directories and files alphabetically by entry extension |
| View hidden files |
| To print out a long listing format of files and directories |
| Displays information about the user, size of the file, and date and time of modification of all the files |
| Directory Tree / Recursively listing directories |
| List UID and GID of Files |
| Display Files in Human Readable Format |
| View Reverse Output Order by Date |
| List Files by Size |
| To check information about the directory only |
Last updated