Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common directory processing commands in CentOS

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what the common CentOS directory commands are, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Relative path and absolute path

Absolute path: the path must be written from the root directory /, for example, / usr/share/doc.

Relative path: the path is not written from /, for example, from / usr/share/doc to / usr/share/man, it can be written as "cd.. / man". This is how the relative path is written. The relative path is always relative to the current working path.

For the correctness of the file name, the correctness of the absolute path is better. When writing a program (shell scripts) to manage the system, be sure to use the absolute path. If you use relative paths in the program, some problems may occur due to the different working environment in which you execute.

Operations related to the directory

Several common commands for dealing with directories:

* cd: switch directories

* pwd: displays the current directory

* mkdir: create a new directory

* rmdir: delete an empty directory

Cd (switch directories, Change Directory)

. represents this layer directory

... represents the upper catalog.

-represents the previous working directory

~ represents the home folder where the current user identity is located

~ account represents the home folder of the user account

Pwd (show current directory, Print Working Directory)

-p displays the current path instead of using the connection path

When we use this command, we can add the parameter-p, which allows us to get the correct directory name instead of showing it as the path to the connection file.

Mkdir (create a new directory, make directory)

-m to force a new directory-related permission example: mkdir-m 711 test

-p helps you directly create the desired directories (including high-level directories) recursively. Example: mkdir test1/test2

Rmdir (delete "empty" directory, remove directory)

-p along with the upper empty directory is also deleted

-r delete together with all files in the directory example: rm-r test

Variable about the path to the execution file: $PATH

Why can I execute the / bin/ls command anywhere? Why do I type ls in any directory and I must be able to display some information without saying I can't find the / bin/ls command? This is due to the help of the environment variable PATH.

When we execute a command, for example, "ls", the system will query the executable file named ls in the directory defined by each PATH according to the settings of PATH. If the directory defined by PATH contains multiple executable files named ls, then the command with the same name will be executed first.

Execute the "echo $PATH" command ($followed by a variable) to display all configured PATH directories. "PATH=" $PATH ": / root", add the / root directory to the PATH variable

The above is all the contents of the article "what are the common directory commands in CentOS?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report