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

CentOS learning notes from the heart part VI: directory operation commands cd, pwd

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Absolute path and relative path

Absolute path: the file name or directory name written from the root directory (/), for example, / home/fromheart/.bashrc

Relative path: the file name relative to the current path. For example,. / home/formheart or.. /.. / home/fromheart/, etc., anyway, it is not / belongs to the relative path at the beginning.

II. Special catalogue

. Represents this layer directory

.. Represents the previous level of directory

-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 (account is an account name)

Under Linux, is there an upper directory (..) under the root directory?

If you use "ls-al /" to query, you can see that the root directory does exist. With; with. Two directories, the attributes and permissions of these two directories are exactly the same, which means that the upper level (..) of the root directory is the same directory as the root directory itself.

Note: for executable files whose file location is not "regular" (/ bin, / usr/bin, etc.), when you want to execute these programs, you need to strictly specify the executable file. If you need to run the install.sh of the current user's home directory, you need to enter. / install.sh when entering the execution command.

Directory operation command

Pwd: displays the current directory

Cd: changing directories

Mkdir: create a new directory

Rmdir: delete an empty directory

1.pwd (Print Working Directory, showing the current directory)

Format pwd [- P]

Options and parameters:

-P: shows the exact path instead of using the link path.

Pwd

Cd / bin

Pwd

Pwd-P

2. Cd (change directory, change directory)

Cd.

Cd..

Cd ~

Cd-

Cd ~ fromheart

3. Mkdir (make directory creates a new directory)

Format: mkdir [- mp] directory name

Options and parameters:

-m: set the permissions of the file! Set the permissions of the established directory directly instead of using the default permissions (umask).

-p: helps the user to create the desired directory (including the upper directory) recursively.

Mkdir 1 2

Mkdir 3/4

(command execution is not successful, substitute-p parameter is required)

Mkdir-p 3amp 4

Ls-alr 3

Ls-al

Note: when a directory name contains spaces, you need to reference the directory name in quotation marks

Mkdir "Program Files". If you type mkdir Program Files directly, the system will directly create two directories, Program and Files.

Umask command: displaying or setting default permissions

Umask

The result shows that the default permission is 0002, and the user can use 777to subtract the last three digits, and the result is 775, even if the permission is rwxrwxr_x. This is the default permission to create directories (files). Users can set permissions when creating a directory through mkdir-m

Mkdir-m 711 5

Ls-al

4. Rmdir (delete the "empty" directory)

Format: rmdir [- p] directory name

Options and parameters:

-p: delete along with the "upper layer" and "empty" directory

Rmdir 1 2 (also delete empty directory 1 2)

Rmdir 3 (deletion failed because directory 3 and directory 4 are not empty)

Rmdir-p 3amp 4 (delete directory 4, along with its last directory 3)

When the directory is not empty, the user can use the rm-r command to delete the directory along with the files and subdirectories under the directory

Rm-r 3

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