RHCSA 第二天

一、Linux命令练习

1. 在root用户的主目录下创建两个目录分别为haha和hehe,复制hehe目录到haha目录并重命名为apple。

[root@localhost ~]# mkdir haha hehe
[root@localhost ~]# cp -r /root/hehe /root/haha
[root@localhost ~]# cd haha
[root@localhost haha]# mv hehe apple
[root@localhost haha]# ls
apple

2. 将hehe目录移动到apple目录下,在haha目录下创建一个普通文件为heihei.txt。

[root@localhost haha]# mv /root/hehe/ /root/haha/apple/
[root@localhost haha]# touch heihei.txt
[root@localhost haha]# ls
apple  heihei.txt

3. 在/usr/local/etc下创建一个目录为mulu1,创建一个普通文件为wenjian1。在/usr/local/bin创建一个目录为mulu2,创建一个普通文件为wenjian2。创建成功后使用ls命令以及它的选项来检查该题的正确性

[root@localhost haha]# alias aoe=ll
[root@localhost haha]# aoe
总用量 0
drwxr-xr-x. 2 root root 6 9月  11 17:16 apple
-rw-r--r--. 1 root root 0 9月  11 17:25 heihei.txt

4. 创建目录/test/sysroot在该目录下创建三个文件a,b,c 之后再将sysroot目录移动到/tmp目录下改名为sys保证目录下三个文件也存在

[root@localhost ~]# mkdir -p /test/sysroot
[root@localhost ~]# mkdir -pv /test/sysroot
[root@localhost ~]# cd /test/sysroot
[root@localhost sysroot]# touch a b c
[root@localhost sysroot]# ll
总用量 0
-rw-r--r--. 1 root root 0 9月  11 17:37 a
-rw-r--r--. 1 root root 0 9月  11 17:37 b
-rw-r--r--. 1 root root 0 9月  11 17:37 c
[root@localhost sysroot]# mv /test/sysroot/ /tmp
[root@localhost sysroot]# cd /tmp
[root@localhost tmp]# ll
总用量 16
-rw-r--r--. 1 root root 3050 9月   6 07:37 anaconda.log
-rw-r--r--. 1 root root 2942 9月   6 07:35 dbus.log
-rw-r--r--. 1 root root    0 9月   6 07:35 ifcfg.log
-rwx------. 1 root root 1379 9月   6 07:34 ks-script-wgqp2cby
-rw-r--r--. 1 root root    0 9月   6 07:35 packaging.log
-rw-r--r--. 1 root root  403 9月   6 07:37 program.log
-rw-r--r--. 1 root root    0 9月   6 07:35 sensitive-info.log
-rw-r--r--. 1 root root    0 9月   6 07:35 storage.log
drwxr-xr-x. 2 root root   33 9月  11 17:37 sysroot
[root@localhost tmp]# mv sysroot sys
[root@localhost tmp]# ll
总用量 16
-rw-r--r--. 1 root root 3050 9月   6 07:37 anaconda.log
-rw-r--r--. 1 root root 2942 9月   6 07:35 dbus.log
-rw-r--r--. 1 root root    0 9月   6 07:35 ifcfg.log
-rwx------. 1 root root 1379 9月   6 07:34 ks-script-wgqp2cby
-rw-r--r--. 1 root root    0 9月   6 07:35 packaging.log
-rw-r--r--. 1 root root  403 9月   6 07:37 program.log
-rw-r--r--. 1 root root    0 9月   6 07:35 sensitive-info.log
-rw-r--r--. 1 root root    0 9月   6 07:35 storage.log
drwxr-xr-x. 2 root root   33 9月  11 17:37 sys
[root@localhost tmp]# ll sys
总用量 0
-rw-r--r--. 1 root root 0 9月  11 17:37 a
-rw-r--r--. 1 root root 0 9月  11 17:37 b
-rw-r--r--. 1 root root 0 9月  11 17:37 c

5. 删除 /tmp/sys/a 文件。

[root@localhost ~]# rm -f /tmp/sys/a
[root@localhost ~]# ll /tmp/sys
总用量 0
-rw-r--r--. 1 root root 0 9月  11 17:37 b
-rw-r--r--. 1 root root 0 9月  11 17:37 c

6. 创建目录/tmp下创建4个目录,并在这四个目录下分别创建一个test目录

[root@localhost ~]# mkdir -pv /tmp/{1/test,2/test,3/test,4/test}
mkdir: 已创建目录 '/tmp/1'
mkdir: 已创建目录 '/tmp/1/test'
mkdir: 已创建目录 '/tmp/2'
mkdir: 已创建目录 '/tmp/2/test'
mkdir: 已创建目录 '/tmp/3'
mkdir: 已创建目录 '/tmp/3/test'
mkdir: 已创建目录 '/tmp/4'
mkdir: 已创建目录 '/tmp/4/test'
[root@localhost ~]# tree /tmp
/tmp
├── 1
│   └── test
├── 2
│   └── test
├── 3
│   └── test
├── 4
│   └── test
├── anaconda.log
├── dbus.log
├── ifcfg.log
├── ks-script-wgqp2cby
├── packaging.log
├── program.log
├── sensitive-info.log
├── storage.log
├── sys
│   ├── b
│   └── c
├── systemd-private-c93c4bf2fdc8468a9e447c84f4982ca8-bluetooth.service-E1vsOs
│   └── tmp
├── systemd-private-c93c4bf2fdc8468a9e447c84f4982ca8-bolt.service-Rgp9dA
│   └── tmp
├── systemd-private-c93c4bf2fdc8468a9e447c84f4982ca8-chronyd.service-yk6Hm3
│   └── tmp
├── systemd-private-c93c4bf2fdc8468a9e447c84f4982ca8-colord.service-LZcPoY
│   └── tmp
├── systemd-private-c93c4bf2fdc8468a9e447c84f4982ca8-fwupd.service-qACs9n
│   └── tmp
├── systemd-private-c93c4bf2fdc8468a9e447c84f4982ca8-geoclue.service-ux8u5L
│   └── tmp
├── systemd-private-c93c4bf2fdc8468a9e447c84f4982ca8-ModemManager.service-q2iSoS
│   └── tmp
├── systemd-private-c93c4bf2fdc8468a9e447c84f4982ca8-rtkit-daemon.service-dFyOdE
│   └── tmp
├── tracker-extract-files.1000
├── vmware-root_1005-4290625330
├── vmware-root_1017-4248221863
└── vmware-root_980-2957518026

29 directories, 10 files

7. 创建一个test目录,在该目录下创建一个文件,内容写

[root@localhost test]# cat /test/aiduo
[root@localhost test]# nano aiduo

8. 在/dir下创建目录dir2和文件file1,移动文件file1到上面创建的test目录中,将目录dir2复制到test目录中

[root@localhost ~]# mkdir /dir
[root@localhost ~]# cd /dir
[root@localhost dir]# mkdir dir2 file1
[root@localhost dir]# mv file1 /test
[root@localhost dir]# 
[root@localhost dir]# cp -r dir2 /test
[root@localhost dir]# ll
总用量 0
drwxr-xr-x. 2 root root 6 9月  11 18:11 dir2
[root@localhost dir]# cd /test
[root@localhost test]# ll
总用量 4
-rw-r--r--. 1 root root 0 9月  11 17:55  aiduo
drwxr-xr-x. 2 root root 6 9月  11 18:06  dir2
drwxr-xr-x. 2 root root 6 9月  11 18:11  file1
drwxr-xr-x. 2 root root 6 9月  11 17:35  sysyroot

猜你喜欢

转载自blog.csdn.net/weixin_45756724/article/details/108541705