作业3

1. 在终端中显示当前系统时间,时间格式为月日时

[root@localhost ~]# date | cut -d " " -f 2-4
Mar 20 16:05:53

2. 截取当前日期的年月日显示在文件A.txt 中

[root@localhost ~]# date | cut -d " " -f 2,3,6 > A.txt
[root@localhost ~]# cat A.txt
Mar 20 2021

3. 用户配置文件将3,4 字段分别截取出来写入文件UID和文件GIU但是要使这两个文件中的信息是以数值由大到小的形式显示;

[root@localhost ~]# cut -d : -f 3 /etc/passwd | sort -n > UID
[root@localhost ~]# cut -d : -f 4 /etc/passwd | sort -n > GID
[root@localhost ~]# paste UID GID
0 0
1 0
2 0
3 0
4 0
5 1
6 2
7 4
8 7
11 12
12 29
14 32
29 42
32 50
42 59
59 70
70 72
72 74
74 75
75 76
81 81
107 100
113 107
171 113
172 171
193 172
976 193
977 974
978 975
979 976
980 977
981 978
982 979
983 980
984 982
990 984
991 985
992 986
993 988
994 989
995 990
996 992
997 995
998 996
999 997
1000 1000
65534 65534

4. 通过一句话在当前终端显示当前系统一共有多少用户;

[root@localhost ~]# wc -l /etc/passwd | cut -d " " -f 1
47

5. 将当前系统root用户执行频率最高的三个命令显示在终端; ~/.bash_history

[root@localhost ~]# cat ~/.bash_history |cut -d " " -f 1 | uniq -c | sort -n | tail
-1
13 date

6. 将当前系统的ip地址查看显示在终端

[root@localhost ~]# ifconfig ens160 | head -2 |tail -1 |cut -d t -f 2 | cut -d " " -f 2
192.168.170.128

[root@localhost ~]# ifconfig ens160 | grep -w inet | tr -s " " | cut -d " " -f 3
192.168.170.128

7. 编辑一个文件file,内容为helloworld,通过字符替换方式将文件内容小写字符替换为大写字符写入newfile文件。

[root@localhost ~]# cat file
helloward
[root@localhost ~]# cat file | tr a-z A-Z > newfile
[root@localhost ~]# cat newfile
HELLOWARD

8. 将/etc/login.defs文件中有PASS关键字的行过滤出来,按文件原顺序显示在file文件。

[root@localhost ~]# cat /etc/login.defs | grep pass > file
[root@localhost ~]# cat file

passwd command) should therefore be configured elsewhere. Refer to

PASS_MAX_DAYS Maximum number of days a password may be used.

PASS_MIN_DAYS Minimum number of days allowed between password changes.

PASS_MIN_LEN Minimum acceptable password length.

PASS_WARN_AGE Number of days warning given before a password expires.

the user to be removed (passed as the first argument).

Use SHA512 to encrypt password.

创建学习组1,学习组2 ;他们的组gid分别1111,2222,添加成员并将uid为1088,和uid为1066的成员为两组的组长,其中一组组长有一个‘外号’(描述名称)laoda。不同学习组进入需要密码才能进入(设置密码);即使密码泄露也不希望组之外的成员进入。

[root@localhost ~]# groupadd -g 1111 group1
[root@localhost ~]# groupadd -g 2222 group2
[root@localhost ~]# useradd -u 1066 u1
[root@localhost ~]# useradd -u 1088 u2
[root@localhost ~]# usermod -c laoda u1
[root@localhost ~]# usermod -G group1 u1
[root@localhost ~]# usermod -G group2 u2
[root@localhost ~]# gpasswd -a u1 group1
Adding user u1 to group group1
[root@localhost ~]# gpasswd -a u2 group2
Adding user u2 to group group2
[root@localhost ~]# gpasswd -A u2 group2
[root@localhost ~]# gpasswd -A u1 group1
[root@localhost ~]# gpasswd group1
Changing the password for group group1
New Password:
Re-enter new password:
[root@localhost ~]# gpasswd -R group1
[root@localhost ~]# gpasswd -r group1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值