LInux上返回到切换目录前的目录

时间:2022-10-26 15:47:54

  在Linux系统上,切换目录用命令cd (change directory),查看当前目录的命令pwd (print working directory)。

  例如当前目录为:/home/keysystem/Desktop

[keysystem@localhost Desktop]$ pwd
/home/keysystem/Desktop
[keysystem@localhost Desktop]$

  要进入到根目录,执行命令:cd /

[keysystem@localhost Desktop]$ cd /
[keysystem@localhost
/]$ pwd
/
[keysystem@localhost
/]$

  如果要回到:/home/keysystem/Desktop,则执行命令:cd -

[keysystem@localhost /]$ cd -
/home/keysystem/Desktop
[keysystem@localhost Desktop]$
pwd
/home/keysystem/Desktop
[keysystem@localhost Desktop]$