Linux using an absolute or relative path for directory switch, the absolute and relative paths of understanding

Absolute and relative paths


learning target

  • It can be used for absolute or relative path change directory

1. absolute path

Called the absolute path to the root directory path from the date of

E.g:

  • /home/python/Desktop
  • /usr/bin

2. Relative path

Called the relative path from the current directory path counting

E.g:

- ./test/hello
- ../static/images

3. The use of absolute and relative paths

  1. Use the absolute path to switch to the desktop
    cd / home / python / Desktop
  2. In the download directory relative path switch to the desktop
    cd Downloads
    cd ... / Desktop
  3. Using a relative path desktop switch to the parent directory of the parent directory cd Desktop cd ... / ... /

4. autocomplete

  • After the first few letters of a file or directory or knock out the command, press the tab key, if not ambiguous input, the system will auto-complete
  • When switched directory or use the command, not sure if there are other commands or those subdirectories under the current directory, you can see through the tab key twice

5. Summary

  • Absolute and relative paths are two forms of the path, the shortest path should follow the principle (using the shortest path to a file or directory operation).
    • Switching from the current directory if the directory may be used near a relative path
    • If you switch from the root directory using an absolute path near
    • If you switch from the root directory of the current directory and then use absolute paths are the same, because this path is clear and unambiguous, easy to read.
Published 698 original articles · won praise 929 · views 120 000 +

Guess you like

Origin blog.csdn.net/qq_35456045/article/details/104785115