One day a linux Base command Directory Management class command ls

Source: Internet
Author: User
Tags file type file parent directory

LS lists directory contents

1. command format

ls [option] [ directory name ]

2. Command function

Show current directory contents,iflsspecify a different directory,then the files and directories in the specified directory will be displayed.  throughlscommands can not only viewLinuxfiles that the folder contains,and you can view file permissions(include directory, folder, file permissions),View directory information and more.

3. Common Parameters

-A, all files in the print directory include hidden files, but not included . and ..

-A: Displays all files in the directory, including hidden files

. represents the current directory

.. represents the parent directory

-L: Print files and directories in the directory in long format (file type, permissions, number of hard links, owner, group, size, time)

-I: usually with -L, print out the inode number during printing

-R: Recursive printing

-F: When the directory is displayed , thefile does not change after adding/

-D: Displays the directory itself, usually in conjunction with- l

-H: File size is displayed in read format , KB,MB,GB

--color={auto;never:always}: Adds a color display to the display when the content is displayed

Auto: auto-display color;never: never display color;always: Color appears all the time

General use Auto, from the dynamic display color

-K: show file Size in K bytes

-T: sorted by file modification time, ascending

Help Display this help message and leave

–version display version information and leave

When using the LS command, pay attention to the format of the command: At the command prompt, the first is the command keyword, followed by the command parameters, before the command parameters to have a short line "-", all the command parameters have a specific role, you can choose one or more parameters according to the need, After the command argument is the action object of the command.

Command: Ls-l-i/root

"LS" is the command keyword, "-l-i" is a parameter, "/root" is the operand of the command. In this command, two parameters are used, respectively "L" and "I", and of course, you can also put them together, as shown below:

Command : Ls-li/root

The result of this form is exactly the same as the command form above.

4. Common examples

Example 1 : Lists the contents of the current directory

command:ls

ls The file and directory under the current directory are listed without any arguments after the command

[Email protected] ~]# lsanaconda-ks.cfg cplogs.sh Documents install.log Music public tmpautouserdel.sh Desktop Downloads install.log.syslog Pictures Templates videos[[email protected] ~]#

Example 2 : Lists all files in the current directory

command:ls-a

[Email protected] ~]# ls-a. Bash_history cplogs.sh Downloads. Gnote.               iceauthority. Local pulse tmp. . bash_logout. CSHRC ...

Example 3: List files under /var

command:ls/var

[[email protected] ~]# Ls/varaccount cache crash cvs db empty games GDM Lib local lock log mail NIS opt preserv E run spool tmp www YP

Example 4: Listing/var in a detailed format under the file

command: ls-l/var

[[Email protected] ~]# l -l /vartotal 80drwxr-xr-x. 2 root root  4096 apr 28  2016accountdrwxr-xr-x. 15 root root 4096 apr  28  2016 cachedrwxr-xr-x. 2 root root 4096 Nov 23   2013crashdrwxr-xr-x. 2 root root 4096 Nov 22  2013  Cvsdrwxr-xr-x. 3 root root 4096 apr 28  2016 dbdrwxr-xr-x. 3  root root 4096 apr 28  2016emptydrwxr-xr-x. 2 root root  4096 sep 23  2011gamesdrwxrwx--t. 2 root gdm  4096 nov  22  2013 gdmdrwxr-xr-x. 38 root root 4096 Apr 28   2016 libdrwxr-xr-x. 2 root root 4096 Sep 23   2011localdrwxrwxr-x. 5 root lock&nBsp;4096 dec  4 12:06 lockdrwxr-xr-x. 13 root root 4096 dec   6 21:19 loglrwxrwxrwx. 1 root root   10 apr 28   2016 mail -> spool/maildrwxr-xr-x. 2 root root 4096 sep  23  2011 nisdrwxr-xr-x. 2 root root 4096 Sep 23   2011 optdrwxr-xr-x. 2 root root 4096 sep 23   2011preservedrwxr-xr-x. 29 root root 4096 dec  6 21:20  RUNDRWXR-XR-X. 13 ROOT ROOT 4096 APR 28  2016 SPOOLDRWXRWXRWT.  2 root root 4096 dec  1 20:51 tmpdrwxr-xr-x. 6 root  root 4096 apr 28  2016 wwwdrwxr-xr-x. 3 root root 4096  apr 28  2016 yp

Example 5: Listing the files and inode numbers under/ var in adetailed format

ls-i-l/root or ls-li/root

[[Email protected] ~]# ll -i /vartotal 802229431 drwxr-xr-x.  2  root root 4096 apr 28  2016 account2228228 drwxr-xr-x. 15  root root 4096 apr28  2016 cache2229519 drwxr-xr-x.  2  root root 4096 Nov 23  2013 crash2229419 drwxr-xr-x.   2 root root 4096 nov 22  2013 cvs2229374 drwxr-xr-x.  3  root root 4096 apr 28  2016 db2229375 drwxr-xr-x.  3  root root 4096 Apr 28  2016 empty2229376 drwxr-xr-x.   2 root root 4096 sep 23  2011 games2229540 drwxrwx--t.   2 root gdm 4096 nov 22  2013 gdm2228226 drwxr-xr-x. 38  root root 4096 apr28  2016 lib2229379 drwxr-xr-x.  2 root root 4096  Sep 23  2011 local2229380 drwxrwxr-x.  5 root lock  4096 dec  4 12:06 lock2229373 drwxr-xr-x. 13 root root  4096dec  6 21:19 log2229382 lrwxrwxrwx.  1 root root    10 apr 28 2016 mail -> spool/mail2229383 drwxr-xr-x.  2  root root 4096 sep 23  2011 nis2229384 drwxr-xr-x.  2  root root 4096 sep 23  2011 opt2229385 drwxr-xr-x.  2  root root 4096 sep 23  2011 preserve2229386 drwxr-xr-x. 29  root root 4096dec  6 21:20 run2229387 drwxr-xr-x. 13 root  root 4096 apR28  2016 spool2228251 drwxrwxrwt.  2 root root 4096 dec   1 20:51 tmp2229576 drwxr-xr-x.  6 root root 4096 apr  28  2016 www2229390 drwxr-xr-x.  3 root root 4096 apr  28  2016 yp

Extended:

file types for Linux

-: Normal file (f)

D: Catalog file

B: Block device files (blocks )

C: Character device file (character)

L: Symbolic Link files (symblic link file)

P: Named pipe file (pipe)

S: Socket file (socket)

Linux file timestamp (timestamp):

access time: Last visited ( read ) access

modified: Write Data Modify Change the contents of the file

Change the time: Change meta data ( attributes of the file ) change,metadata, metadata changes the properties of the file

Ls

-li: Long format

2229576 l rwxrwxrwx.  1 root root 4096 Jan 09:31 RVi-VI inode Number file type file permissions hard-link count is the primary (owner) group size Last modified time file name original file



This article is from "Linux rookie" blog, please be sure to keep this source http://geekb0y.blog.51cto.com/10743719/1880179

One day a linux Base command Directory Management class 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.