Linux 文件系统导航基础知识Linux 文件系统导航基础知识Linux 文件系统导航基础知识Linux 文件系统导航基础知识
  • 业务
  • 目标
  • 支持
  • 关于
  • 联系我们
  • 登录
✕

Linux 文件系统导航基础知识

发表 admin at 2025年2月28日
类别
未分类
标签

本文介绍了在 Linux 文件系统中导航的基本命令。下图代表了被称为文件系统层次结构标准的 Linux 文件系统(的一部分)。从一个节点到其右侧节点的一条线表示包含。例如,学生目录包含在主目录中。

在本教程中您将学习:

  • 如何使用pwd命令

  • 如何使用cd命令

  • 如何导航到用户主目录

  • 相对与绝对之间的差异

  • 什么是父目录

Linux 文件系统层次结构标准 (FHS)

Linux 文件系统导航基础分步说明

以下说明是 GNU/Linux 初学者用户需要掌握的最低指令,以便能够在 GNU/Linux 命令行上执行最简单的任务。一旦您学习了以下基础知识,您就可以开始学习更高级的命令行主题。

  1. 当您在 shell 终端中工作时,您始终在特定目录中进行操作。要确定您所在的目录,请使用 pwd 命令:

    student@linuxconfig:$ pwd /usr/local/bin 
    student@linuxconfig:$ cd 
    student@linuxconfig:$ pwd /home/student 
    student@linuxconfig:$
  2. 您的主目录是您第一次打开终端时所在的目录。要从任何地方转到您的主目录,只需输入 cd 命令:

    student@linuxconfig:$ pwd
    /usr/local/bin
    student@linuxconfig:$ cd
    student@linuxconfig:$ pwd
    /home/student
    student@linuxconfig:$
  3. 绝对路径名是以 / 字符开头,表示文件系统树的根。因此,进入主目录的另一种方法是:

    student@linuxconfig:/etc$ cd /home/student
    student@linuxconfig:$ pwd
    /home/student
    student@linuxconfig:$
  4. 相对路径是以连接到当前目录的目录名称开头的路径。例如,如果您位于 /usr 目录中,则仅键入 cd bin(“bin”前面不带“/”)会产生以下效果:

    student@linuxconfig:$ pwd
    /usr
    student@linuxconfig:$ cd bin
    student@linuxconfig:$ pwd
    /usr/bin
    student@linuxconfig:$
  5. 要转到包含当前工作目录(也称为父目录)的目录,请键入:

    student@linuxconfig:$ pwd
    /usr/bin
    student@linuxconfig:$ cd ..
    student@linuxconfig:$ pwd
    /usr
    student@linuxconfig:$
  6. 当前工作目录的相对路径名称为.(句号)。因此输入:

    student@linuxconfig:$ pwd
    /usr/bin
    student@linuxconfig:$ cd . 
    student@linuxconfig:$ pwd
    /usr/bin
    student@linuxconfig:$
©2015-2025 Norria support@norria.com