One Linux command per day-ls

Source: Internet
Author: User
Tags control characters parent directory syslog

ls command in the Linux system is one of the most frequent use of a few commands, directly using the directory name, is the default display of the current directory of the file and subdirectory name, LS plus the specified directory name, you can view the specified directory of files and sub-directory name, LS can not only see the directory of files and subdirectories, You can also see the size, permissions, and modification dates of these files by specifying parameters, which are used much in your daily work.


Ls-list Directory Contents


  1. Command format

    ls [option] [directory]

  2. Common parameters

    -A or--all: Lists all files under the directory, including. and. As well as the hidden files.

    -A or--almost-all: equivalent-A, but not listed. (. Indicates the current directory) and. (.. Represents the parent directory) directory.

    -1: Only one file or directory is displayed per column.

    -C: Used with-LT parameters, LS-CLT directory, sorted by CTime (last modified time) and displayed CTime

    -D or--directory: Displays only name information, not files in the directory, usually with-L, Ls-ld directory.

    -G: Equivalent-L, but does not display the file owner.

    -G or--no-group: equivalent-L, but does not display the group to which the file belongs.

    -F: The displayed file is not sorted, the parameter "AU" is in effect, the parameter "LST" is invalidated.

    -H: Use "K", "M", "G" to display the file size.

    --si: This parameter effect is similar to "-H", but the unit of calculation is 1000Bytes instead of 1024Bytes.

    -H: Use the symbolic link in the command column to indicate the true destination.

    -I or--inode: Displays the inode number of the file and directory.

    -K or--kilobytes: equivalent –block-size=1k, which displays the unit size of the K-byte file.

    -L: Displays the file or directory information in a detailed format, in addition to the file name, and displays the size, permissions, ownership, and CTime of the files.

    -M: Use "," to separate the files and directories used.

    -O: Equivalent to-g

    -N or--numeric-uid-gid replaces its name with a user ID and a group identifier.

    -N or--literal directly lists file and directory names, including control characters.

    -R or--reverse reverse sort.

    -R or--recursive recursive processing to display all files and subdirectories in the specified directory.

    -S or--size displays the size of the file and directory, in chunks.

    -S is sorted by file and directory size.

    -T is sorted with file and directory change times.

    -U sorts the last access time to display files and directories.

    -u lists file and directory names without sorting.

    --block-size=< Chunk Size > Specifies the chunk size to hold the file.

    --full-time lists the full date and time.

    --help online Help.

    --version Displays version information.

  3. Command instance:

    Example 1: List the details of all files and subdirectories in the/root directory.

    Command:

Ls-la/root

Command output:

[[Email protected] ~]# ls -la /roottotal 116dr-xr-x---.   7 root  root  4096 Jun 29 02:38 .dr-xr-xr-x. 25 root root  &NBSP;4096&NBSP;JUN&NBSP;29&NBSP;18:03&NBSP, .... -RW-------.   1 root root  1234 Jun 23 22:02  anaconda-ks.cfgdrwxr-xr-x.  2 root root  4096 jun 29 02:33  BACKUP-RW-------.   1 root root  2736 jun 29 02:10 .bash_ History-rw-r--r--.   1 root root    18 may 20  2009  .bash_logout-rw-r--r--.   1 root root   176 May 20   2009 .bash_profile-rw-r--r--.   1 root root   176 Sep  23  2004 .bashrc-rw-r--r--.   1 root root   100 sep 23  2004 .cshrcdrwxr-xr-x.  3 root root  4096 jun  29 02:27 datadrwxr-xr-x.  3 root root  4096 jun 23  23:01 .emacs.d-rw-r--r--.   1 root root    14 jun 29  00:29 ett.txt-rw-r--r--.   1 root root 34961 jun 23 22:02  install.log-rw-r--r--.   1 root root  7346 jun 23 21:59 &NBSP;INSTALL.LOG.SYSLOG-RW-------.   1 root root    48 Jun  28 23:47 .lesshstdrwxr-xr-x.  8 root root  4096 jun 29  02:38 mkdirtest-rw-r--r--.   1 root root    18 jun 28  08:16 oldboy.txt-rw-r--r--.   1 root root   129 Dec   4  2004 .tcsHrcdrwxrwxrwx.  2 root root  4096 jun 29 02:30 test[[email  protected] ~]#

Example 2: List all problems in the/root directory and sort by last modified time

Command:

Ls-lt/root

Command output:

[[email protected] ~]# ls -lt /roottotal 76drwxr-xr-x. 8 root  root  4096 jun 29 02:38 mkdirtestdrwxr-xr-x. 2 root root   4096 Jun 29 02:33 backupdrwxrwxrwx. 2 root root  4096  jun 29 02:30 testdrwxr-xr-x. 3 root root  4096 jun 29  02:27 data-rw-r--r--.  1 root root    14 jun 29 00:29  ett.txt-rw-r--r--.  1 root root    18 jun 28 08:16 &NBSP;OLDBOY.TXT-RW-------.  1 root root  1234 Jun 23 22:02  Anaconda-ks.cfg-rw-r--r--.  1 root root 34961 Jun 23 22:02  Install.log-rw-r--r--.  1 root root  7346 Jun 23 21:59  install.log.syslog[[email protected] ~]#

instance, continue adding in the post-build environment

One Linux command per day-ls

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.