If you need to frequently use the Linuxcd command to jump to multiple subdirectories under a specific parent directory, you can consider setting the CDPATH environment variable to this parent directory. For example, frequent operations
If you need to frequently use the Linux cd command to jump to multiple subdirectories under a specific parent directory, you can consider setting the CDPATH environment variable to this parent directory.
For example, when several sub-directories under the/etc directory are frequently operated, we set CDPATH to/etc, you do not need to add the/etc prefix each time you go to the/etc subdirectory.
Code:# Pwd
/Home/topsage # cd ssh-bash: cd: ssh: No such file or direcotry
Code: # export CDPATH =/etc
# Cd ssh
At this time, the cd ssh command will find the ssh subdirectory in the basic directory/etc:
Code: # pwd
/Etc/ssh
If you want to change the basic directory permanently, add the downloaded code to your ~ /. Bash_profile:
Code:
Vi ~. /Bash_profileexport CDPATH =/etc
Similar to the PATH variable, you can add multiple paths to the CDPATH variable (separate multiple directories with semicolons), which makes it easier.
Code:
Export CDPATH = .:~ :/Etc:/var
This technique is helpful when you use the Linux cd command to jump to a specific parent directory:
Oracle DBAs often make some settings under the $ ORACLE_HOME Directory. it is much easier to add the Oracle root directory in the CDPATH.
Unix-like system administrators often modify the configuration files in/etc and add/etc to CDPATH. program developers often work in the/home/projects project directory, at this time, CDPATH can also be of great help.
End users (ordinary account users) often perform routine operations in their home directory. you can consider ~ Add the CDPATH variable to see if using the CDPATH variable can speed up the operation of the Linux cd command.