文件操作-cd
cd命令是linux实际使用当中另一个非常重要的命令,本文就为大家介绍下Linux中cd命令的用法。
转载自 https://www.cnblogs.com/waitig/p/5880719.html
更多Linux命令详情可看 https://www.linuxdaxue.com/linux-commands-manual
cd命令
Linux cd命令用于切换当前工作目录至 dirName(目录参数)。
其中 dirName 表示法可为绝对路径或相对路径。若目录名称省略,则变换至使用者的 home 目录 (也就是刚 login 时所在的目录)。
另外,"~" 也表示为 home 目录 的意思,"." 则是表示目前所在的目录,".." 则表示目前目录位置的上一层目录。
一、Linux cd命令语法
cd [dirName]
dirName:要切换的目标目录。
二、Linux cd命令实例
跳入test目录:
[root@/root/linuxdaxue.com]#cd testDir/
[root@/root/linuxdaxue.com/testDir]#ls
file1 file2 file3
跳至上层目录:
[root@/root/linuxdaxue.com/testDir]#cd ..
[root@/root/linuxdaxue.com]#ls
testDir
跳至上上层目录:
[root@/root/linuxdaxue.com/testDir]#cd ../../
[root@/root]#ls
跳入用户主目录:
[root@/root/linuxdaxue.com/testDir]#ls
file1 file2 file3
[root@/root/linuxdaxue.com/testDir]#cd ~/
[root@/root]#pwd
/root
使用绝对路径:
[root@/root]#cd /root/linuxdaxue.com/testDir
[root@/root/linuxdaxue.com/testDir]#ls
file1 file2 file3
使用环境变量:
[root@/root]#cd $TEST_PATH
[root@/root/linuxdaxue.com/testDir]#ls
file1 file2 file3
跳入上次使用目录:
[root@/root]#pwd
/root
[root@/root]#cd -
/root/linuxdaxue.com/testDir
[root@/root/linuxdaxue.com/testDir]#
cd命令比较简单,主要用来切换工作目录,希望大家能熟练掌握。
作者: DreamDZhu
出处: https://www.cnblogs.com/ddz-linux/>
关于作者:专注Linux运维的萌新,目标:独立管理后宫三千服务器,请多多赐教!
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 原文链接 如有问题, 可邮件(852749070@qq.com)咨询.
互相尊重版权,才能有更好的未来。