Home > System Tutorial > LINUX > body text

How to switch directories in linux

下次还敢
Release: 2024-04-12 11:09:13
Original
1044 people have browsed it

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.

How to switch directories in linux

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.

  • Absolute path: The full path starting from the root directory /. For example: /home/username/Documents
  • Relative path: The path relative to the current directory. For example: ./Documents means the Documents subdirectory in the current directory

Switch to the root directory:

<code>cd /</code>
Copy after login

Switch to the parent directory:

<code>cd ..</code>
Copy after login

Switch to the relative path:

<code>cd ./Documents</code>
Copy after login

Switch to the absolute path:

<code>cd /home/username/Documents</code>
Copy after login

Switch to the home directory:

<code>cd ~</code>
Copy after login

Switch to another user’s home directory:

<code>cd ~username</code>
Copy after login

Tips:

  • You can use the pwd command to view the current directory.
  • Tab key can automatically complete directory and file names.
  • Use the 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template