Linux简单练习
1.在root用户的主目录下创建两个目录分别为haha和hehe,复制hehe目录到haha目录并重命名为apple。
[root@bogon ~]# mkdir /root/{haha,hehe}
[root@bogon ~]# cp -r /root/hehe /root/haha/apple
[root@bogon ~]# ll /root/haha
total 0
drwxr-xr-x. 2 root root 6 Feb 25 13:30 apple
2.将hehe目录移动到apple目录下,在haha目录下创建一个普通文件为heihei.txt。
[root@bogon ~]# mv /root/hehe /root/haha/apple
[root@bogon ~]# ll /root/haha/apple
total 0
drwxr-xr-x. 2 root root 6 Feb 25 13:28 hehe
[root@bogon ~]# touch /root/haha/heihei.txt
[root@bogon ~]# ll /root/haha
total 0
drwxr-xr-x. 3 root root 18 Feb 25 13:32 apple
-rw-r--r--. 1 root root 0 Feb 25 13:34 heihei.txt
3.在/usr/local/etc下创建一个目录为mulu1,创建一个普通文件为wenjian1。在/usr/local/bin创建一个目录为mulu2,创建一个普通文件为wenjian2。创建成功后使用ls命令以及它的选项来检查该题的正确性
[root@bogon ~]# mkdir /usr//local/etc/mulu1
[root@bogon ~]# touch /usr/local/etc/mulu1/wenjian1
[root@bogon ~]# mkdir /usr/local/bin/mulu2
[root@bogon ~]# touch /usr/local/bin/mulu2/wenjian2
[root@bogon ~]# ll /usr/local/etc/mulu1/
total 0
-rw-r--r--. 1 root root 0 Feb 25 13:42 wenjian1
[root@bogon ~]# ll /usr/local/bin/mulu2/
total 0
-rw-r--r--. 1 root root 0 Feb 25 13:54 wenjian2
4.创建目录/test/sysroot在该目录下创建三个文件a,b,c 之后再将sysroot目录移动到/tmp目录下改名为sys保证目录下三个文件也存在
[root@bogon ~]# touch /test/sysroot/{a,b,c}
[root@bogon ~]# mv /test/sysroot/ /tmp/sys
[root@bogon ~]# ll /tmp/sys
total 0
-rw-r--r--. 1 root root 0 Feb 25 13:59 a
-rw-r--r--. 1 root root 0 Feb 25 13:59 b
-rw-r--r--. 1 root root 0 Feb 25 13:59 c
5.删除 /tmp/sys/a 文件。
[root@bogon ~]# rm /tmp/sys/a
rm: remove regular empty file '/tmp/sys/a'? y
6.创建目录/tmp下创建4个目录,并在这四个目录下分别创建一个test目录
在[root@bogon ~]# cd /tmp
[root@bogon tmp]# mkdir -pv /1/test/2/test/3/test/4/test/
7.创建一个test目录,在该目录下创建一个文件,内容写
[root@bogon ~]# mkdir test
[root@bogon ~]# touch /test/file
[root@bogon ~]# vim /test/file
[root@bogon ~]# cat /test/file
hello!
8.在/dir下创建目录dir2和文件file1,移动文件file1到上面创建的test目录中,将目录dir2复制到test目录中
[root@bogon ~]# mkdir /dir
[root@bogon ~]# mkdir /dir/dir2
[root@bogon ~]# touch /dir/file1
[root@bogon ~]# ll /dir
total 0
drwxr-xr-x. 2 root root 6 Feb 25 14:16 dir2
-rw-r--r--. 1 root root 0 Feb 25 14:16 file1
[root@bogon ~]# mv /dir/file1 /test/
[root@bogon ~]# cp -r /dir/dir2/ /test/
[root@bogon ~]# ll /test
total 4
drwxr-xr-x. 2 root root 6 Feb 25 14:18 dir2
-rw-r--r--. 1 root root 8 Feb 25 14:13 file
-rw-r--r--. 1 root root 0 Feb 25 14:16 file1