集锦续集
2015-06-09 19:25
351 查看
Linux中的cd命令
cd==change directory==切换目录Linux中用cd命令来切换路径
cd命令的语法
cd的语法,可参见:CLi@PC-CLI-1 ~/develop/docbook $ help cd cd: cd [-L|-P] [dir] Change the shell working directory. Change the current directory to DIR. The default DIR is the value of the HOME shell variable. The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the same as the current directory. If DIR begins with a slash (/), then CDPATH is not used. If the directory is not found, and the shell option `cdable_vars' is set, the word is assumed to be a variable name. If that variable has a value, its value is used for DIR. Options: -L force symbolic links to be followed -P use the physical directory structure without following symbolic links The default is to follow symbolic links, as if `-L' were specified. Exit Status: Returns 0 if the directory is changed; non-zero otherwise.
从其解释中,我们可以知道:
如果没有给cd参数的话,默认就是使用HOME环境变量当参数
即:如果没有给cd参数的话,则等价于:
cd $HOME
而由于:
【整理】Linux系统中用波浪号~表示用户的根目录即$HOME,以及为何用波浪号表示用户根目录
所以:
cd == cd $HOME == cd ~ |
那么又等价于:cd /home/CLi
即:
cd == cd $HOME == cd ~ == cd /home/CLi |
cd加上减号表示切换到前一次的路径/目录
cd,加上减号’-‘作为参数的话,表示:切换到上一次,前一次,所在的目录。
举例:
CLi@PC-CLI-1 ~/develop/docbook $ pwd /home/CLi/develop/docbook CLi@PC-CLI-1 ~/develop/docbook $ cd tools/ CLi@PC-CLI-1 ~/develop/docbook/tools $ pwd /home/CLi/develop/docbook/tools CLi@PC-CLI-1 ~/develop/docbook/tools $ cd - /home/CLi/develop/docbook
如图:
总结
cd命令,用好了,也可以提高工作效率。相关文章推荐
- 关于Android Studio无法更新安装而导致无法启动的问题
- 【leetcode】【单链表】【109】Convert Sorted List to Binary Search Tree
- 【leetcode】【单链表】【109】Convert Sorted List to Binary Search Tree
- Linux下编译安装Apache及模块
- Xcode 6.1 做ipa企业级分发(In-House模式)详细步骤
- maven安装到本地库时如何加入工程本地jar包
- Hdu 5262 最强密码(dp)
- adb logcat打印log丢失
- C# 简单工厂模式
- 20150526数据编码_练习
- Linux inotify功能及实现原理
- 【hadoop】5004-Hadoop2.x 集群搭建步骤
- hdu1150 最小点覆盖集的一个小小的变形
- Hadoop伪分布式部署
- 32位和64位各变量字节数
- Java——(三)Collection之Set集合、HashSet类
- hdu2206IP的计算
- scala快速学习笔记(三):Collections,包
- MD5原理
- Python中zip()函数用法举例