系统版本:
[root@node1 ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
[root@node1 ~]# uname -r
3.10.0-229.el7.x86_64
~: 自动展开为用户的家目录,或指定的用户的家目录
示例:
[root@node1 network-scripts]# cd ~
[root@node1 ~]#
{}: 可承载一个以逗号分隔的路径列表,并能够将其展开为多个路径
示例: 在/tmp创建以下目录,a_c,a_d,b_c,b_d
[root@node1 ~]# mkdir -v {a,b}_{c,d}
mkdir: created directory ‘a_c’
mkdir: created directory ‘a_d’
mkdir: created directory ‘b_c’
mkdir: created directory ‘b_d’
示例: 在/tmp/mylinux下创建目录结构
先了解tree命令:
以树状结构列出目录内容。
语法: tree [options] [directory]
选项: -L level: 指定要显示的层级
安装: yum -y install tree
[root@node1 ~]# mkdir -pv /tmp/mylinux/{bin,etc/sysconfig/network-scripts,sbin,usr/\
{bin,lib,lib64,local/{bin,etc,lib,sbin},sbin},var/{cache,log,run}}
mkdir: created directory ‘/tmp/mylinux’
mkdir: created directory ‘/tmp/mylinux/bin’
mkdir: created directory ‘/tmp/mylinux/etc’
mkdir: created directory ‘/tmp/mylinux/etc/sysconfig’
mkdir: created directory ‘/tmp/mylinux/etc/sysconfig/network-scripts’
mkdir: created directory ‘/tmp/mylinux/sbin’
mkdir: created directory ‘/tmp/mylinux/usr’
mkdir: created directory ‘/tmp/mylinux/usr/bin’
mkdir: created directory ‘/tmp/mylinux/usr/lib’
mkdir: created directory ‘/tmp/mylinux/usr/lib64’
mkdir: created directory ‘/tmp/mylinux/usr/local’
mkdir: created directory ‘/tmp/mylinux/usr/local/bin’
mkdir: created directory ‘/tmp/mylinux/usr/local/etc’
mkdir: created directory ‘/tmp/mylinux/usr/local/lib’
mkdir: created directory ‘/tmp/mylinux/usr/local/sbin’
mkdir: created directory ‘/tmp/mylinux/usr/sbin’
mkdir: created directory ‘/tmp/mylinux/var’
mkdir: created directory ‘/tmp/mylinux/var/cache’
mkdir: created directory ‘/tmp/mylinux/var/log’
mkdir: created directory ‘/tmp/mylinux/var/run’
[root@node1 ~]# tree /tmp/mylinux/
/tmp/mylinux/
├── bin
├── etc
│ └── sysconfig
│ └── network-scripts
├── sbin
├── usr
│ ├── bin
│ ├── lib
│ ├── lib64
│ ├── local
│ │ ├── bin
│ │ ├── etc
│ │ ├── lib
│ │ └── sbin
│ └── sbin
└── var
├── cache
├── log
└── run
19 directories, 0 files