RHCSA作业2
压缩
将整个 /etc 目录下的文件全部打包并用 gzip 压缩成/back/etcback.tar.gz
[root@jyh ~]# cd /etc
[root@jyh etc]# tar -czf etcback.tar.gz /etc
tar: Removing leading `/' from member names
tar: /etc/etcback.tar.gz: file changed as we read it
[root@jyh etc]# ls
使当前用户永久生效的命令别名
写一个命令命为hello,实现的功能为每输入一次hello命令,就有hello,everyone写入文件/file.txt中
[root@jyh etc]# echo "echo 'hello,everyone'>> /file.txt" >> ~/.bashrc
[root@jyh etc]# alias hello="echo 'hello,everyone'>>/file.txt"
[root@jyh etc]# source ~/.bashrc
[root@jyh etc]# alias
用户和组的管理
创建mygroup组群,再创建myuser用户,并且此用户属于mygroup组群,接着以myuser身份登录,创建ex和hv两个文件于/home/myuser目录,并使hv文件的同组用户是root。请依次写出相应执行的命令
[root@jyh ~]# groupadd mygroup
[root@jyh ~]# useradd -m -G mygroup myuser
[root@jyh ~]# passwd myuser
Changing password for user myuser.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[myuser@jyh root]$ pwd
/root
[myuser@jyh root]$ su myuser
Password:
[myuser@jyh root]$ pwd
/root
[myuser@jyh root]$ cd /home/myuser
[myuser@jyh ~]$ pwd
/home/myuser
[myuser@jyh ~]$ touch ex hv
[myuser@jyh ~]$ ls
ex hv
[myuser@jyh ~]$ sudo chgrp root hv
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for myuser:
myuser is not in the sudoers file. This incident will be reported.
[myuser@jyh ~]$ ls -l hv
-rw-rw-r--. 1 myuser myuser 0 Nov 25 21:37 hv
[myuser@jyh ~]$ groupadd -a redhat g1
groupadd: invalid option -- 'a'
Usage: groupadd [options] GROUP
Options:
-f, --force exit successfully if the group already exists,
and cancel -g if the GID is already used
-g, --gid GID use GID for the new group
-h, --help display this help message and exit
-K, --key KEY=VALUE override /etc/login.defs defaults
-o, --non-unique allow to create groups with duplicate
(non-unique) GID
-p, --password PASSWORD use this encrypted password for the new group
-r, --system create a system account
-R, --root CHROOT_DIR directory to chroot into
-P, --prefix PREFIX_DI directory prefix
-U, --users USERS list of user members of this group
[myuser@jyh ~]$ touch redhat.txt
[myuser@jyh ~]$ ls
ex hv redhat.txt
[myuser@jyh ~]$ groupadd g1
groupadd: Permission denied.
groupadd: cannot lock /etc/group; try again later.
[myuser@jyh ~]$ touch /home/myuser/redhat.txt
[myuser@jyh ~]$ chown redhat g1 /home/myuser/redhat.txt
chown: cannot access 'g1': No such file or directory
chown: changing ownership of '/home/myuser/redhat.txt': Operation not permitted
设置权限
创建g1组,要求创建一个属于redhat用户g1组的文件redhat.txt
[myuser@jyh ~]$ chmod 640 /home/myuser/redhat.txt
原文地址:https://blog.csdn.net/liuxini2251/article/details/144040592
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!