嗨害嗨害嗨

创建临时目录
[root@localhost ~]# mkdir test
创建多个同级目录
[root@localhost ~]# touch /test/{passed,group,bashrc,profile,sshd_config}
创建软链接
[root@localhost ~]# ln -s /etc/motd /test/motd.soft
创建硬链接
[root@localhost ~]# ln /etc/motd /test/motd.hard

查看内核信息,并写入
[root@localhost ~]# cat /etc/redhat-release > /test/motd.soft 
查看主机名,并写入
[root@localhost ~]# hostname >> /test/motd.hard 
查看当前shell,并写入
[root@localhost ~]# echo ${SHELL} >> /test/motd.hard 
查看/下的文件名并写入
[root@localhost ~]# ls / > /test/file
查看当前目录
[root@localhost ~]# pwd
/root
将/test目录的详细追加写入/test/file
[root@localhost ~]# cd /test/
[root@localhost test]# ll /test/ >> /test/file 

将当前时间添加到/test下的passwd,group,bashrc,profile,sshd_config中
[root@localhost test]# date | tee /test/{passwd,group,bashrc,profile,sshd_config}
Thu Aug 18 07:28:27 CST 2022
将当前用户名追加到/test下的passwd,group,bashrc,profile,sshd_config中
[root@localhost test]# hostname | tee -a /test/{passwd,group,bashrc,profile,sshd_config}
localhost.localdomain

将/etc/passwd读入/test/passed,并修改文件的root字符为admin
[root@localhost test]#vim passwd
》:r /etc/passwd
》:set number
》:1,40 s/root/admin/g
》:wq
将/etc/group读入/test/group,只保留root开头的行内容
[root@localhost test]#vim group
》:r /etc/group
》:/root
》:4,70 d
》wq
将/etc/.bashrc读入/test/bashrc,删除#开头的内容
[root@localhost test]#vim group
》:r /etc/group
》:g/#/d
》wq
将/etc/ssh/sshd_coonfig读入/test/sshd_config,只保留root开头的行内容
[root@localhost test]#vim sshd_config
》:r /etc/ssh/sshd_coonfig
》:set number
》insert
》17 Port 22
》wq
将/test/sshd_config文件中的第40-50行的yes改为no
[root@localhost test]#vim sshd_config
》:40,50 s/yes/no/g
》:wq
将/test/sshd_config文件另存为/test/sshd.conf
[root@localhost test]#vim sshd_config
》:w /test/sshd.conf
》:wq
将/test目录下的passwd,group,bashrc文件中的第一行内容复制至文档最后一行
[root@localhost test]#vim passwd
思路:
1、先显示行号
》:set number
2、复制
    单行复制》:1 co n
    多行复制》:1,2 co n
其中1,2代表一到二行,也就是前两行,n是要复制到的行数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值