One Linux command per day (3): ls command

Source: Internet
Author: User
Tags syslog

The ls command is used to display the target list, which is a high-usage command in Linux. The output information of the LS command can be colored and highlighted to partition different types of files.

Grammar
LS (option) (parameter)
Options
-A: Displays all files and directories (ls default file name or directory name is ".") not listed);-A: show except hidden files "." and ".." A list of all files other than the; C: multiple columns display the output results. This is the default option;-L: In contrast to the "-C" option, all output information is output in a single-column format, not output as multiple columns;-f: Appends the type identifier of the file after each output item, meaning: "*" means a normal file with executable permissions, "/" for the Directory, "@" for symbolic links, Represents a command pipeline FIFO, and "=" represents a sockets socket. When the file is a normal file, no identifier is output;-D: Displays only the directory name, not the table of contents. Displays the symbolic link file itself without displaying the list of directories it points to;-F: The effect of this parameter is the same as specifying the "AU" parameter, and the effect of the "LST" parameter is turned off;-I: Displays the file index node number (inode). An index node represents a file;--file-type: The function is the same as the "-f" option, but does not display "*";
-K: Displays the file size in kilobytes (Kbytes);
-L: Displays a table of contents in a long format. The output information includes file name, file type, permission mode, number of hard connections, owner, group, file size, and last modification time of file, etc. from left to right.
-M: The name of each file and directory separated by the "," area;
-N: Replace its name with user identification code and group identifier;
-R: The list of directory contents is sorted and output in reverse order of file name;
-S: Displays the size of files and directories, in chunks;
-T: Sorts the file and directory change times;
-L: If you encounter a file or directory with a symbolic link, directly list the original file or directory that the link points to;
-R: Recursive processing, all files and subdirectories under the specified directory are processed together;
-B: Outputs the non-output characters in the file with the backslash "" and the character encoding;
--full-Time: Lists the full date and times;
--color[=when]: Use different colors to highlight different types of.
Parameters
Directory: Specifies the directory in which to display the list, or it can be a specific file.
Example

Displays non-hidden files and directories in the current directory:

[[Email protected] ~] # lsanaconda-ks.cfg install.log install.log.syslog

Output long format list (file and folder details):

[[Email protected] ~] # ls-lTotal 72-RW-------. 1 root root 1497 13:34 anaconda-ks.cfg-rw-r--r--. 1 root root 51437 13:34 install.log-rw-r--r--. 1 root root 11504 13:31 Install.log.syslog

Displays a list of all files, including hidden files, in the current directory:

[[Email protected] ~] # ls-a .                . Bash_history  . bashrc.  gconf.              TCSHRC               ... Bash_logout   . config  install.log         . Xauthgbvjmpanaconda-ks.cfg  . Bash_profile  . CSHRC   Install.log.syslog

To display inode information for a file:

The index node (the index inode is referred to as "Inode") is a special concept in Linux, and two text with the same index node number is essentially the same file (except for the file name).

[[Email protected] ~] #  5111817-RW-------. 1 root root  1497 13:34 anaconda-ks.cfg5111810-rw-r--r--. 1 root root 51437-13:34 Install.lo G

Horizontal Output File list:

[[Email protected] ~] # ls-manaconda-ks.cfg, Install.log, Install.log.syslog

The most recently modified files are displayed at the top:

[[Email protected] ~] # ls-tanaconda-ks.cfg  install.log  install.log.syslog

Print the UID and GID of the file:

[[Email protected] ~] # ls-nTotal 72-RW-------.  1 0 0  1497 13:34 anaconda-ks.cfg-rw-r--r--. 1 0 0 51437 13:34 install.log-rw-r--r--.  1 0 0 11504 13:31 install.log.syslog

Show Recursive files:

[[Email protected] ~] # Ls-r .: Anaconda-ks.cfg  install.log  install.log.syslog

One Linux command per day (3): ls command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.