rhcsa第三天
2022年3月26日
23:41
创建目录test
使用两种方式在test目录中创建文本文件text1.txt, text2.txt
使用Vim在文件text1.txt中写入
Welcome to my Linux.
You are the best.
This is my first file to create on linux
设置行号,并将文本中my替换成your,
[root@localhost ~]# mkdir test
[root@localhost ~]# touch test2.txt
[root@localhost ~]# vim test1.txt
[root@localhost test]# cat vim test1.txt
Welcome to your Linux
You are the best
This is your firet file to create on linux
[root@localhost test]# vim new_test1.txt
[root@localhost test]# cd ~
[root@localhost ~]# ls
new_test1.txt test test1.txt test2 test2.txt
[root@localhost ~]# cp -a test /root/test2
在test2目录中新建test111.txt的软链接文件 test111_symb.txt
在test2目录中新建test111.txt的硬链接文件 test111_hard.txt
删除test目录中test1.txt
删除test目录
[root@localhost ~]# ln test111.txt test_hard.txt
[root@localhost ~]# ln test111.txt test_symb.txt
[root@localhost ~]# cd test
[root@localhost test]# rm -rf test1.txt
[root@localhost test]# cd ~
[root@localhost ~]# rm -rf test
[root@localhost ~]#
将echo "This is my first time to use pipe"内容输出到屏幕上,且保存到pipe_data.txt中
[root@localhost ~]# echo This is my first time to use pipe
This is my first time to use pipe
[root@localhost ~]# touch pipe_data.txt
[root@localhost ~]# vim pipe_data.txt
a.cat查看/etc/passwd文件内容,且输出时带行号
b.使用more/less查看/etc/passwd内容,且每页显示10行
c.使用head/tail分别查看文件前5行内容和后5行内容
[root@localhost ~]# cat -n /etc/passwd | more -10
1 root:x:0:0:root:/root:/bin/bash
2 bin:x:1:1:bin:/bin:/sbin/nologin
3 daemon:x:2:2:daemon:/sbin:/sbin/nologin
4 adm:x:3:4:adm:/var/adm:/sbin/nologin
5 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6 sync:x:5:0:sync:/sbin:/bin/sync
7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
8 halt:x:7:0:halt:/sbin:/sbin/halt
9 mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
10 operator:x:11:0:operator:/root:/sbin/nologin
[root@localhost ~]# head -5 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
[root@localhost ~]# tail -5 /etc/passwd
gnome-initial-setup:x:979:977::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
hanzebin:x:1000:1000:hanzebin:/home/hanzebin:/bin/bash