1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - 正文

君子好学,自强不息!

linux cd命令怎么用?

2022-10-21 | Linux系统 | 1818ip | 734°c
A+ A-
可能大家还对“linux cd命令怎么用?”有些不明白,下面由1818ip小编来为大家解答一下,现在我们来一起看看吧!

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命令比较简单,主要用来切换工作目录,希望大家能熟练掌握。

以上就是“linux cd命令怎么用?”的详细内容,更多请关注1818ip网其它相关文章!

本文来源:1818IP

本文地址:https://www.1818ip.com/post/3731.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。