Linux简单命令

1 、创建文件命令练习:
1 ) 在 / 目录下创建一个临时目录 test
2 )在临时目录 test 下创建五个文件,文件名分别为 passwd group bashrc profile
sshd_config
3 )在 /test 创建 /etc/motd 的软链接,文件名为 motd.soft; 创建 /etc/motd 的硬链接为 motd.hard

 

2 、重定向练习:
1 )将系统内核版本信息,发行版本信息,写入到 /test/motd.soft 文件中
2 )将当前主机主机名,当前用户使用的 shell 信息追加到 /test/motd.hard 文件中
3 )将根目录下的文件的文件名写入 /test/file 文件中
4 )查看当前工作目录是否为 /test 目录,将当前工作目录的详细信息追加到 /test/file 文件中
 
[root@localhost test]# cat /etc/redhat-release > /test/motd.soft
[root@localhost test]# uname -r >> /test/motd.soft


 

 

3 tee 命令练习:
1 )将当前时间添加至 /test 目录下的 passwd group bashrc profile sshd_config 文件中
2 )将当前用户的用户名追加至 /test 目录下的 passwd group bashrc profile sshd_config 文件 中
[root@localhost test]# date | tee /test/passwd /test/group /test/bashrc /test/profile /test/sshd_config
Wed Aug 17 20:00:24 CST 2022

[root@localhost test]# hostname | tee -a /test/passwd /test/group /test/bashrc /test/profile /test/sshd_config
localhost.localdomain

4 vim 命令练习:
1 )将 /etc/passwd 文件内容读入 /test/passwd ,并修改文件里的 root 字符为 admin
2 )将 /etc/group 文件内容读入 /test/group ,只保留 root 开头的行内容
3 )将 /root/.bashrc 文件内容读入 /test/bashrc ,删除 # 号开头的行内容
4 )将 /etc/ssh/sshd_config 文件内容读入 /test/sshd_config, 在该文件的第 17 行后添加一行内容
Port 22
5 )将 /test/sshd_config 文件中的第 40-50 行的 yes 改为 no
6 )将 /test/sshd_config 文件另存为 /test/sshd.conf
7 )将 /test 目录下的 passwd group bashrc 文件中的第一行内容复制至文档最后一行
8 )将 /test 目录下的 profile sshd_config 文件中前两行内容复制至文档倒数第二行
(1):%s/root/admin/g
(2)2,72 d
(3):g/#/d
 (4) :set nu 17G 添加   
(5):set nu 
      :40,50 s/yes/no/g
 (6):w /test/sshd.config
 (7) yy G p
 (8) yy p

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值