The LS command can be said to be the most commonly used command under Linux.
-A lists all files under the directory, including the. The implied file at the beginning.
-B lists the characters that are not output in the file name in the form of a backslash and a character number (as in the C language).
-C The modified time of the I node of the output file and sorted by this.
-D Displays the directory as if it were a file, rather than displaying the file below it.
-e outputs the full information of the time, not the output of the brief information.
-f-u the output file is not sorted.
-G useless.
-I index information for the I node of the output file.
-K represents the size of a file in the form of a byte.
-l lists the file details.
-m output file name horizontally and "," as a separator.
-N replaces the name with the uid,gid of the number.
-O Displays detailed information about the file in addition to the group information.
-p-f a character appended to each file name to indicate the type of the file, "*" indicates an executable normal
file; "/" means directory; "@" means symbolic link; "|" Represents a fifos; "=" represents a set of
Socket (sockets).
-Q replaces non-output characters.
-R sorts the directory backwards.
-S prints the size of the file after each file name.
-T is sorted by time.
-U sorts the time the file was last accessed.
-X output by column, sorted horizontally.
-a displays except for "." and ".." All files outside the file.
-B does not output backup files ending with "~".
-C output By column, sorted vertically.
-G output file for the group information.
-l lists the link file name instead of the file that is linked to.
-N does not limit file length.
-Q Enclose the file name of the output in double quotation marks.
-r lists all the files under subdirectories.
-S is sorted by file size.
-X sorts with the file's extension (the last character after the.).
-11 lines output only one file.
--color=no do not display color file names
The--HELP displays help information on the standard output.
The--version outputs the version information on the standard output and exits.
List subdirectories only
1. Ls-f | grep/$ or alias sub = "Ls-f | grep/$ "(Linux)
2. Ls-l | grep "^d" or Ls-ll | grep "^d" (Solaris)
Calculate the number of files and directories in the current directory
The following command can calculate the number of files and directories in the current directory, respectively:
# ls-l * |grep "^-" |wc-l----to count files
# ls-l * |grep "^d" |wc-l-----to Count dir
Display a list of color catalogs
Open/ETC/BASHRC and add the following line:
Alias ls= "LS--color"
The next time you start bash, you'll be able to display a list of colored catalogs as you would in Slackware, where the meanings of colors are as follows:
1. Blue---Directory
2. Green---executable file
3. Red--Compress files
4. Light blue--linked files
5. Gray--Other files
LS-TL--time-style=full-iso sshd
Ls-ctl--time-style=long-iso
The LS command means that the list displays the name of the file in the current directory. Note that it displays the names of all files and directories except hidden files, without parameters.
1) ls–a displays all files in the current directory, including hidden files
]# Ls–a
. . gnome2. Nautilus
.. . gnome2_private oracle_rpm
. bash_profile. Gtkrc-1.2-gnome2 Tnsnames.ora
. bashrc. Iceauthority Types.h
Note that hidden files are in the file name with "." The file that begins with the (English period).
2) ls–l display the file and its details.
]# ls–l
Total 5
-rw-r--r--1 root root 1668 Oct 3-anaconda-ks.cfg
Drwxr-xr-x 2 root root 4096 Nov 6 00:04 AA
What does the file details display represent? Take the blue section above as an example.
Total 5 Represents the sum of the file sizes in the current directory as 5K (the size of each directory is calculated as 4K)
Drwxr-xr-x the first character has 3 cases: "-" for ordinary files, "D" for the Directory, "L" for the connection file, "B" represents the device file.
Each of the following 9 characters is a group of 3, each representing the file owner, the user group where the file owner resides, and other users ' permissions to the file. The 3 characters in each group represent read, write, and execute permissions, which are represented by "-" if none of the permissions are available. The permission to execute has two characters optional "x" for executable, "s" for the socket interface file.
The following number 2 represents the number of directory files in the directory "AA" (This number = number of hidden directories + normal directory). We enter the "AA" directory with the command Ls–al (in order to see the hidden file we add-a parameter)
]# Ls-al
Total 8
Drwxr-xr-x 2 root root 4096 Nov 6 00:04.
Drwxr-x---root root 4096 Nov 6 00:04.
(2 in the 3rd row above means that there are 2 subdirectories in the current directory, that is,.)
In line 4th above, 14 represents 14 subdirectories in the previous level of the directory. )
The next root represents the owner of the file (directory) as the user root.
The next root represents the group root of the user group to which the file (directory) belongs.
4096 represents the size of the file (in bytes), and the directory size is always 4096 bytes.
Nov 6 00:04 represents the modified time for a file (directory).
AA represents the file (directory) in the name.
3) Meaning of the file name color
The default color represents normal files. Example: Install.log
Green represents the executable file. Example: Rc.news
Red represents the Tar package file. Example: vim-7.1.tar.bz2
Blue represents the catalog file. Example: AA
Shuihong represents an image file. Example: sunset.jpg
Cyan represents the linked file. Example: rc4.d (this type of file is equivalent to a shortcut)
Yellow represents the device file. Example: fd0
4) A few more commonly used parameters.
-T sorts by last modified time.
-S sorts by file size. (s in uppercase)
-R sort when in reverse order.
-H increase readability when displaying file size (example: 1K 234M 2G)
One command per day LS 2015/4/1