访问手机版  

Linux常用命令|Linux培训学习|考试认证|工资待遇与招聘,认准超级网工!

招聘|合作 登陆|注册

网络工程师培训

当前位置:网络工程师 > 技术课程 > linux > 热点关注 > linux常用命令

linux每日命令(2):cd命令

时间:2019-10-16

linux 关机命令_linux命令_linux命令

cd   [目录名]

切换当前目录至 [目录名]

命令:

cd  / 

说明:进入系统根目录,上面命令执行完后拿ls命令看一下linux命令,当前目录已经到系统根目录了

输出:

hc@hc-virtual-machine:~$ pwd
/home/hc
hc@hc-virtual-machine:~$ cd /
hc@hc-virtual-machine:/$ ls
bin    dev   initrd.img      lib64       mnt   root  snap      sys  var
boot   etc   initrd.img.old  lost+found  opt   run   srv       tmp  vmlinuz
cdrom  home  lib             media       proc  sbin  swapfile  usr

pwd的作用是查询当前所在目录

linux命令_linux 关机命令_linux命令

命令:

cd  ..

输出:

hc@hc-virtual-machine:~/PycharmProjects$ pwd
/home/hc/PycharmProjects
hc@hc-virtual-machine:~/PycharmProjects$ cd ..
hc@hc-virtual-machine:~$ pwd
/home/hc

命令:

cd  ../..

输出:

hc@hc-virtual-machine:~/PycharmProjects$ pwd
/home/hc/PycharmProjects
hc@hc-virtual-machine:~/PycharmProjects$ cd ../..
hc@hc-virtual-machine:/home$ pwd
/home

linux 关机命令_linux命令_linux命令

“当前用户主目录”和“系统根目录”是两个不同的概念。进入当前用户主目录有两个方法。

命令1:

cd

直接输入cd,然后回车

输出:

hc@hc-virtual-machine:~/PycharmProjects/my_test$ pwd
/home/hc/PycharmProjects/my_test
hc@hc-virtual-machine:~/PycharmProjects/my_test$ cd 
hc@hc-virtual-machine:~$ pwd
/home/hc

上面的命令是我在非root用户下操作的linux命令,现在我切换到root用户下再操作一遍

hc@hc-virtual-machine:~/PycharmProjects/my_test$ sudo su
root@hc-virtual-machine:/home/hc/PycharmProjects/my_test# pwd
/home/hc/PycharmProjects/my_test
root@hc-virtual-machine:/home/hc/PycharmProjects/my_test# cd 
root@hc-virtual-machine:~# pwd
/root

linux 关机命令_linux命令_linux命令

命令2:

cd ~

输出

hc@hc-virtual-machine:~/PycharmProjects/my_test$ pwd
/home/hc/PycharmProjects/my_test
hc@hc-virtual-machine:~/PycharmProjects/my_test$ cd ~
hc@hc-virtual-machine:~$ pwd
/home/hc

命令