创建一个名为user1的用户,并用root身份给它修改密码为redhat
创建名为user1的用户:
[root@HLQ ~]# useradd user1
用root身份给它修改密码为redhat:
[root@HLQ ~]# echo redhat | passwd --stdin user1
查找系统中所有与passwd关键词相关的man 帮助章节:
[root@HLQ ~]# man -k passwd
chgpasswd (8) - update group passwords in batch mode
chpasswd (8) - update passwords in batch mode
fgetpwent_r (3) - get passwd file entry reentrantly
getpwent_r (3) - get passwd file entry reentrantly
gpasswd (1) - administer /etc/group and /etc/gshadow
grub2-mkpasswd-pbkdf2 (1) - Generate a PBKDF2 password hash.
htpasswd (1) - Manage user files for basic authentication
ldappasswd (1) - change the password of an LDAP entry
lpasswd (1) - Change group or user password
mkpasswd (1) - generate new password, optionally apply i...
openssl-passwd (1ssl) - compute password hashes
pam_localuser (8) - require users to be listed in /etc/passwd
passwd (1) - update user's authentication tokens
passwd (5) - password file
passwd2des (3) - RFS password encryption
pwhistory_helper (8) - Helper binary that transfers password has...
saslpasswd2 (8) - set a user's sasl password
smbpasswd (5) - The Samba encrypted password file
smbpasswd (8) - change a user's SMB password
sslpasswd (1ssl) - compute password hashes
userpasswd (1) - A graphical tool to allow users to change...
vncpasswd (1) - change the VNC password
分别写出man帮助的第1,5,8章节是做什么的?
第一章节:命令的语法,针对所有用户
第五章节:查看配置文件的语法规则
第八章节:只有root可以执行的命令的语法规则
创建一个目录/data
[root@HLQ ~]# mkdir /data
将 /etc/目录拷贝到data 并且重命名为 config
[root@HLQ ~]# cp -r /etc/ /data/config
[root@HLQ ~]# ls /data/
[root@HLQ ~]# ll /data/config/
将config 目录中的shadow 文件拷贝/tmp
[root@HLQ ~]# cp -r /data/config/shadow /tmp
将config 下的shadow文件更名为password
[root@HLQ ~]# cp -r /data/config/shadow /tmp
[root@HLQ ~]# mv /data/config/shadow /data/config/password
[root@HLQ ~]# ls /data/config/pass*
更新/etc/目录下面所有文件的时间戳(注意不是/etc目录本身的时间戳)
[root@HLQ ~]# stat /etc/passwd
File: /etc/passwd
Size: 3120 Blocks: 8 IO Block: 4096 regular file
Device: fd03h/64771d Inode: 25746907 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:passwd_file_t:s0
Access: 2021-06-03 21:58:42.329741116 +0800
Modify: 2021-06-03 21:58:42.309741599 +0800
Change: 2021-06-03 21:58:42.311741551 +0800
Birth: -
[root@HLQ ~]# touch /etc/
[root@HLQ ~]# stat /etc/
File: /etc/
Size: 12288 Blocks: 32 IO Block: 4096 directory
Device: fd03h/64771d Inode: 25165952 Links: 159
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:etc_t:s0
Access: 2021-06-03 23:39:37.703152403 +0800
Modify: 2021-06-03 23:39:37.703152403 +0800
Change: 2021-06-03 23:39:37.703152403 +0800
Birth: -
在/tmp下创建一个空文件test1,并且通过文本编辑器来验证时间戳的更改
[root@HLQ ~]# touch /tmp/test1
[root@HLQ ~]# stat /tmp/t
test1 tracker-extract-files.0/
[root@HLQ ~]# stat /tmp/test1
File: /tmp/test1
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd03h/64771d Inode: 54776057 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2021-06-03 23:42:24.299865758 +0800
Modify: 2021-06-03 23:42:24.299865758 +0800
Change: 2021-06-03 23:42:24.299865758 +0800
Birth: -
[root@HLQ ~]# echo 111 >> /tmp/test1
[root@HLQ ~]# cat /tmp/test1
111
[root@HLQ ~]# stat /tmp/test1
File: /tmp/test1
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd03h/64771d Inode: 54776057 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2021-06-03 23:43:34.689516459 +0800
Modify: 2021-06-03 23:43:33.186545156 +0800
Change: 2021-06-03 23:43:33.186545156 +0800
Birth: -
清空/tmp目录
[root@HLQ ~]# rm -rf /tmp/*
[root@HLQ ~]# ls /tmp
[root@HLQ ~]#
给/data目录改名,更名为RHCE
[root@HLQ ~]# mv /data /RHCE
[root@HLQ ~]# ls /
bin dev home lib64 mnt proc root sbin sys usr
boot etc lib media opt RHCE run srv tmp var
创建目录/tmp/a/b/c/d/e/f这样的目录树结构
[root@HLQ ~]# mkdir -pv /tmp/a/b/c/d/e/f
mkdir: created directory '/tmp/a'
mkdir: created directory '/tmp/a/b'
mkdir: created directory '/tmp/a/b/c'
mkdir: created directory '/tmp/a/b/c/d'
mkdir: created directory '/tmp/a/b/c/d/e'
mkdir: created directory '/tmp/a/b/c/d/e/f'
[root@HLQ ~]#
将/usr/share/doc/zip目录下的所有文件拷贝至/tmp
[root@HLQ ~]# cp -r /usr/share/doc/zip/* /tmp
[root@HLQ ~]# ls /tmp
a algorith.txt CHANGES README README.CR TODO WHATSNEW WHERE
[root@HLQ ~]# ls /usr/share/doc/zip/
algorith.txt CHANGES README README.CR TODO WHATSNEW WHERE
[root@HLQ ~]#
查看/etc/profile 文件的时间戳。并尝试用touch修改A time和M time
[root@HLQ ~]# stat /etc/profile
File: /etc/profile
Size: 2078 Blocks: 8 IO Block: 4096 regular file
Device: fd03h/64771d Inode: 25311382 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:etc_t:s0
Access: 2021-06-03 23:39:17.070559446 +0800
Modify: 2021-06-03 23:39:17.070559446 +0800
Change: 2021-06-03 23:39:17.070559446 +0800
Birth: -
[root@HLQ ~]# touch /etc/profile
[root@HLQ ~]# stat /etc/profile
File: /etc/profile
Size: 2078 Blocks: 8 IO Block: 4096 regular file
Device: fd03h/64771d Inode: 25311382 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:etc_t:s0
Access: 2021-06-03 23:58:27.486468339 +0800
Modify: 2021-06-03 23:58:27.486468339 +0800
Change: 2021-06-03 23:58:27.486468339 +0800
Birth: -
用file查看文件/etc/profile的文件类型
[root@HLQ ~]# file /etc/profile
/etc/profile: ASCII text
————————————————
版权声明:本文为CSDN博主「m0_54176769」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_54176769/article/details/117536025