In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "the combined use of ls and dir commands in the Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Ls or dir command: lists the contents of the current directory
The ls (abbreviation for list) command lists the contents of the current directory. The dir command is an alias for the ls command and an abbreviation for directory. Usually listed files are displayed in different colors, and different colors represent different file types. The following table lists the corresponding relationship between file types and colors.
Ls also identifies certain types of files with symbols, and the following table lists commonly used identifiers and their descriptions.
The format of the ls command is as follows:
Ls [options] directory or file name
The meaning of each option is as follows.
-a: lists the information (including implicit files) of all files and subdirectories under the specified directory.
-A: same as-a, but not listed. And...
-b: when there is an undisplayable character in the file name, the octal number of that character is displayed.
-c: sort by the last modification time of the file.
-C: display in multiple columns.
-d: displays the directory name instead of the contents of the directory, usually used with-l.
-f: add a symbol to the listed file name to distinguish between different types.
-R: recursively displays files in all levels of subdirectories of the specified directory.
-s: gives the number of blocks used for each directory item, including indirect blocks.
-t: sort by the last modification time (the new one comes first and the old one comes later).
-l: displays the details of the file in a long format, including file type and permissions, number of links, file owner, group to which the file owner belongs, file size, last modified time and file name, as shown in figure 6.4.
The contents of the directory are displayed in different formats:
The code is as follows:
# ls / / display the contents of the directory in thumbnail format
Cal_txt finger_txt id_txt newgrp_txt
Suple_txt who.txt
Finger2_txt groups_txt last_txt suple3_txt
Suple_txt~ w.txt
Finger3_txt groups_txt2 ln suple3_txt~ w
The code is as follows:
# ls-l / / displays directory contents in a long format, including permissions,
User name, modification time, etc.
Total 224
-rw-r--r-- 1 root root 2163 07-24 13:00 cal_txt
-rw-r--r-- 1 root root 212 07-23 06:37 finger2_txt
-rw-r--r-- 1 root root 0 07-23 06:39 finger3_txt
-rw-r--r-- 1 root root 24807-23 06:31 finger_txt
-rw-r--r-- 1 root root 35 07-23 04:22 groups_txt
-rw-r--r-- 1 root bin 140 07-23 04:32 groups_txt2
-rw-r--r-- 1 root root 14407-23 04:11 id_txt
-rw-r--r-- 1 root root 1655 07-22 19:19 last_txt
Drwxr-xr-x 5 root root 4096 07-26 09:42 ln
-rw-r--r-- 1 root bin 14307-23 04:24 newgrp_txt
-rw-r--r-- 1 root root 25098 07-26 19:15 suple3_txt
-rw-r--r-- 1 root root 24031 07-26 16:00 suple3_txt~
-rw-r--r-- 1 root root 25198 07-24 20:16 suple_txt
-rw-r--r-- 1 root root 24827 07-24 20:06 suple_txt~
-rw-r--r-- 2 root root 19607-23 06:48 w
-rw-r--r-- 1 root root 46 07-23 06:48 who.txt
-rw-r--r-- 2 root root 19607-23 06:48 w.txt
The code is as follows:
# ls-s / / displays the number of blocks used
Total 224
8 cal_txt 8 groups_txt 8 ln
32 suple_txt 8 w.txt
8 finger2_txt 8 groups_txt2 8 newgrp_txt
32 suple_txt~
4 finger3_txt 8 id_txt 32 suple3_txt 8 w
8 finger_txt 8 last_txt 28 suple3_txt~ 8 who.txt
Options can be combined. For example, if you need to list all the contents of the current directory (including those with "." At the beginning of the implied file), and output the details of the file on the screen in "redundant format", using the option "- al". To display all files in the / root directory in redundant format, you can use the command:
The code is as follows:
# ls-al / root
Drwxr-x--- 18 root root 4096 07-26 16:00.
/ / current directory
Drwxr-xr-x 24 root root 4096 07-25 05:43..
/ / parent directory
-rw- 1 root root 997 07-15 20:58
Anaconda-ks.cfg / / ordinary file
-rw- 1 root root 2827 07-24 21:32
.bash _ history / / hide the file
-rw-r--r-- 1 root root 24 2006-07-13
.bash _ logout / / hide the file
... ...
Where the file is called "." Represents the current directory, and the corresponding row gives the details of the current directory. The file is called ".." Indicates that the parent directory is one level above the current directory, and the corresponding row lists the details of the parent directory. The file name is preceded by "." The file of the symbol is a hidden file and will be displayed only if the "- a" parameter is used.
Use the 'ls' and' dir' commands to determine the file type
Another way to determine the file type is to display a long list of results with the ls and dir commands.
Use ls-l to determine the type of a file.
When you view file permissions, the first character shows the file type, and the other characters show file permissions.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $ls-l
Total 6908
Drwxr-xr-x 2 tecmint tecmint 4096 Sep 9 11:46 BACKUP
-rw-r--r-- 1 tecmint tecmint 1075620 Sep 9 11:47 crossroads-stable.tar.gz
-rwxr- 1 tecmint tecmint 5916085 Sep 9 11:49 EDWARD-MAYA-2011-2012-NEW-REMIX.mp3
-rw-r--r-- 1 tecmint tecmint 42122 Sep 9 11:49 Linux-Security-Optimization-Book.gif
-rw-r--r-- 1 tecmint tecmint 17627 Sep 9 11:46 master.zip
-rw-r--r-- 1 tecmint tecmint 5 Sep 9 11:48 num.txt
-rw-r--r-- 1 tecmint tecmint 0 Sep 9 11:46 reggea.xspf
-rw-r--r-- 1 tecmint tecmint 5 Sep 9 11:47 tmp-link
Use ls-l to determine block and character files
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $ls-l / dev/sda1
Brw-rw---- 1 root disk 8, 1 Sep 9 10:53 / dev/sda1
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $ls-l / dev/tty1
Crw-rw---- 1 root tty 4, 1 Sep 9 10:54 / dev/tty1
Use dir-l to determine the type of a file.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $dir-l
Total 6908
Drwxr-xr-x 2 tecmint tecmint 4096 Sep 9 11:46 BACKUP
-rw-r--r-- 1 tecmint tecmint 1075620 Sep 9 11:47 crossroads-stable.tar.gz
-rwxr- 1 tecmint tecmint 5916085 Sep 9 11:49 EDWARD-MAYA-2011-2012-NEW-REMIX.mp3
-rw-r--r-- 1 tecmint tecmint 42122 Sep 9 11:49 Linux-Security-Optimization-Book.gif
-rw-r--r-- 1 tecmint tecmint 17627 Sep 9 11:46 master.zip
-rw-r--r-- 1 tecmint tecmint 5 Sep 9 11:48 num.txt
-rw-r--r-- 1 tecmint tecmint 0 Sep 9 11:46 reggea.xspf
-rw-r--r-- 1 tecmint tecmint 5 Sep 9 11:47 tmp-link
This is the end of the content of "the combined use of ls and dir commands in the Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.