Linux Common Command ls

Source: Internet
Author: User
Tags aliases

Linux common command LS New Linux operations, common commands

      • ls command
        • Grammar
        • Options
        • Parameters
        • Instance

ls command

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(选项)(参数)

Options
  • -A: Displays all files and directories (ls default file name or directory name is ".") As a shadow, not listed);
  • -C: Multi-column display output results. This is the default option;
  • -L: In contrast to the "-C" option, all output information is output in a single-column format and not output as multiple columns;
  • -F: Append the type identifier of the file after each output item, meaning: "*" means a normal file with executable permissions, "/" for the Directory, "@" for the symbolic Link, "|" Represents a command pipeline FIFO, and "=" represents a sockets socket. When the file is a normal file, do not output any identifiers;
  • -B: Outputs the non-output characters in the file with the backslash "" and the character encoding;
  • -C: When in use with the "-lt" option, the output directory capacity is sorted according to the file status time, sorted by the CTime field in the index node of the file. When in conjunction with the "-l" option, the ordered sentence is the time of the file's state change;
  • -D: Displays only the directory name, not the list of contents under the directory. Displays the symbolic link file itself without displaying the list of directories it points to;
  • -I: Displays the file index node number (inode). An index node represents a file;
  • -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;
  • -R: Recursive processing, all files and subdirectories under the specified directory are processed together;
  • --full-time: Lists the full date and time;
  • --color[=when]: Use different colors to highlight different types of.
Parameters

Files or directories that can be specified, or files or directories if not added

Instance

1. Long format display file list, display the file details

[[email protected] etc]# ls -l |tail -1rwxr-xr-x.  2 root root   4096 Jul  3 11:14 yum.repos.d
    1. Displaying inode information for a file
[[email protected] etc]# ls -i -l yp.conf yum.conf 92590 -rw-r--r--. 1 root root 585 Oct 10  2012 yp.conf92070 -rw-r--r--. 1 root root 813 Jan  9  2013 yum.conf
    1. Horizontal Output File List
[[email protected] etc]# LS-MABRT, ACPI, Adjtime, aliases, aliases.db, ALSA, alternatives, Ana Crontab, asound.conf, At.deny, Audisp, audit,autofs_ldap_auth.conf, Auto.master, Auto.misc, Auto.net, AUTO.SMB, Bash_ COMPLETION.D, BASHRC, ~.BASHRC, Blkid, Cas.conf,certmonger, cgconfig.conf, cgrules.conf, cgsnapshot_blacklist.conf, CHKCONFIG.D, Consolekit, CRON.D, cron.daily, cron.deny,cron.hourly, cron.monthly, Crontab, cron.weekly, Crypttab, CSH.CSHRC, Csh.login, cups, dbus-1, default, Depmod.d, Dhcp,dir_colors, Dir_colors.256color, Dir_colors.lightbgcolor, Dracut.conf, DRACUT.CONF.D, DRIRC, elinks.conf, Environment, ethers 
    1. The most recently modified file is above
[[email protected] etc]# ls -tprelink.cache      cron.daily      rc4.d           ssl                        yp.conf                       anacrontabsysconfig          audit           rc5.d           crypttab                   csh.cshrc                     cron.denyhosts
    1. Show Recursive files:
[[email protected] etc]# ls -R |tail -2./yum.repos.d:rhel-source.repo

6. Print the UID and GID of the file or directory:

[[email protected] etc]# ls -n |tail -2-rw-r--r--.  1 0 0    813 Jan  9  2013 yum.confdrwxr-xr-x.  2 0 0   4096 Jul  3 11:14 yum.repos.d
    1. File and folder details
[[email protected] etc]# ls -lh |tail -3drwxr-xr-x.  5 root root 4.0K May  2 04:30 yum-rw-r--r--.  1 root root  813 Jan  9  2013 yum.confdrwxr-xr-x.  2 root root 4.0K Jul  3 11:14 yum.repos.d
    1. Display directory information
[[email protected] etc]# ls -ld yumdrwxr-xr-x. 5 root root 4096 May  2 04:30 yum

9. To list the details of a file or folder by modified time:

[[email protected] etc]# ls -ltr |head -5total 1748-rw-r--r--.  1 root root  10814 Feb 21  2006 ltrace.conf-rw-r--r--.  1 root root    662 Aug 29  2007 logrotate.conf-rw-r--r--.  1 root root    220 Oct 14  2008 quotagrpadmins-rw-r--r--.  1 root root    148 May 15  2009 asound.conf
    1. To classify by special characters:
[[email protected] etc]# ls -Fabrt/                      dracut.conf.d/    ld.so.conf       plymouth/                     selinux/acpi/                      drirc             ld.so.conf.d/    pm/                           servicesadjtime                    elinks.conf       libaudit.conf    pm-utils-hd-apm-restore.conf  sestatus.conf
    1. List files and mark
[[email protected] etc]# ls -ld yum.repos.d/ --color=autodrwxr-xr-x. 2 root root 4096 Jul  3 11:14 yum.repos.d/

Linux Common Command ls

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.