How to use linux cd command?

青灯夜游
Release: 2020-11-02 17:19:49
Original
13737 people have browsed it

linux cd command is used to switch the current working directory, the syntax format is "cd [dirName]", where the dirName representation can be an absolute path or a relative path; if the directory name is omitted, it changes to the user's home directory , that is, the directory where you were when you first logged in.

How to use linux cd command?

Related recommendations: "Linux Video Tutorial"

Linux cd command is used to switch the current working directory to dirName( directory parameters).

The dirName representation can be an absolute path or a relative path. If the directory name is omitted, it will change to the user's home directory (that is, the directory where the user just logged in).

In addition, "~" also means the home directory, "." means the current directory, and ".." means the directory above the current directory.

1. Linux cd command syntax

cd [dirName]
Copy after login

dirName: The target directory to be switched.

2. Linux cd command example

Jump into the test directory:

[root@/root/linuxdaxue.com]#cd testDir/
[root@/root/linuxdaxue.com/testDir]#ls
file1  file2  file3
Copy after login

Jump to the upper directory

[root@/root/linuxdaxue.com/testDir]#cd ..
[root@/root/linuxdaxue.com]#ls
testDir
Copy after login

Jump to the upper directory

[root@/root/linuxdaxue.com/testDir]#cd ../../
[root@/root]#ls
Copy after login

Jump to the user home directory

[root@/root/linuxdaxue.com/testDir]#ls
file1  file2  file3
[root@/root/linuxdaxue.com/testDir]#cd ~/
[root@/root]#pwd
/root
Copy after login

Use absolute path

[root@/root]#cd /root/linuxdaxue.com/testDir
[root@/root/linuxdaxue.com/testDir]#ls
file1  file2  file3
Copy after login

Use environment variables

[root@/root]#cd $TEST_PATH
[root@/root/linuxdaxue.com/testDir]#ls
file1  file2  file3
Copy after login

Jump to the last time Using the directory

[root@/root]#pwd
/root
[root@/root]#cd -
/root/linuxdaxue.com/testDir
[root@/root/linuxdaxue.com/testDir]#
Copy after login

cd command is relatively simple. It is mainly used to switch working directories. I hope everyone can master it.

For more programming-related knowledge, please visit: Introduction to Programming! !

The above is the detailed content of How to use linux cd command?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template