小试牛刀-命令练习(1)
使用命令行展开功能,创建/tmp/a1, /tmp/a2, /tmp/a1/a, /tmp/a1/b
[root@localhost ~]# mkdir -p /tmp/{a1/{a,b},a2} [root@localhost ~]# ls -R /tmp /tmp: a1 a2 /tmp/a1: a b /tmp/a1/a: /tmp/a1/b: /tmp/a2:
[root@localhost ~]#
在/tmp目录下创建目录:x_y, x_z, q_y, q_z
[root@localhost ~]# mkdir -p /tmp/{x,q}_{y,z} [root@localhost ~]# ls -R /tmp /tmp: q_y q_z x_y x_z /tmp/q_y: /tmp/q_z: /tmp/x_y: /tmp/x_z: [root@localhost ~]#
在/tmp目录下创建以tfile开头,后跟当前日期和时间的文件,文件名形如:tfile-2016-05-27-09-32-22
[root@localhost ~]# touch /tmp/tfile-`date +%Y-%m-%d-%H-%M-%S` [root@localhost ~]# ls -R /tmp /tmp: tfile-2019-10-11-18-18-05 [root@localhost ~]#
复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。
[root@localhost ~]# mkdir -p /tmp/mytest1 [root@localhost ~]# cp -r /etc/p*[^0-9] /tmp/mytest1 [root@localhost ~]# [root@localhost ~]# ls -al /tmp/mytest1/ total 528 drwxr-xr-x 15 root root 4096 Oct 11 18:24 . drwxrwxrwt 3 root root 4096 Oct 11 18:23 .. drwxr-xr-x 2 root root 4096 Oct 11 18:24 pam.d drwxr-xr-x 3 root root 4096 Oct 11 18:24 pango -rw-r--r-- 1 root root 1925 Oct 11 18:24 passwd -rw-r--r-- 1 root root 1882 Oct 11 18:24 passwd- -rw-r--r-- 1 root root 1362 Oct 11 18:24 pbm2ppa.conf drwxr-xr-x 2 root root 4096 Oct 11 18:24 pcmcia -rw-r--r-- 1 root root 2872 Oct 11 18:24 pinforc drwxr-xr-x 10 root root 4096 Oct 11 18:24 pki drwxr-xr-x 2 root root 4096 Oct 11 18:24 plymouth drwxr-xr-x 5 root root 4096 Oct 11 18:24 pm -rw-r--r-- 1 root root 370 Oct 11 18:24 pm-utils-hd-apm-restore.conf -rw-r--r-- 1 root root 6300 Oct 11 18:24 pnm2ppa.conf drwxr-xr-x 2 root root 4096 Oct 11 18:24 popt.d drwxr-xr-x 2 root root 4096 Oct 11 18:24 portreserve drwxr-xr-x 2 root root 4096 Oct 11 18:24 postfix drwxr-xr-x 3 root root 4096 Oct 11 18:24 ppp -rw-r--r-- 1 root root 427855 Oct 11 18:24 prelink.cache -rw-r--r-- 1 root root 789 Oct 11 18:24 prelink.conf drwxr-xr-x 2 root root 4096 Oct 11 18:24 prelink.conf.d -rw-r--r-- 1 root root 233 Oct 11 18:24 printcap -rw-r--r-- 1 root root 2116 Oct 11 18:24 profile drwxr-xr-x 2 root root 4096 Oct 11 18:24 profile.d -rw-r--r-- 1 root root 6455 Oct 11 18:24 protocols drwxr-xr-x 2 root root 4096 Oct 11 18:24 pulse [root@localhost ~]#
创建用户tom,指定UID为5001,指定家目录为/tmp/tom, 指定shell为/bin/zsh, 指定基本组为tom,附加组为jack
[root@jod-service2 tmp]# [root@jod-service2 tmp]# groupadd jack [root@jod-service2 tmp]# useradd tom -u 5001 -d /tmp/tom -G jack -s /bin/zsh [root@jod-service2 tmp]# cat /etc/passwd |grep tom tom:x:5001:5001::/tmp/tom:/bin/zsh [root@jod-service2 tmp]#