Linux命令:cd
语法
cd [-L|[-P [-e]]] [dir]
改变shell当前工作目录。仅对执行命令所在的shell有效。
参数
-L 按符号链接进入目录。
-P 按物理链接进入目录
-e 如果指定-P,且路径不存在,则返回-e后指定的退出码。
说明
cd =change directory
进入主目录。不带参数dir,就默认进入当前用户的主目录。等价命令还有 cd ~ 或 cd $HOME。
进入上一次切换前的工作目录。cd - 或 cd $OLDPWD。如果反复执行,则会在最后两次工作目录间来回切换。
cd的默认行为,等于cd <=> cd -L。如果路径中包含符号连接,则跟着符号链接走。
CDPATH环境变量
CDPATH环境变量为cd 提供一组备选的当前目录。也就是说,如果你输入的不是/开头的绝对路径,则进入的目录的绝对路径是CDPATH中的目录+你的目录。举例来说,
架设你当前目录是/usr,myhome在你的/home下。
export CDPATH=/root:/home/:/etc
cd myhome
执行以上命令后,bash会依次将CDPATH中的目录+myhome来进入,最终进入到/home/myhome目录下。【CDPATH中多个路径下都有dir怎么办?】
进入你刚创建的目录
mkdir <dir> && cd $_
不论你创建的目录是否你当前工作目录下的,这个命令都能用。
创建只有一个下划线名字的目录
mkdir ./_
help cd
cd: cd [-L|[-P [-e]]] [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
-e if the -P option is supplied, and the current working directory
cannot be determined successfully, exit with a non-zero status The default is to follow symbolic links, as if `-L' were specified. Exit Status:
Returns if the directory is changed, and if $PWD is set successfully when
-P is used; non-zero otherwise.
Linux命令:cd的更多相关文章
- 【Linux基础】常用Linux命令: cd, cp, ls, mkdir, mv, rm, su, uname
常用Linux命令:cd, cp, ls, mkdir, mv, rm, su, uname cd命令:切换当前工作目录至 dirName(目录参数) 其中 dirName 可为绝对路径或相对路径.若 ...
- linux命令 --> cd命令
关于linux的命令这里进行简单的说明一下(简单的说明哦!!) 对于linux和windows基本的操作就是切换目录,因为只有进入目录时,才能看到里面的内容(对于linux这说的不太准确必定还有ls呢 ...
- Linux 命令 - cd: 切换工作目录
命令格式 cd [directory] 实例 a) 将工作目录切换成主目录. cd # 或 cd ~ b) 将工作目录切换成当前工作目录的父目录. cd .. c) 将工作目录切换成上一个的工作目录. ...
- 07.19 Linux命令 cd
情景:在用compass编写sass,cd进入目录后,想退出, 解决: cd.. 回到上一层目录 cd\ 回到根目录 cd 进入具体目录
- WinSCP使用与linux命令(小部分命令)
一.下载一个WinSCP WinSCP是一个Windows环境下使用SSH的开源图形化SFTP客户端.同时支持SCP协议.它的主要功能就是在本地与远程计算机间安全的复制文件..winscp也可以链接其 ...
- Linux命令详解之–cd命令
cd命令是linux实际使用当中另一个非常重要的命令,本文就为大家介绍下Linux中cd命令的用法. 更多Linux命令详情请看:Linux命令速查手册 Linux cd命令用于切换当前工作目录至 d ...
- linux 命令随笔 ls cd pwd mkdir rm mv cp cat nl
Linux 命令练习 ls命令 ls就是list的简写,目的是打印当前目录下的清单 格式 ls[选项][目录名] 常用参数 -a –all 列出目录下的所有文件,包括以 . 开头的隐含文件 -l 除了 ...
- 自学Linux Shell3.2-切换目录命令cd
点击返回 自学Linux命令行与Shell脚本之路 3.2-切换目录命令cd 当登录系统并获得shell命令提示符后,你通常位于自己的主目录中. 使用pwd命令验证: pwd命令以绝对路径的方式显示用 ...
- 每天一个linux命令(3):cd命令
版权声明 更新:2017-04-27博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下命令cd. 2 开 ...
随机推荐
- vs2015和Oracle在一起时的Shit问题
VS2015在连接Oracle时,必须要安装到一个不含有空格的目录中去,否则连接不上Oracle,至于为什么,不知道,鬼知道,日的. 如果你不幸以前安装过VS2015,安装到它的默认的什么“progr ...
- 真机*Appium
一.真机连接电脑123 1.一般android手机的的USB调试模式在设置里的开发者选项中,找到开发者选项,打开USB调试 2.cmd命令→[adb devices]→回车,得到真机设备 可能存在问题 ...
- 2017-2018 ACM-ICPC, NEERC A题Automatic Door 挺棘手的模拟
题目链接:http://codeforces.com/contest/883/problem/A 题意大致就是有一个门,有n个人有规律的来,时刻分别是a,2a,3a.....na.有m个人无规律的来, ...
- winform获取EXE图片
winform获取EXE图片 using (FileStream fs = new System.IO.FileStream(n, FileMode.OpenOrCreate, FileAccess. ...
- #20175120彭宇辰 java第五周学习总结
第六章 接口与实现 教材学习内容总结 接口-接口声名interace -接口体1.只有常量声明和抽象方法2.所有常量和方法的访问权限都为public3.常量都为static常量4.可省略pulic\s ...
- 2018.4.27 python使用过的第三方库
Flask flask-login flask-sqlalchemy flask-mail psutil lvm2py oss2 python-ldap pyudev pyOpenSSL urllib ...
- hdu5001 Walk 概率DP
I used to think I could be anything, but now I know that I couldn't do anything. So I started travel ...
- 使用miniconda创建python虚拟环境
安装python指定环境 conda create -n oldboy python=3.6.5 安装环境的同时安装相应的包 conda create -n oldboy python=3.6.5 p ...
- (拼接SQL语句)mysql中date类型,datetime类型
: , . _ - / % & # @ ! * | [ ] { } ; + = update ky set date = '18,9-2' where id = 1 // 2 ...
- linux学习笔记(二:权限)
Linux下有两种用户: 超级用户(root).普通用户. 超级用户:可以再linux系统下做任何事情,不受限制 普通用户:在linux下做有限的事情,例如:rm -rf 只会删除自己的东西. 超级用 ...