Use the CDPATH variable to speed up Linux cd command operations

Source: Internet
Author: User

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_profile

Export CDPATH =/etc

Similar to the PATH variable, you can add multiple paths in the CDPATH variable to separate multiple directories with semicolons (;). This 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. You can add/etc to CDPATH.

Program developers often work in projects such as/home/projects. CDPATH can also help a lot at this time.

End users (ordinary account users) often perform routine operations in their home directory. You can consider ~ Add the CDPATH variable.

You can use the CDPATH variable to speed up the operation of the Linux cd command.

  1. Linux basic commands-linux cd commands
  2. Linux cd commands and several tips on cd commands
  3. Linux cd commands

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.