Erlo

Linux #sql_zs# 目录基本操作(1)

2019-02-14 17:38:49 发布   535 浏览  
页面报错/反馈
收藏 点赞

cd 切换目录

1.切换到指定目录下

#cd 相对/绝对目录
[root@localhost ~]# cd /home/tom/demo
[root@localhost demo]# 

2.切换到某个用户的主文件夹

[root@localhost /]# cd ~tom
[root@localhost tom]#

3.切换到自己的主文件夹

[root@localhost tom]# cd ~
[root@localhost ~]# 
或者
[root@localhost demo]# cd
[root@localhost ~]# 

4.返回上级目录

[root@localhost demo]# cd ..
[root@localhost tom]# 

5.回到刚才在的目录

[root@localhost tom]# cd -
/home/tom/demo
[root@localhost demo]# 

pwd 显示当前路径

 

[root@localhost demo]# pwd
/home/tom/demo

 

mkdir 新建目录

1.简单创建一个目录 mkdir 目录名

[root@localhost demo]# mkdir work
[root@localhost demo]# ls
work

2.创建目录时同时赋予目录权限

[root@localhost demo]# mkdir -m 777 test
[root@localhost demo]# ll
总用量 8
drwxrwxrwx 2 root root 4096 2月  12 20:15 test
drwxr-xr-x 2 root root 4096 2月  12 20:09 work

3.创建多层目录

[root@localhost demo]# mkdir -p test1/test2/test3
[root@localhost demo]# cd test1/test2/test3/
[root@localhost test3]# pwd
/home/tom/demo/test1/test2/test3

 4.rmdir 删除文件夹

只能删除没有文件的目录,如果删除有文件的目录可以使用 rm -r 目录名

[root@hs-192-168-33-206 tom]# rmdir demo/
rmdir: 删除 "demo/" 失败: 目录非空
#清除文件后,再次删除可成功
[root@hs-192-168-33-206 tom]# rmdir demo/

  

登录查看全部

参与评论

评论留言

还没有评论留言,赶紧来抢楼吧~~

手机查看

返回顶部

给这篇文章打个标签吧~

棒极了 糟糕透顶 好文章 PHP JAVA JS 小程序 Python SEO MySql 确认