15 practice examples of Linux ' CD ' commands

Source: Internet
Author: User
Tags parent directory

650) this.width=650; "src=" Http://www.linuxprobe.com/wp-content/uploads/2017/04/linux-cd-command01.jpg "width=" "Height=" 657 "class=" Alignnone size-full wp-image-58121 "style=" Height:auto; "/>

So, please learn from the heart, we will bring you 15 basic ' CD ' command, they are skilled and shortcut, learn to use these learned techniques, will greatly reduce the effort and time you spend on the terminal

Course Content

    • Command name: CD

    • Delegate: Switch directories

    • Use platform: all Linux distributions

    • Execution mode: command line

    • Permissions: Access your own directory or the rest of the specified directory

    • Level: Basic/Beginner

1. Switch from current directory to/usr/local

[Email protected]:~$ cd/usr/local[email protected]:/usr/local$

2. Use absolute path to switch from current directory to/usr/local/lib

[Email protected]:/usr/local$ cd/usr/local/lib[email protected]:/usr/local/lib$

3. Using relative paths, switch from current path to/usr/local/lib

[Email protected]:/usr/local$ cd Lib[email protected]:/usr/local/lib$

4. (a) switch the current directory to the previous directory

[Email protected]:/usr/local/lib$ cd-/usr/local[email protected]:/usr/local$

4. (b) switch the current directory to the parent directory

[Email protected]:/usr/local/lib$ CD. [Email protected]:/usr/local$

5. Show us the last working directory left

[Email protected]:/usr/local$ cd--/home/avi

6. Return two tiers from the current directory to the Superior

[Email protected]:/usr/local$ CD. /.. /[email protected]:/$

7. Return to user home directory from any directory

[Email protected]:/usr/local$ cd ~[email protected]:~$

Or

[Email protected]:/usr/local$ cd[email protected]:~$

8. Switch the working directory to the current working directory

[Email protected]:~/downloads$ CD. [Email protected]:~/downloads$

Or

[Email protected]:~/downloads$ cd./[email protected]:~/downloads$

9. Require one-line command switch

Your current directory is "/usr/local/lib/python3.4/dist-packages", now you want to switch to "/home/avi/desktop/", require: one line of command, by switching up until '/', and then using the absolute path

[Email protected]:/usr/local/lib/python3.4/dist-packages$ CD. /.. /.. /.. /.. /home/avi/desktop/[email protected]:~/desktop$

10. Ask for Tab

Switch from current working directory to/var/www/html, ask: Do not complete the command, use tab

[Email protected]:/var/www$ cd/v<tab>/w<tab>/h<tab>[email protected]:/var/www/html$

11. Forget the directory name

Switch from current directory to/etc/v__ _, gosh, you forgot the name of the directory, but you don't want to use tab.

[Email protected]:~$ cd/etc/v*[email protected]:/etc/vbox$

Please note: If only one directory starts with 'v', this will move to 'vbox'. If many directories start with 'v' and no more standards are provided on the command line, this will move to the first directory starting with 'v' (in the order in which they exist in the standard dictionary)

12. Switch the desired user

You want to switch to the user's 'av' (not sure if it's an AVI or AVT) directory without the TAB

[Email protected]:/etc$ cd/home/av? [Email protected]:~$

Pushed and poped under 13.Linux

Pushed and poped are Linux bash commands, and several other scripts that can save the current working directory location to memory and read the directory from memory as the current directory, and these scripts may also switch directories

[Email protected]:~$ pushd/var/www/html/var/www/html ~[email protected]:/var/www/html$

The above command saves the current directory to memory and then switches to the requested directory. Once poped is executed, it will remove the saved directory location from memory as the current directory

[Email protected]:/var/www/html$ popd~[email protected]:~$

14. Switch to a directory with a blank name

[Email protected]:~$ cd test/tecmint/[email protected]:~/test tecmint$

Or

[Email protected]:~$ CD ' Test tecmint ' [email protected]:~/test tecmint$

Or

[Email protected]:~$ cd "Test Tecmint"/[email protected]:~/test tecmint$

15. Toggle and show it

Switch from the current directory to the download directory, and then list what it contains (using one line command)

[Email protected]:/usr$ cd ~/downloads && ls....service_locator_in.xlssources.listteamviewer_linux_ X64.debtor-browser-linux64-3.6.3_en-us.tar.xz ....

We try to use the fewest words and as always friendly to let you know about the work and execution of Linux.

That's all that stuff. I'll be back with another interesting theme soon.

Original address:http://www.linuxprobe.com/linux-cd-command.html

This article is from the "blog" blog, please be sure to keep this source http://coderhsf.blog.51cto.com/12629645/1918379

15 practice examples of Linux ' CD ' commands

Related Article

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.