我是靠谱客的博主 傻傻哈密瓜,最近开发中收集的这篇文章主要介绍linux cd命令怎么用?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

相关推荐:《Linux视频教程》

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命令怎么用?的全部内容,希望文章能够帮你解决linux cd命令怎么用?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(84)

评论列表共有 0 条评论

立即
投稿
返回
顶部