Home >System Tutorial >LINUX >15 practice examples of the Linux 'cd' command
In the Linux operating system, the "cd" (change directory) command is one of the most commonly used and important commands for novices and system administrators. For administrators who manage servers without a graphical interface, it is essential to use the "cd" command to enter directories, check logs, execute programs/applications/scripts, and complete other tasks. For novices, the "cd" command is also one of the basic commands they must learn.
So, please study hard. We will bring you 15 basic 'cd' commands here. They are full of skills and shortcuts. Learning to use these learned skills will greatly reduce your expenses on the terminal. Effort and time
Course content
Command name: cd
stands for: switch directory
Platform used: all Linux distributions
Execution method: command line
Permissions: access your own directory or other specified directories
Level: Basic/Beginner
avi@tecmint:~$ cd /usr/local avi@tecmint:/usr/local$
avi@tecmint:/usr/local$ cd /usr/local/lib avi@tecmint:/usr/local/lib$
avi@tecmint:/usr/local$ cd lib avi@tecmint:/usr/local/lib$
avi@tecmint:/usr/local/lib$ cd - /usr/local avi@tecmint:/usr/local$
avi@tecmint:/usr/local/lib$ cd .. avi@tecmint:/usr/local$
avi@tecmint:/usr/local$ cd -- /home/avi
avi@tecmint:/usr/local$ cd ../../ avi@tecmint:/$
avi@tecmint:/usr/local$ cd ~ avi@tecmint:~$
or
avi@tecmint:/usr/local$ cd avi@tecmint:~$
avi@tecmint:~/Downloads$ cd . avi@tecmint:~/Downloads$
or
avi@tecmint:~/Downloads$ cd ./ avi@tecmint:~/Downloads$
Your current directory is "/usr/local/lib/python3.4/dist-packages", now you want to switch to "/home/avi/Desktop/", the requirements are: one line of command, switch up until '/ ', then use the absolute path
avi@tecmint:/usr/local/lib/python3.4/dist-packages$ cd ../../../../../home/avi/Desktop/ avi@tecmint:~/Desktop$
Switch from the current working directory to /var/www/html, requirement: do not type the complete command, use TAB
avi@tecmint:/var/www$ cd /v/w/h avi@tecmint:/var/www/html$
Switch from the current directory to /etc/v__ _, oh, you forgot the name of the directory, but you don’t want to use TAB
avi@tecmint:~$ cd /etc/v* avi@tecmint:/etc/vbox$
Please note: If there is only one directory starting with 'v', this will be moved to 'vbox'. If there are many directories starting with 'v' and no further criteria are provided on the command line, this will move to the first directory starting with 'v' (as per The order in which they appear alphabetically in a standard dictionary)
你想切换到用户‘av‘(不确定是avi还是avt)目录,不用TAB
avi@tecmint:/etc$ cd /home/av? avi@tecmint:~$
Pushed和poped是Linux bash命令,也是其他几个能够保存当前工作目录位置至内存,并且从内存读取目录作为当前目录的脚本,这些脚本也可以切换目录
avi@tecmint:~$ pushd /var/www/html /var/www/html ~ avi@tecmint:/var/www/html$
上面的命令保存当前目录到内存,然后切换到要求的目录。一旦poped被执行,它会从内存取出保存的目录位置,作为当前目录
avi@tecmint:/var/www/html$ popd ~ avi@tecmint:~$
avi@tecmint:~$ cd test/ tecmint/ avi@tecmint:~/test tecmint$
或
avi@tecmint:~$ cd 'test tecmint' avi@tecmint:~/test tecmint$
或
avi@tecmint:~$ cd "test tecmint"/ avi@tecmint:~/test tecmint$
从当前目录切换到下载目录,然后列出它所包含的内容(使用一行命令)
avi@tecmint:/usr$ cd ~/Downloads && ls ... . service_locator_in.xls sources.list teamviewer_linux_x64.deb tor-browser-linux64-3.6.3_en-US.tar.xz . ...
我们尝试使用最少的词句和一如既往的友好,来让你了解Linux的工作和执行。
这就是所有内容。我很快会带着另一个有趣的主题回来的。
The above is the detailed content of 15 practice examples of the Linux 'cd' command. For more information, please follow other related articles on the PHP Chinese website!