cd 更改目录
1、单独一个命令是进入到用户的家目录
[root@wy ~]# cd
[root@wy ~]#
等同于cd ~,~就表示root,即用户的家目录
[root@wy ~]# cd ~
[root@wy ~]# cd /tmp
[root@wy tmp]# cd ~
[root@wy ~]#
2、查看当前用户
[root@wy ~]# whoami
root
3、查看用户的uid或组
[root@wy ~]# id
uid=0(root) gid=0(root) groups=0(root)
4、查看用户的家目录
[root@wy ~]# echo $HOME
/root
5、如何查看当前在哪个目录下
[root@wy ~]# pwd
/root
6、cd后面加上要进入的目录
[root@wy ~]# cd /tmp
[root@wy tmp]# pwd
/tmp
7、不管在哪个目录下,用cd单独的命令,都会回到用户的家目录下
[root@wy tmp]# cd
[root@wy ~]# pwd
/root
8、回到上一次所在的目录(交替)
[root@wy ~]# cd -
/tmp
[root@wy tmp]#
[root@wy tmp]# cd -
/root
[root@wy ~]#
9、cd . 进入当前目录,cd .. 进入到上一级目录
[root@wy ~]# cd /tmp
[root@wy tmp]# cd .
[root@wy tmp]# cd /var/log
[root@wy log]# cd ..
[root@wy var]#
[root@wy var]# pwd
/var
本文出自 “linux” 博客,转载请与作者联系!
原文:http://warm51fun.blog.51cto.com/3884274/1891497