RHCSA第三天作业

1、创建目录test

使用两种方式在test目录中创建文本文件text1.txt,text.txt

[root@localhost ~]# mkdir test
[root@localhost ~]# cd test
[root@localhost test]# touch text1.txt
[root@localhost test]# vim text.txt
[root@localhost test]# ls
text1.txt  text.txt

使用vim在文件text.txt中写入

Welcome to my Linux. ​ You are the best. ​ This is my first file to create on linux.

[root@localhost test]# vim text.txt
#进入vim编辑器后,按a键进入编辑模式,输入完成之后按Esc键退出编辑模式,再次按:wq保存并退出vim
Welcome to my Linux.
You are the best.
This is my first file to create on linux.

设置行号,并将文本中my替换成your,将文件另存为new_test1.txt

#进入vim后按:键,进入末行模式,输入set nu设置行号
#在末行模式下输入%s/my/your/g,即可将全文中的my替换成your 
#在末行模式下输入w new_test1.txt,即可将文件另存为

将test中的文件拷贝到test2目录

[root@localhost ~]# cp -a test test2

将test2目录中的text1.txt重命名为text111.txt

[root@localhost ~]# cd test2
[root@localhost test2]# mv text1.txt text111.txt

在test2目录中新建text111.txt的软链接文件test111Symb.txt

 [root@localhost test2]# ln -s text111.txt test111symb.txt

在test2目录中新建test111.tbxt的硬链接文件test111hard.txt

[root@localhost test2]# ln text111.txt test111hard.txt

删除test目录中test1.txt

[root@localhost test]# rm -rf test1.txt

删除test目录

[root@localhost ~]# rm -rf test

2、将echo"This is my first time to use pipe"内容输出到屏幕上,且保存到pipe_data.txt中

[root@localhost ~]# echo "This is my first time to use pipe" | tee pipe_data.txt
This is my first time to use pipe
[root@localhost ~]# more pipe_data.txt
This is my first time to use pipe

3、文件内容浏览

a.cat查看/etc/passwd文件内容,且输出时带行号

[root@localhost ~]# cat -n /etc/passwd

b.使用more/less查看/etc/passwd内容,且每页显示10行

more命令:
[root@localhost ~]# more -10 /etc/passwd
less命令:
[root@localhost ~]# less -10 /etc/passwd

c.使用head/tail分别查看文件前5行内容和后5行内容

head命令查看文件前5行内容:
[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
tail命令查看文件后5行内容:
[root@localhost ~]# tail -5 /etc/passwd
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:975:975::/run/gnome-initial-setup/:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
redhat:x:1000:1000:redhat:/home/redhat:/bin/bash
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值