linux基础命令-mkdir/tree/rmdir
命令行的展开
~: 展开为用户的主目录
~USERNAME: 展开为指定用户的主目录
{}:可承载一个以逗号分隔的列表,并将其展开为多个路径
[root@host01 tmp]# mkdir -vp /tmp/{china/{Beijing,Shanghai},usa,english}
mkdir: created directory `/tmp/china'
mkdir: created directory `/tmp/china/Beijing'
mkdir: created directory `/tmp/china/Shanghai'
mkdir: created directory `/tmp/usa'
mkdir: created directory `/tmp/english'
命令的执行结果状态
bash使用特殊变量$? 保存最后一条命令的执行状态结果
1)成功 0
2)失败 1-255
[root@host01 tmp]# mkdir /tmp/test
[root@host01 tmp]# echo $? [root@host01 tmp]# mkdir /tmp/test
mkdir: cannot create directory `/tmp/test': File exists
[root@host01 tmp]# echo $? [root@host01 tmp]#
程序执行有两类结果
1)程序的返回值
2)程序的运行状态结果(只有两种状态)
mkdir 创建目录
-p:同时创建父目录
-v:显示创建过程
-m MODE : 创建目录时直接指定权限
[root@host01 ~]# mkdir /tmp/a
[root@host01 ~]# mkdir /tmp/a/b/c
mkdir: cannot create directory `/tmp/a/b/c': No such file or directory
[root@host01 ~]# mkdir -pv /tmp/a/b/c #路径不存在的目录创建时会报错,要加-p参数将想应的路径一起创建
mkdir: created directory `/tmp/a/b'
mkdir: created directory `/tmp/a/b/c'
[root@host01 ~]# tree /tmp/
/tmp/
├── a
│ └── b
│ └── c
└── yum.log directories, file
[root@host01 ~]# ls -d /tmp/a/
/tmp/a/
[root@host01 ~]# ll -d /tmp/a/
drwxr-xr-x. root root Aug : /tmp/a/
[root@host01 ~]# mkdir -m /tmp/a/a1 #mkdir -m 权限 路径 创建指定权限的目录
[root@host01 ~]# ll -d /tmp/a/a1/
drw-r--r--. root root Aug : /tmp/a/a1/
[root@host01 ~]# mkdir -v {x,y}-{a,b}
mkdir: created directory `x-a'
mkdir: created directory `x-b'
mkdir: created directory `y-a'
mkdir: created directory `y-b'
[root@host01 ~]# ls
anaconda-ks.cfg install.log install.log.syslog x-a x-b y-a y-b
[root@host01 ~]# rmdir {x,y}-{a,b} -v
rmdir: removing directory, `x-a'
rmdir: removing directory, `x-b'
rmdir: removing directory, `y-a'
rmdir: removing directory, `y-b'
[root@host01 ~]#
rmdir 删除空目录
[root@host01 tmp]# ls
a yum.log
[root@host01 tmp]# rmdir -v a/
rmdir: removing directory, `a/'
rmdir: failed to remove `a/': Directory not empty
[root@host01 tmp]# ll ./a/
total
drw-r--r--. root root Aug : a1
drwxr-xr-x. root root Aug : b
[root@host01 tmp]# rmdir /tmp/a/a1/
a/ .ICE-unix/ yum.log
[root@host01 tmp]# rmdir /tmp/a/a1/
a/ .ICE-unix/ yum.log
[root@host01 tmp]# rmdir /tmp/a/a1/ -v
rmdir: removing directory, `/tmp/a/a1/'
[root@host01 tmp]#
tree
-d:只显示目录
-L level : 指定显示的层级数目
-P pattern :只显示由指定pattern匹配到的路径
[root@host01 tmp]# tree -d /boot/
/boot/
├── efi
│ └── EFI
│ └── redhat
├── grub
└── lost+found directories
[root@host01 tmp]# tree -L /boot/
/boot/
├── config-2.6.-.el6.x86_64
├── efi
├── grub
├── initramfs-2.6.-.el6.x86_64.img
├── lost+found
├── symvers-2.6.-.el6.x86_64.gz
├── System.map-2.6.-.el6.x86_64
└── vmlinuz-2.6.-.el6.x86_64 directories, files
[root@host01 tmp]#
linux基础命令-mkdir/tree/rmdir的更多相关文章
- Linux基础命令mkdir
mkdir /home/ceshi home目录下创建测试目录 mkdir -p /home/ceshi1/ceshi home目录下递归创建 mkdir /home/ceshi2 ...
- Linux基础命令-mkdir
mkdir 作用:创建目录 主要参数:-p $ cd /home/test $ mkdir caianchun $ ls caianchun -p:递归参数 $ mkdir caianchun2/1/ ...
- Linux基础命令小结(超全!!)
Linux目录结构 1.bin 存放经常使用的指令比如ll,cp 2.sbin 系统管理员使用的系统管理指令 3.home 存放普通用户的住目录 4.root 系统管理员的用户主目录 5.boot 存 ...
- Linux 基础命令及基本目录
Linux 基础命令及基本目录 一.网卡 1.网卡配置文件路径 /etc/sysconfig/network-scripts/ifcfg-eth0 配置文件: TYPE=Ethernet # 以太 ...
- 第四节,Linux基础命令
第四节,Linux基础命令 命令是系统操作员对系统传入的指令,传入指令后回车,系统接收到指令做出相应的行为 1.查看用户位于系统什么位置 [pmd]检查操作用户位于系统的什么位置 命令 ...
- 【Python之路】第一篇--Linux基础命令
pwd 命令 查看”当前工作目录“的完整路径 pwd -P # 显示出实际路径,而非使用连接(link)路径:pwd显示的是连接路径 . 表示当前目录 .. 表示上级目录 / 表示根目录 ls ...
- 2.Linux基础命令
linux内一切皆文件,没有文件夹只有目录,目录也是一种文件 1.一些常用按键: 将鼠标的光标从虚拟机里切换回来:Ctrl+Alt 拖动Ubuntu内的对话框:Alt键+鼠标左键拖动 清屏:Ctrl+ ...
- linux基础命令:
linux基础命令: 显示 echo 输出我写的内容 ls 查看当前目录的文件 pwd 查看当前目录 ifconfig 查看网卡信息 grep 过滤 -v 取反 -n man 查看命令的帮助信息 md ...
- 常用的linux基础命令
常用的linux基础命令 1.ls 显示目录属性 -l:(也可以简写成ll),列表显示权限等属性 -a:显示所有文件包括隐藏文件等 -d:只列出目录本身 2.chgrp 改变档案所属群组 eg:chg ...
随机推荐
- PHPExcel 报 Allowed memory size of 8388608 byte
使用 phpExcel 报 Allowed memory size of 8388608 bytes exhausted 错误,原因是php页面消耗的最大内存默认是为 8M (在PHP的ini件里可以 ...
- FileWriter 中午乱码
解决办法 BufferedWriter writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (fil ...
- Kibana问题搜集---下载源码,执行npm install 报错
npm ERR! code ELIFECYCLEnpm ERR! errno 1npm ERR! chromedriver@2.34.0 install: `node install.js`npm E ...
- C#校验手机端或客户端
以下代码用来检查,客户端是手机端还是PC端 string strUserAgent = Request.UserAgent.ToString().ToLower(); bool isMobile = ...
- Codeforces Round #340 (Div. 2) C
Description A flowerbed has many flowers and two fountains. You can adjust the water pressure and se ...
- 1022 D进制的A+B (20 分)
输入两个非负 10 进制整数 A 和 B (≤),输出 A+B 的 D (1)进制数. 输入格式: 输入在一行中依次给出 3 个整数 A.B 和 D. 输出格式: 输出 A+B 的 D 进制数. 输入 ...
- javaEE 转发 和 重定向
转发 两种方法: 1,request.getRequestDispatcher(getServletContext().getContextPath() + "/path").fo ...
- ymPrompt.js消息提示组件
转载:https://www.cnblogs.com/linzheng/archive/2010/11/15/1878058.html 使用说明: 1.在页面中引入ymPrompt.js.如:< ...
- POI 读大文件日志
POI的三个目录 usermodel 包含很多类,方便用户使用,但是占用内存大 eventusermodel 使用xml的SAX事件解析,XSSFReader创建时必须使用OPCPackage,pkg ...
- inode与block知识总结
inode概述:硬盘要分区,然后格式化,创建文件系统在每个Linux存储设备的分区被格式化为ext3文件系统后一般有两个部分: 第一部分Inode:存储这些数据的属性信息(大小,属主,归属的用户 ...