셋째 주 공부

1. / etc 디렉토리를 표시하고 문자가 아닌 문자로 시작하고 그 뒤에 문자 및 길이와 문자의 기타 파일 또는 디렉토리를 표시합니다.

[root @ txcentos7 etc] # touch 15 
[root @ txcentos7 etc] # touch 1aa 
[root @ txcentos7 etc] # ls -d / etc / [^ [: alpha :]] [[: alpha :]] * 
/ etc / 1a / etc / 1aa

2. / etc 디렉토리에서 p로 시작하고 숫자가 아닌 모든 파일 또는 디렉토리를 / tmp / mytest1 디렉토리로 복사합니다.

[root @ txcentos7 tmp] # cp -a / etc / p * [^ 0-9] / tmp / mytest1 / 
[root @ txcentos7 tmp] # ls / tmp / mytest1 / 
pam.d passwd- plymouth popt.d ppp printcap profile.d python 
passwd pki pm postfix prelink.conf.d 프로파일 프로토콜

3. / etc / issue 파일의 내용을 대문자로 변환하고 /tmp/issue.out 파일에 저장합니다.

[root @ txcentos7 tmp] # cat / etc / issue | tr "az" "AZ">> / tmp / ussue.out 
[root @ txcentos7 tmp] # cat /tmp/ussue.out 
\ S 
커널 \ R ON AN \ M

4. 사용자 및 그룹 관리 명령을 사용하는 방법을 요약하고 설명하고 다음 연습을 완료하십시오.
(1) 2019 년 GID로 그룹 배포판을 만듭니다.

[[email protected] / root] groupadd -g 2019 배포판

(2) ID 번호가 1005 인 사용자 mandriva를 생성하고 기본 그룹은 distro입니다.

[[email protected] / root] useradd mandriva -u 1015 -g distro 
[[email protected] / root] cat / etc / passwd | egrep mandriva 
mandriva : x : 1015 : 2019 :: / home / mandriva : / bin / bash 
[[email protected] / root] groups mandriva 
mandriva : distro

(3) ID 번호가 1100이고 홈 디렉토리가 / home / linux 인 사용자 mageia를 만듭니다.

[root @ txcentos7 ~] # useradd mageia -d / home / linux -u 1100 
[root @ txcentos7 ~] # cat / etc / passwd | egrep mageia 
mageia : x : 1100 : 1100 :: / home / linux : / bin / bash 
[root @ txcentos7 home] # ls / home 
linux mandriva tommy tt username wang wang1 wwwww

(4) 사용자 mageia에 암호를 추가하고 암호는 mageedu이며 사용자 암호가 7 일 후에 만료되도록 설정합니다.

[root @ txcentos7 home] # echo mageedu | passwd --stdin mageia mageia 
사용자의 암호를 변경합니다. 
passwd : 모든 인증 토큰이 성공적으로 업데이트되었습니다. 
[root @ txcentos7 home] # passwd mageia -x 7 
사용자 mageia에 대한 에이징 데이터 조정. 
passwd : Success 
# 列出 密码 有效期 : 
[root @ txcentos7 home] # chage -l mageia 
마지막 암호 변경 : 2021 년 3 월 22 일 
암호 만료 : 2021 년 3 월 29 일 
암호 비활성 : 
없음 계정 만료 : 없음 
암호 변경 사이의 최소 일수 : 0 
암호 변경 사이의 최대 일수 : 7
암호 만료 전 경고 일수 : 7

(5), mandriva를 삭제하고 홈 디렉토리는 유지하십시오.

[root @ txcentos7 home] # userdel mageia

(6) ID 번호가 2002이고 기본 그룹이 distro이고 추가 그룹이 peguin 인 사용자 슬랙웨어를 만듭니다.

[root @ txcentos7 home] # groupadd peguin 
[root @ txcentos7 home] # useradd slackware -u 2002 -g distro -G peguin 
[root @ txcentos7 home] # groups slackware 
slackware : distro peguin

(7), 슬랙웨어의 기본 쉘을 / bin / tcsh로 수정합니다.

[root @ txcentos7 home] # usermod -s / bin / tcsh slackware 
[root @ txcentos7 home] # cat / etc / passwd | egrep 슬랙웨어 
슬랙웨어 : x : 2002 : 2019 :: / home / slackware : / bin / tcsh

(8) 사용자 슬랙웨어에 대한 그룹 관리자를 추가하고 로그인하지 않도록 설정합니다.

[root @ txcentos7 home] # id slackware 
uid = 2002 (slackware) gid = 2019 (distro) groups = 2019 (distro), 2020 (peguin), 2021 (admins) 

[root @ txcentos7 sbin] # usermod slackware -s / sbin / nologin 
[root @ txcentos7 sbin] # echo mageedu | passwd --stdin slackware 
사용자 slackware의 비밀번호 변경. 
passwd : 모든 인증 토큰이 성공적으로 업데이트되었습니다. 
경고! 원격 SSH 서버가 X11 전달 요청을 거부했습니다. 
마지막 로그인 : Mon Mar 22 22:02:57 2021 from 111.196.233.254 
이 계정은 현재 사용할 수 없습니다. 
연결 닫힘 ... 소켓 닫힘. 

외부 호스트에 의해 연결이 닫혔습니다.

5. 사용자 user1, user2 및 user3을 만듭니다. / data / 아래에 디렉터리 테스트를 만듭니다.

(1), 디렉토리 / data / test의 소유자, 그룹은 user1입니다.

[root @ txcentos7 data] # chown user1 : user1 test 
[root @ txcentos7 data] # ll -t 
total 28 
drwxr-xr-x 2 user1 user1 4096 Mar 22 22:05 test

(2) User2는 디렉토리의 소유자와 그룹이 변경되지 않은 경우 파일에 대한 읽기 및 쓰기 권한을가집니다.

[root @ txcentos7 data] # chmod o + rw test 
[root @ txcentos7 data] # ll -t 
total 28 
drwxr-xrwx 2 user1 user1 4096 Mar 22 22:05 test 

[root @ txcentos7 data] # su user2 
[user2 @ txcentos7 data] $ cd / data / 
[user2 @ txcentos7 data] $ ls 
1111 laji lajixiang nianling.txt script test vkokdfs 
[user2 @ txcentos7 data] $ cd test / 
[user2 @ txcentos7 test] $ touch 10.txt 
[user2 @ txcentos7 test ] $ ll 
총 0 
-rw-rw-r-- 1 user2 user2 0 Mar 22 22:11 10.txt

(3) User1은 / data / test 디렉토리에 a1.sh, a2.sh, a3.sh, a4.sh 파일을 생성하고 user1과 root를 제외한 모든 사용자가 1.sh, 2.sh 파일을 삭제할 수 없도록 설정합니다. 또한 모든 사용자는 a3.sh, a4.sh를 삭제할 수 없습니다.

[user1 @ txcentos7 test] $ touch a {1..4} \. sh 
[user1 @ txcentos7 test] $ ls 
a1.sh a2.sh a3.sh a4.sh 

모든 사용자를 삭제할 수없는 경우 일반 사용자는 cahttr을 실행할 수 없습니다. + 명령합니다, 다른 방법이 있습니까? 
[root @ txcentos7 test] # chattr + i a1.sh 
[root @ txcentos7 test] # chattr + i a2.sh 
[root @ txcentos7 test] # lsattr 
------------- e-- ./a3.sh 
------------- e-- ./a4.sh 
---- i -------- e-- ./a1.sh 
--- -i -------- e-- ./a2.sh

(4) user1 그룹을 user3에 추가하고 user1이 / data / test 디렉토리 및 그 아래의 모든 파일에 액세스하지 않도록 요구합니다.

[root @ txcentos7 테스트] # usermod user3 -aG user1 
[root @ txcentos7 test] # id user3 
uid = 2006 (user3) gid = 2006 (user3) groups = 2006 (user3), 2004 (user1) 

setfacl -mu : user1 : -/ data / test / 
[root @ txcentos7 test] # su user1 
[user1 @ txcentos7 test] $ cd / data / test / 
bash : cd : / data / test / : Permission denied


(5) / data / test 디렉토리와 그 아래에있는 모든 파일의 acl 권한을 정리합니다.

[root @ txcentos7 테스트] # setfacl -R -b / data / test /


추천

출처blog.51cto.com/15132577/2668894