5ucms论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 4339|回复: 0
打印 上一主题 下一主题

Linux命令详解之–cd命令

[复制链接]

670

主题

785

帖子

8303

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
8303
跳转到指定楼层
楼主
发表于 2018-10-31 08:28:01 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
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命令比较简单,主要用来切换工作目录,希望大家能熟练掌握。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|5ucms.com

GMT+8, 2024-9-29 05:25 , Processed in 0.046875 second(s), 30 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表