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

Use the cd command of linux to change directories

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

Share

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

This article mainly introduces the use of linux cd command to switch directories, the article is very detailed, has a certain reference value, interested friends must read it!

The cd command is the acronym of the word "change directory", and its English definition is to change the directory, so the function of the command is to change from the current directory to the specified directory.

The path of the directory can be divided into absolute path and relative path. If the directory name is omitted, change to the user's user directory (that is, the directory where you first logged in).

In addition, "~" also means user directory. "." Indicates the directory in which it is currently located, ".." Represents the directory one level above the current directory location.

Syntax format: cd [parameters] [directory name]

Common parameters:

-P if the target directory is a symbolic link, then switch directly to the target directory that the symbolic link points to.-L if the target directory is a symbolic link, then switch directly to the directory where the symbolic link name is located. If only the "-" option is used, the current directory will be switched to the directory corresponding to the environment variable "OLDPWD". Switch to a directory one level above the current directory location

Reference example

Change the current working directory to the dir directory and use the pwd command to view the current directory:

[root@linuxcool ~] # cd dir

[root@linuxcool dir] # pwd

/ root/dir

Use the "cd ~" and "cd.." commands to switch directories, and use the pwd command to view the current directory:

Note: use the "cd ~" command to switch directly to the current user directory, while "cd.." is to switch to the previous directory.

[root@linuxcool dir] # pwd

/ root/dir

[root@linuxcool dir] # cd ~

[root@linuxcool ~] # pwd

/ root [root@linuxcool dir] # pwd

/ root/dir

[root@linuxcool dir] # cd..

[root@linuxcool dir] # pwd

/ root

Use "cd.. /.." The command returns to the upper two-level directory:

[root@linuxcool dir_2] # pwd

/ root/dir/dir_1/dir_2

[root@linuxcool dir_2] # cd.. /..

[root@linuxcool dir] # pwd

/ root/dir

Use the "cd" command to return to the current user directory. The "cd--" command returns the last directory:

[root@linuxcool dir_2] # pwd

/ root/dir/dir_1/dir_2

[root@linuxcool dir_2] # cd

[root@linuxcool ~] # pwd

/ root

[root@linuxcool ~] # cd-

/ root/dir/dir_1/dir_2

[root@linuxcool dir_2] # pwd

/ root/dir/dir_1/dir_2 above is to use the cd command of linux to change all the contents of the directory, thank you for reading! Hope to share the content to help you, more related 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