Use of relative paths, absolute paths, and cd commands

Source: Internet
Author: User

Use of relative paths, absolute paths, and cd commands

Cd (change directory) directory
Jump to the specified directory

There are two types of path definitions: absolute path (absolute) and relative path (relative)

Absolute path: the file name or directory name written from the root directory (/)
Example:/tmp/test/test1

Relative Path: the file name method relative to the current path
For example,./home/dmtsai or.../home/dmtsai.

The following uses the cd command to explain the relative path and absolute path.

For example, there are two files
/Tmp/test/test1
/Tmp/test/fun/test2

If you want to go to the fun directory, you can do this.

$ Cd/tmp/test/fun

$ Pwd: we can see that the user is now in the fun directory, and the previous directory is test.

If you want to go to the test directory, you can do this.

$ Cd .. this is the method of writing relative paths, directly jump up from the current directory, that is, test

$ Cd/tmp/test: this is the absolute path, or it starts from the root. If the directory is long
The method increases the input, but this is the most accurate method.

Bytes ------------------------------------------------------------------------------------
.: Indicates the current directory./also indicates the current directory.

..: Indicates the previous directory ../is also the meaning of the previous directory

-: Relative to the current directory, the previous directory

For example, using $ cd/from/tmp/test/fun will jump to the root directory and then use
$ Cd-Return to the/tmp/test/fun directory

~ : Indicates the user's home directory

Cd [~] : Jump to the Home Directory of the current user

Cd ~ Username: jump to a user's home directory




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.