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
1. Switch from the current directory to /usr/local
avi@tecmint:~$ cd /usr/local avi@tecmint:/usr/local$
2. Use the absolute path to switch from the current directory to /usr/local/lib
avi@tecmint:/usr/local$ cd /usr/local/lib avi@tecmint:/usr/local/lib$
3. Use a relative path to switch from the current path to /usr/local/lib
avi@tecmint:/usr/local$ cd lib avi@tecmint:/usr/local/lib$
4. (a) Switch the current directory to the previous directory
avi@tecmint:/usr/local/lib$ cd - /usr/local avi@tecmint:/usr/local$
4. (b) Switch the current directory to the upper-level directory
avi@tecmint:/usr/local/lib$ cd .. avi@tecmint:/usr/local$
5. Display the last working directory we left
avi@tecmint:/usr/local$ cd -- /home/avi
6. Return two levels from the current directory to the upper level
avi@tecmint:/usr/local$ cd ../../ avi@tecmint:/$
7. Return to the user’s home directory from any directory
avi@tecmint:/usr/local$ cd ~ avi@tecmint:~$
or
avi@tecmint:/usr/local$ cd avi@tecmint:~$
8. Switch the working directory to the current working directory
avi@tecmint:~/Downloads$ cd . avi@tecmint:~/Downloads$
or
avi@tecmint:~/Downloads$ cd ./ avi@tecmint:~/Downloads$
9. Request a line of command to switch
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$
10. Request to use TAB
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$
11. Forgot the directory name
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)
12.切换想要的用户
你想切换到用户‘av‘(不确定是avi还是avt)目录,不用TAB
avi@tecmint:/etc$ cd /home/av? avi@tecmint:~$
13.Linux下的pushed和poped
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:~$
14.切换到名字带有空格的目录
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$
15.切换并显示出来
从当前目录切换到下载目录,然后列出它所包含的内容(使用一行命令)
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!

Linux performs well in servers and development environments, while Windows performs better in desktop and gaming. 1) Linux's file system performs well when dealing with large numbers of small files. 2) Linux performs excellently in high concurrency and high throughput network scenarios. 3) Linux memory management has more advantages in server environments. 4) Linux is efficient when executing command line and script tasks, while Windows performs better on graphical interfaces and multimedia applications.

Creating graphical user interface (GUI) applications is a fantastic way to bring your ideas to life and make your programs more user-friendly. PyGObject is a Python library that allows developers to create GUI applications on Linux desktops using the

Arch Linux provides a flexible cutting-edge system environment and is a powerfully suited solution for developing web applications on small non-critical systems because is a completely open source and provides the latest up-to-date releases on kernel

Due to its Rolling Release model which embraces cutting-edge software Arch Linux was not designed and developed to run as a server to provide reliable network services because it requires extra time for maintenance, constant upgrades, and sensible fi
![12 Must-Have Linux Console [Terminal] File Managers](https://img.php.cn/upload/article/001/242/473/174710245395762.png?x-oss-process=image/resize,p_40)
Linux console file managers can be very helpful in day-to-day tasks, when managing files on a local machine, or when connected to a remote one. The visual console representation of the directory helps us quickly perform file/folder operations and sav

qBittorrent is a popular open-source BitTorrent client that allows users to download and share files over the internet. The latest version, qBittorrent 5.0, was released recently and comes packed with new features and improvements. This article will

The previous Arch Linux LEMP article just covered basic stuff, from installing network services (Nginx, PHP, MySQL, and PhpMyAdmin) and configuring minimal security required for MySQL server and PhpMyadmin. This topic is strictly related to the forme

Zenity is a tool that allows you to create graphical dialog boxes in Linux using the command line. It uses GTK , a toolkit for creating graphical user interfaces (GUIs), making it easy to add visual elements to your scripts. Zenity can be extremely u


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
