centos7进入文件夹命令

您所在的位置:网站首页 linux进入文件夹指令 centos7进入文件夹命令

centos7进入文件夹命令

#centos7进入文件夹命令| 来源: 网络整理| 查看: 265

相对和绝对路径

绝对路径:从/目录开始的文件,无论在哪个目录都可以使用绝对路劲访问

相对路径:相对绝对路径来说,从当前目录开始 查看当前目录路径

[root@linux1 ~]# /etc/sysconfig/network-scripts/ifcfg-ens33 #这个就是路径

[root@linux1 ~]# ls /root/anaconda-ks.cfg

/root/anaconda-ks.cfg                                       #这个是就是绝对路径

cd命令

[root@linux1 ~]# pwd          #查看当前目录

/root

[root@linux1 ~]# cd /etc/     #进入到etc目录下

[root@linux1 etc]# pwd

/etc                          #当前目录是etc

[root@linux1 etc]# cd         #返回上一次目录

[root@linux1 ~]# pwd

/root

[root@linux1 ~]# cd /etc/

[root@linux1 etc]# pwd

/etc

[root@linux1 etc]# cd ~       #进入到当前用户/目录

[root@linux1 ~]# pwd

/root

[root@linux1 ~]# cd /etc/

[root@linux1 etc]# cd ..      #进入到上级目录

[root@linux1 /]# pwd

/

[root@linux1 /]# cd -        #返回上次所在目录

/etc

[root@linux1 etc]# cd -

/

[root@linux1 /]#

创建和删除目录mkdir/rmdir

#mkdir 创建目录

[root@linux1 /]# mkdir -pv /tmp/a/1/2/3   #可视化创建目录 带有两个参数:p & v 分别表示 级联创建 和 可视化创建

mkdir: 已创建目录 "/tmp/a"

mkdir: 已创建目录 "/tmp/a/1"

mkdir: 已创建目录 "/tmp/a/1/2"

mkdir: 已创建目录 "/tmp/a/1/2/3"

[root@linux1 /]# mkdir /tmp/a/2           #创建/tmp/a/2目录

[root@linux1 /]# cd /tmp/a/

[root@linux1 a]# pwd

/tmp/a

#rmdir 只能删除非空目录

[root@linux1 a]# rmdir /tmp/a/1/2/3       #删除/tmp/a/1/2/3目录

[root@linux1 2]# cd /tmp/a/1/2/3

-bash: cd: /tmp/a/1/2/3: 没有那个文件或目录

[root@linux1 2]# touch /tmp/a/1/2/1.txt   #创建 1.txt文件

[root@linux1 2]# rmdir /tmp/a/1

rmdir: 删除 "/tmp/a/1" 失败: 目录非空

rm命令

#rm remove 删除文件或者非空目录

[root@linux1 ~]# ls /tmp/a/1/2

1.txt

[root@linux1 ~]# rm -f /tmp/a/1/2/*      #删除1.txt文件 *表示通配符,即删除目录下的文件

[root@linux1 ~]# ls /tmp/a/1/2

[root@linux1 ~]# rm -rfv /tmp/a/1        #强制删除目录 参数:r 、f 、v 各表示 删除目录 强制删除文件,无需提示 可视化删除

已删除目录:"/tmp/a/1/2"

已删除目录:"/tmp/a/1"



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3