🌿 Linux Command Line (Part II): Introduction to File System Navigation
What is the core component of an operating system? It is not the interface, nor the applications, but the file system. Without a file system, the system cannot boot. It is the carrier of all data and the foundation for user interaction with the system.
In this article, we will briefly understand how to navigate the Linux file system and master a few basic commands.
This article serves to better connect the previous and subsequent content. For detailed operations, please refer to Linux Command Line (Part III).
📍 Current Location: <span>pwd</span>
Every time you open a terminal, the system places you in a default directory—your home directory. To confirm your current location, you can use the <span>pwd</span> (print working directory) command:
yusen@yusen:~$ pwd
/home/yusen
📂 View Directory Contents: <span>ls</span>
Want to know what files or folders are in the current directory? Use the <span>ls</span> command to find out:
yusen@yusen:~$ ls
公共的 模板 视频 图片 文档 下载 音乐 桌面
🧭 Two Forms of Paths: Absolute vs Relative
Paths in Linux are divided into two types:
- • Absolute Path: Starts from the root directory
<span>/</span>and points to a specific location completely - • Relative Path: Describes the target using relative positions starting from the current directory
For example:
# Absolute Path
cd /usr/bin
pwd
# Output: /usr/bin
Relative paths can also use special symbols:
- •
<span>.</span>represents the current directory - •
<span>..</span>represents the parent directory
cd ..
pwd
# Output: /usr
You can also use <span>cd ./bin</span> or directly <span>cd bin</span> to return to the subdirectory <span>/usr/bin</span>.
🔄 Other Uses of cd
- •
<span>cd</span>: Return to the home directory - •
<span>cd -</span>: Switch to the previous working directory - •
<span>cd ~user_name</span>: Enter the home directory of a specified user
cd
pwd
# Output: /home/yusen
cd -
pwd
# Output: /usr/bin