In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you what are the commands listed in the directory content under Linux, I believe most people still do not know how to share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
ls
The most common command to list the contents of a directory in Linux is the ls command. By default, ls displays all non-hidden content in a directory. Files and directories will be displayed in different colors in the display results, depending on the color theme of the terminal.
The ls command lists the contents of the current directory. If you want to view the contents of other directories, you can specify the specific path in the command:
$ ls /other/directory/path
If you want to see hidden content in the directory, you can add the-a option:
$ ls -a
You can also use the-l option to list the contents of the current directory, in which case the file size listed will be displayed in bytes, which is very inconvenient to read. We can add the-h option to display file sizes in human-readable format, such as k, M, G, etc.
Of course, for convenience, you can simply combine the two options into one.
$ ls -lh
dir
The ls command is familiar to everyone and is used very frequently. The dir command is similar to ls in that it lists the contents of a directory. If the file names listed contain special characters, such as spaces, they will be preceded by a backslash\.
dir is similar to ls in that the command arguments in ls are also available in dir.
In fact, dir is equivalent to this command:
$ ls -C -b
Of which:
-C : Display content as columns
-b : add backslash before special character\
vdir
The vdir command displays the contents of the directory as a long list, and special characters are also preceded by a backslash\. A long list shows permission information for the file or directory, number of connections, owner, group owner, file size, last modified time, and name.
The vdir command has the same effect as the ls command:
$ ls -l -b
Of which:
-l : Display the contents of a directory as a list
-b : preceded by a backslash\
The meaning of dir and vdir
See here, everyone will definitely have a question, since the ls command can achieve all the functions of dir and vdir, then what is the point of these two existence?
Shell commands are often part of scripts whose output is sometimes displayed on the terminal, sometimes redirected to a file, or sometimes simply piped to other commands.
However, in some cases, the ls command may not produce the desired results due to performance issues with script execution. So Linux developers have developed these two commands so that you don't run into that kind of performance problem.
Some other knowledge
When we use ls to view directory contents, different types of files will appear in different colors, whereas dir and vdir will have the same color for everything. This is because by default ls is actually an alias for ls --color=auto, so color is assigned to the output content.
If you also want the output to be colored by type when using dir and vdir, you can use:
$ dir --color$ vdir --color
The above is "What are the commands to list directory contents under Linux" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
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.