참고 : 2023.03.28 - [네트워크 수업/리눅스] - 사용자계정.pdf
[root@centos7 ~]# cat /etc/passwd | more ==> |(파이프)는 앞 명령어 실행하고 뒤에거 실행해다오 라는 뜻
root:x:0:0:root:/root:/bin/bash ==> x가 패스워드(우리는 못알아봄) : 0은 user아이디 : 그다음0은 admin아이디 : root는 코맨트 : /root는 root사용자가 쓰는 홈디렉터리 : /bin/bash 는 명령어 해석기 shell중에 bone again shell을 쓴다.
[root@centos7 ~]# cat /etc/shadow | more ==>보안을 요하는 특수계정이 여기에 들어있다.
root:$6$pwFHMPUP5SAhjihb$jbphBZa2U4twRs6wKhDnmUiZUem4CjSZoxNMQbr.wMwkoFwHXfLU
5Be3gXbl.uXe0qGWb/ZjcQ3QNTPfuDj.l0::0:99999:7::: ==> root 는 사용자계정명, 그다음 암호화가 되어있다.
[root@centos7 ~]# cat /etc/group ==>그룹의 목록이 쫙 나온다.
[root@centos7 ~]# cat /etc/gshadow ==>그룹 목록의 암호를 볼수있지만 볼수없다. 다 암호화되어있어서..
[root@centos7 home]# vi /etc/login.defs ==>계정정보 생성할때 환경설정값이 여기에있다. =지우면 큰일남
[root@centos7 home]# cat /etc/default/useradd ==>
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash ==>계정만드는 shell을 여기서 바꿀수도있다.
SKEL=/etc/skel ==>skeleton 기본적인 구조물들이 여기에 복사됨. 계정생성하면 무조건복사되어야만하는 파일이 여기있다.
CREATE_MAIL_SPOOL=yes
[root@centos7 home]# cd /etc/skel
[root@centos7 skel]# ls -a
. .. .bash_logout .bash_profile .bashrc .mozilla
[root@centos7 /]# ls -al root
합계 36
dr-xr-x---. 5 root root 225 3월 27 17:57 .
dr-xr-xr-x. 19 root root 250 3월 21 17:17 ..
-rw-------. 1 root root 1292 3월 25 19:50 .bash_history
-rw-r--r--. 1 root root 18 12월 29 2013 .bash_logout
...
...
...
이부분은 외우자
passwd shadow login.../useradd skel
사용자 계정 만들어보기
[root@centos7 /]# cd ~
[root@centos7 ~]# useradd test1
[root@centos7 ~]# ls /home
heejae test1
[root@centos7 ~]# ls -al /home/test1 =>디렉터리가 만들어지면 무조건 만들어져야하는 것이 들어와있다.= skel에 들어있는것들.
합계 12
drwx------. 3 test1 test1 78 3월 28 10:01 .
drwxr-xr-x. 4 root root 33 3월 28 10:01 ..
-rw-r--r--. 1 test1 test1 18 4월 1 2020 .bash_logout
-rw-r--r--. 1 test1 test1 193 4월 1 2020 .bash_profile
-rw-r--r--. 1 test1 test1 231 4월 1 2020 .bashrc
drwxr-xr-x. 4 test1 test1 39 2월 9 12:13 .mozilla
[root@centos7 ~]# cd /etc/skel
[root@centos7 skel]# touch test
[root@centos7 skel]# ls -l
합계 0
-rw-r--r--. 1 root root 0 3월 28 10:03 test
[root@centos7 skel]# useradd test2
[root@centos7 skel]# ls /home/test2 ==>나는 복사한적이없는데 알아서 복사가 되어있다. (회사 공지사항같은거 넣으면 됨)
test
사용자계정 지우기
[root@centos7 skel]# userdel test1
[root@centos7 skel]# userdel test2
[root@centos7 skel]# ls /home
heejae test1 test2 ===>근데 userdel만으로는 홈디렉터리에서는 안지워진다.
[root@centos7 skel]# rm -rf /home/test1
[root@centos7 skel]# ls /home
heejae test2
[root@centos7 skel]# ls /home/user1 ==>userdel로 home디렉터리에 있는것까지 한번에 지우기
test
[root@centos7 skel]# userdel -r user1
[root@centos7 skel]# ls /home
heejae test2
쉘 바꾸고싶으면??
centos7 skel]# useradd -s /bin/sh user1 ==>쉘을 따로 만들수있다. (-s은 shell)
쉘 생성된거 보고싶으면?
[root@centos7 skel]# head /etc/passwd ==>앞에 몇줄만 보여주세요
[root@centos7 skel]# tail /etc/passwd ==>앞에 몇줄만 보여주세요
...
...
tcpdump:x:72:72::/:/sbin/nologin
heejae:x:1000:1000:HEEJAE:/home/heejae:/bin/bash
user1:x:1001:1001::/home/user1:/bin/sh ==>생성된 것 확인
[root@centos7 skel]# id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@centos7 skel]# users ==>현재 사용자들이 보인다.
heejae heejae
[root@centos7 skel]# su user1 ==>shell로 들어가기. exit로 빠져나오고.
sh-4.2$
[root@centos7 skel]# su test1 ==> 쉘바꿀수있다. tcsh 입력하고
[root@centos7 skel]# bash ==>바뀐 쉘정보 볼수있다.
[root@centos7 skel]# groupadd test
[root@centos7 skel]# useradd -u 1500 -g test user2
[root@centos7 skel]# cat /etc/group
...
...
user1:x:1001:
test:x:1002:
[root@centos7 skel]# useradd -D ==>
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
홈디렉터리 바꾸기
[root@centos7 /]# mkdir test
[root@centos7 /]# useradd -D -b /test
[root@centos7 /]# useradd -D
GROUP=100
HOME=/test
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
[root@centos7 /]# groupadd test1
[root@centos7 /]# useradd -D -g test1
[root@centos7 /]# useradd user3
[root@centos7 /]# cat /etc/passwd ==>그룹번호는 마음대로 못정한다. 명은 정할수있음.
user3:x:1502:1503::/home/user3:/bin/bash
홈디렉터리 바꾸기
[root@centos7 /]# tail /etc/passwd
...
user1:x:1502:1503::/home/user1:/bin/bash
[root@centos7 /]# usermod -d /test user1
[root@centos7 /]# tail /etc/passwd
user1:x:1502:1503::/test:/bin/bash ==>바뀐거 확인
[root@centos7 /]# cat /etc/group
user1:x:1503:
...??
.......//??
다시..
계정의 홈디렉터리 바꾸고싶으면?
[root@centos7 /]# mkdir /sunny
[root@centos7 /]# cp -r /home/sunny/* /sunny/
cp: cannot stat `/home/sunny/*': 그런 파일이나 디렉터리가 없습니다
[root@centos7 /]# cp -r /home/sunny/* /heejae/
cp: cannot stat `/home/sunny/*': 그런 파일이나 디렉터리가 없습니다
[root@centos7 /]# cp -r /home/heejae/* /sunny
[root@centos7 /]# ls -al /sunny/
합계 0
drwxr-xr-x. 10 root root 133 3월 28 10:41 .
dr-xr-xr-x. 21 root root 275 3월 28 10:40 ..
drwxr-xr-x. 2 root root 6 3월 28 10:41 공개
drwxr-xr-x. 2 root root 6 3월 28 10:41 다운로드
drwxr-xr-x. 2 root root 6 3월 28 10:41 문서
drwxr-xr-x. 2 root root 6 3월 28 10:41 바탕화면
drwxr-xr-x. 2 root root 6 3월 28 10:41 비디오
drwxr-xr-x. 2 root root 96 3월 28 10:41 사진
drwxr-xr-x. 2 root root 6 3월 28 10:41 서식
drwxr-xr-x. 2 root root 6 3월 28 10:41 음악
[root@centos7 /]# usermod -d /sunny heejae
usermod: user heejae is currently used by process 1827
...???....????뭐여...?
유저의 비밀번호 넣기
[root@centos7 /]# useradd user1
useradd: 'user1' 사용자가 이미 있습니다
[root@centos7 /]# passwd user1
user1 사용자의 비밀 번호 변경 중
새 암호:
새 암호 재입력:
passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.
'네트워크 수업 > 리눅스' 카테고리의 다른 글
[리눅스] 리눅스 압축 도구.pdf 23.03.28 (0) | 2023.03.28 |
---|---|
[리눅스] 압축하기 tar, 압축풀기 gz 23.03.28 (0) | 2023.03.28 |
[리눅스] vmware와 연결 23.03.27 (0) | 2023.03.27 |
[리눅스] fstab, 복사, 시간 23.03.23 (0) | 2023.03.23 |
[리눅스] 쉘 23.03.22 (0) | 2023.03.22 |
댓글