Linux文件路径分为绝对路径和相对路径

1. 绝对路径

绝对路径是指从根目录(/)开始的路径,如/usr、/etc/X11表示绝对路径。用户通过cd命令以绝对路径进入某个文件夹,具体如下所示。

[root@localhost ~]# cd  /usr/share/doc/

此时,用户通过pwd命令可以查看当前工作目录的绝对路径,具体如下所示。

[root@localhost doc]# pwd

/usr/share/doc

以上输出结果表示用户当前处于/usr/share/doc路径下。

2. 相对路径

相对路径是指相对于当前工作目录的路径,例如,用户从/usr/share/doc路径切换到/usr/share/man路径,可以用如下方式。

 [root@localhost ~]# cd  /usr/share/doc/

[root@localhost doc]# cd  ../man

[root@localhost man]# pwd

/usr/share/man

[root@localhost man]#

注:“..”表示当前目录的上层目录,“.”表示当前目录。

猜你喜欢

转载自blog.csdn.net/m0_68367226/article/details/130511517