Home >System Tutorial >LINUX >How to switch directories in linux
Switch directories in Linux systems: use the cd command. The path can be absolute (starting from the root directory) or relative (relative to the current directory). Relative paths: Use . to represent the current directory and .. to represent the parent directory. Absolute path: Full path starting from the root directory (/). cd ~ switches to the home directory, cd ~username switches to other users' home directories. The pwd command displays the current directory, the Tab key automatically completes the path, and the ls command lists the directory contents.
Switching Directories in Linux
In a Linux system, a directory is a hierarchical structure that organizes files and folders . Changing directories is one of the basic operations of navigating a file system.
Method:
You can use the cd
command to switch directories. cd
The following path can be an absolute path or a relative path.
/
. For example: /home/username/Documents
./Documents
means the Documents
subdirectory in the current directory Switch to the root directory:
<code>cd /</code>
Switch to the parent directory:
<code>cd ..</code>
Switch to the relative path:
<code>cd ./Documents</code>
Switch to the absolute path:
<code>cd /home/username/Documents</code>
Switch to the home directory:
<code>cd ~</code>
Switch to another user’s home directory:
<code>cd ~username</code>
Tips:
pwd
command to view the current directory. ls
command to list the files and folders in the directory. The above is the detailed content of How to switch directories in linux. For more information, please follow other related articles on the PHP Chinese website!