OS/Linux

[Linux] root 권한 부여

dalgong 2023. 6. 18. 17:21
반응형

계정 추가


1. root 권한을 부여해주기 위한 계정을 추가해줍니다.

[root@dalgong-test ~]# adduser dalgong

2. 계정이 잘 추가되었는지 확인

[root@dalgong-test ~]# vim /etc/passwd

3. 계정 패스워드 변경

[root@dalgong-test ~]# passwd dalgong 
Changing password for user dalgong.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

 

 

root 권한 부여


1. sudoers 파일 편집

[root@dalgong-test ~]# vim /etc/sudoers
## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
dalgong    ALL=(ALL)       ALL

2. sudo su - 확인

[dalgong@dalgong-test /]$ sudo su -
Last login: Sun Jun 18 17:14:18 KST 2023 on pts/0

3. 기존 계정 sudo 사용 가능 확인

[dalgong@dalgong-test ssh]$ systemctl restart sshd.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to restart sshd.service: Access denied
See system logs and 'systemctl status sshd.service' for details.

=> 기존 계정으로 sudo 없이 실행 불가능

[dalgong@dalgong-test ssh]$ sudo systemctl restart sshd.service

=> sudo 사용하여 실행 가능 확인

반응형

'OS > Linux' 카테고리의 다른 글

[Linux] NAS란?  (0) 2023.11.27
[Linux] Open SSH 업데이트  (0) 2023.07.23
[Linux] SSH 접속 포트 변경  (0) 2023.06.12
[Linux] SWAP 메모리 설정  (0) 2023.06.10
[Linux] 리눅스 -> 윈도우 파일 옮기기  (0) 2023.06.09