Home> System Tutorial> LINUX> body text

How to switch directories in linux

下次还敢
Release: 2024-04-12 11:09:13
Original
940 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 thecdcommand to switch directories.cdThe 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:./Documentsmeans theDocumentssubdirectory in the current directory

Switch to the root directory:

cd /
Copy after login

Switch to the parent directory:

cd ..
Copy after login

Switch to the relative path:

cd ./Documents
Copy after login

Switch to the absolute path:

cd /home/username/Documents
Copy after login

Switch to the home directory:

cd ~
Copy after login

Switch to another user’s home directory:

cd ~username
Copy after login

Tips:

  • You can use thepwdcommand to view the current directory.
  • Tab key can automatically complete directory and file names.
  • Use thelscommand 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 Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!