Use the CDPATH variable to speed up the Linuxcd command operation

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.