본문 바로가기
강의 실습/비전공자도 이해할 수 있는 리눅스 입문 실전

어떠한 제약도 없이 모든 기능을 사용할 수 있는 관리자 권한 (sudo)

by jint 2025. 11. 4.

1. 권한이 허용되지 않았는데 접근이 가능한 경우

- Ubuntu

ubuntu@ip-172-31-39-75:~$ cd /var/log
ubuntu@ip-172-31-39-75:/var/log$ ls -al
total 11700
drwxrwxr-x  11 root      syslog             4096 Nov  2 00:00 .
drwxr-xr-x  13 root      root               4096 Aug 31 03:27 ..
lrwxrwxrwx   1 root      root                 39 Aug 21 10:04 README -> ../../usr/share/doc/systemd/README.logs
-rw-r--r--   1 root      root                  0 Oct  1 00:00 alternatives.log
-rw-r--r--   1 root      root               7800 Sep 17 06:12 alternatives.log.1
drwx------   3 root      root               4096 Nov  1 02:52 amazon
-rw-r-----   1 root      adm                   0 Aug 31 03:27 apport.log
drwxr-xr-x   2 root      root               4096 Nov  1 06:21 apt
-rw-r-----   1 syslog    adm              414002 Nov  4 12:40 auth.log
-rw-r-----   1 syslog    adm             2024402 Nov  2 00:00 auth.log.1
-rw-r-----   1 syslog    adm              317290 Oct 25 23:59 auth.log.2.gz
-rw-r-----   1 syslog    adm              173086 Oct 18 23:59 auth.log.3.gz
-rw-r-----   1 syslog    adm              224955 Oct 11 23:59 auth.log.4.gz
-rw-rw----   1 root      utmp             340608 Nov  4 12:06 btmp
-rw-rw----   1 root      utmp            6329856 Oct 31 22:25 btmp.1
drwxr-x---   2 _chrony   _chrony            4096 Aug 31 03:27 chrony
-rw-r-----   1 root      adm                4330 Aug 31 03:27 cloud-init-output.log
-rw-r-----   1 syslog    adm              131040 Aug 31 03:27 cloud-init.log
drwxr-xr-x   2 root      root               4096 Jul 25 16:08 dist-upgrade
-rw-r-----   1 root      adm               47405 Aug 31 03:27 dmesg
-rw-r--r--   1 root      root               2117 Nov  1 06:21 dpkg.log
-rw-r--r--   1 root      root              29397 Oct 23 06:08 dpkg.log.1
-rw-r--r--   1 root      root               5796 Sep 27 06:28 dpkg.log.2.gz
drwxr-sr-x+  3 root      systemd-journal    4096 Aug 31 03:27 journal
-rw-r-----   1 syslog    adm                   0 Nov  2 00:00 kern.log
-rw-r-----   1 syslog    adm                 149 Nov  1 15:06 kern.log.1
-rw-r-----   1 syslog    adm                 481 Oct 22 11:47 kern.log.2.gz
-rw-r-----   1 syslog    adm                 152 Oct 18 03:56 kern.log.3.gz
-rw-r-----   1 syslog    adm                 217 Sep 23 06:03 kern.log.4.gz
drwxr-xr-x   2 landscape landscape          4096 Aug 31 03:35 landscape
-rw-rw-r--   1 root      utmp             292292 Nov  4 12:32 lastlog
drwx------   2 root      root               4096 Aug 31 03:27 private
-rw-r-----   1 syslog    adm              446889 Nov  4 12:40 syslog
-rw-r-----   1 syslog    adm             1039511 Nov  2 00:00 syslog.1
-rw-r-----   1 syslog    adm               96241 Oct 26 00:00 syslog.2.gz
-rw-r-----   1 syslog    adm               87210 Oct 19 00:00 syslog.3.gz
-rw-r-----   1 syslog    adm               86143 Oct 12 00:00 syslog.4.gz
drwxr-xr-x   2 root      root               4096 Nov  4 00:07 sysstat
drwxr-x---   2 root      adm                4096 Nov  1 00:00 unattended-upgrades
-rw-rw-r--   1 root      utmp              23424 Nov  4 12:32 wtmp
ubuntu@ip-172-31-39-75:/var/log$ ls chrony
ls: cannot open directory 'chrony': Permission denied


/var/log 경로에 chrony 디렉토리가 있는데, 소유자와 소유그룹이 _chrony 이다. 권한 정보는 drwxr-x--- 로 되어있으므로 소유자, 소유 그룹을 제외한 그 이외 사용자는 접근 권한이 없다.
ubuntu 계정으로 chrony 디렉토리 내부 조회시, 권한이 불충분하여 Permission denied 에러 메시지가 뜬다.

root 사용자로 접근하여 다시 시도해본다.

- Ubuntu

ubuntu@ip-172-31-39-75:/var/log$ sudo su
root@ip-172-31-39-75:/var/log# ls chrony


Permission denied 에러 메시지가 뜨지 않았다. 명령어를 입력했음에도 아무것도 출력되지 않는 이유는 chrony 디렉토리에 파일이 존재하지 않기 때문이다.
root 사용자는 _chrony 사용자가 아님에도 불구하고 접근할 수 있었던 이유는 슈퍼 사용자로 설정되어 있기 때문이다.
슈퍼 사용자는 시스템의 모든 권한을 가진 계정이다. 파일에 설정된 권한과는 별개로 모든 권한을 가지고 있기 때문에 어떠한 조작이든 전부 다 가능하다.


2. root 사용자가 아니더라도 권한이 없는 파일에 접근하는 방법
일반 사용자가 슈퍼 사용자처럼 명령어를 실행하거나 파일에 접근할 수 있는 치트키같은 명령어가 있다. 바로 sudo 명령어이다.

sudo [실행하고자 하는 명령어] : 일반 사용자가 슈퍼 사용자처럼 명령어를 실행

sudo 명령어를 활용하여 다시 chrony 디렉토리 내부를 조회한다.

- Ubuntu

root@ip-172-31-39-75:/var/log# su ubuntu
ubuntu@ip-172-31-39-75:/var/log$ ls chrony
ls: cannot open directory 'chrony': Permission denied
ubuntu@ip-172-31-39-75:/var/log$ sudo ls chrony


Permission denied 에러가 안 뜨고 명령어가 정상적으로 동작한다.
또 다른 파일로 테스트한다.

- Ubuntu

ubuntu@ip-172-31-39-75:/var/log$ cd /etc
ubuntu@ip-172-31-39-75:/etc$ ls -l
total 928
drwxr-xr-x 4 root root       4096 Aug 21 10:06 ModemManager
drwxr-xr-x 2 root root       4096 Aug 21 10:06 PackageKit
drwxr-xr-x 4 root root       4096 Aug 21 10:04 X11
drwxr-xr-x 4 root root       4096 Aug 21 10:15 acpi
-rw-r--r-- 1 root root       3444 Jul  5  2023 adduser.conf
drwxr-xr-x 2 root root       4096 Sep 25 06:29 alternatives
drwxr-xr-x 2 root root       4096 Aug 21 10:06 apparmor
drwxr-xr-x 9 root root       4096 Aug 21 10:15 apparmor.d
drwxr-xr-x 3 root root       4096 Aug 21 10:06 apport
drwxr-xr-x 8 root root       4096 Aug 21 10:16 apt
-rw-r--r-- 1 root root       2319 Mar 31  2024 bash.bashrc
-rw-r--r-- 1 root root         45 Jan 24  2020 bash_completion
drwxr-xr-x 2 root root       4096 Aug 21 10:06 bash_completion.d
-rw-r--r-- 1 root root        367 Aug  2  2022 bindresvport.blacklist
drwxr-xr-x 2 root root       4096 Apr 19  2024 binfmt.d
drwxr-xr-x 2 root root       4096 Aug 21 10:06 byobu
drwxr-xr-x 3 root root       4096 Aug 21 10:04 ca-certificates
-rw-r--r-- 1 root root       6288 Aug 21 10:04 ca-certificates.conf
drwxr-xr-x 4 root root       4096 Aug 21 10:15 chrony
drwxr-xr-x 5 root root       4096 Aug 21 10:07 cloud
drwxr-xr-x 2 root root       4096 Aug 21 10:07 console-setup
drwx------ 2 root root       4096 Apr 19  2024 credstore
drwx------ 2 root root       4096 Apr 19  2024 credstore.encrypted
drwxr-xr-x 2 root root       4096 Aug 21 10:06 cron.d
drwxr-xr-x 2 root root       4096 Sep 25 06:29 cron.daily
drwxr-xr-x 2 root root       4096 Aug 21 10:04 cron.hourly
drwxr-xr-x 2 root root       4096 Aug 21 10:04 cron.monthly
drwxr-xr-x 2 root root       4096 Aug 21 10:06 cron.weekly
drwxr-xr-x 2 root root       4096 Aug 21 10:04 cron.yearly
-rw-r--r-- 1 root root       1136 Mar 31  2024 crontab
drwxr-xr-x 2 root root       4096 Aug 21 10:06 cryptsetup-initramfs
-rw-r--r-- 1 root root         54 Aug 21 10:05 crypttab
drwxr-xr-x 4 root root       4096 Aug 21 10:04 dbus-1
-rw-r--r-- 1 root root       2967 Apr 12  2024 debconf.conf
-rw-r--r-- 1 root root         11 Apr 22  2024 debian_version
drwxr-xr-x 3 root root       4096 Aug 21 10:16 default
-rw-r--r-- 1 root root       1706 Jul  5  2023 deluser.conf
drwxr-xr-x 2 root root       4096 Aug 21 10:05 depmod.d
drwxr-xr-x 3 root root       4096 Aug 21 10:04 dhcp
-rw-r--r-- 1 root root       1429 Mar 31  2024 dhcpcd.conf
drwxr-xr-x 4 root root       4096 Sep 25 06:29 dpkg
-rw-r--r-- 1 root root        685 Apr  8  2024 e2scrub.conf
-rw-r--r-- 1 root root         34 Aug 21 10:07 ec2_version
-rw-r--r-- 1 root root        106 Aug 21 10:04 environment
-rw-r--r-- 1 root root       1853 Oct 17  2022 ethertypes
-rw-r--r-- 1 root root        146 Aug 21 10:15 fstab
-rw-r--r-- 1 root root        694 Apr  8  2024 fuse.conf
drwxr-xr-x 4 root root       4096 Aug 21 10:06 fwupd
-rw-r--r-- 1 root root       2584 Jan 31  2024 gai.conf
drwxr-xr-x 2 root root       4096 Aug 21 10:05 gnutls
drwxr-xr-x 2 root root       4096 Aug 21 10:06 groff
-rw-r--r-- 1 root root        844 Aug 31 03:27 group
-rw-r--r-- 1 root root        798 Aug 21 10:15 group-
drwxr-xr-x 2 root root       4096 Aug 21 10:15 grub.d
-rw-r----- 1 root shadow      712 Aug 31 03:27 gshadow
-rw-r----- 1 root shadow      670 Aug 21 10:15 gshadow-
drwxr-xr-x 3 root root       4096 Aug 21 10:04 gss
-rw-r--r-- 1 root root       4436 Oct  6  2022 hdparm.conf
-rw-r--r-- 1 root root       1470 Nov 20  2023 hibagent-config.cfg
-rw-r--r-- 1 root root        822 May 23  2024 hibinit-config.cfg
-rw-r--r-- 1 root root         92 Apr 22  2024 host.conf
-rw-r--r-- 1 root root         16 Aug 31 03:27 hostname
-rw-r--r-- 1 root root        221 Aug 20 22:49 hosts
-rw-r--r-- 1 root root        411 Aug 21 10:06 hosts.allow
-rw-r--r-- 1 root root        711 Aug 21 10:06 hosts.deny
drwxr-xr-x 2 root root       4096 Oct  1 06:52 init.d
drwxr-xr-x 5 root root       4096 Aug 21 10:06 initramfs-tools
-rw-r--r-- 1 root root       1875 Mar 31  2024 inputrc
drwxr-xr-x 4 root root       4096 Aug 21 10:05 iproute2
drwxr-xr-x 2 root root       4096 Aug 21 10:06 iscsi
-rw-r--r-- 1 root root         26 Aug  1 14:21 issue
-rw-r--r-- 1 root root         19 Aug  1 14:21 issue.net
drwxr-xr-x 6 root root       4096 Aug 21 10:15 kernel
drwxrwxr-x 2 root landscape  4096 Oct 15  2024 landscape
-rw-r--r-- 1 root root      20775 Nov  1 06:21 ld.so.cache
-rw-r--r-- 1 root root         34 Aug  2  2022 ld.so.conf
drwxr-xr-x 2 root root       4096 Sep 23 06:03 ld.so.conf.d
drwxr-xr-x 2 root root       4096 Aug 21 10:06 ldap
-rw-r--r-- 1 root root        267 Apr 22  2024 legal
-rw-r--r-- 1 root root        191 Mar 31  2024 libaudit.conf
drwxr-xr-x 3 root root       4096 Aug 21 10:06 libblockdev
drwxr-xr-x 2 root root       4096 Aug 21 10:06 libibverbs.d
drwxr-xr-x 2 root root       4096 Aug 21 10:06 libnl-3
-rw-r--r-- 1 root root       2996 Mar 30  2024 locale.alias
-rw-r--r-- 1 root root         13 Aug 21 10:07 locale.conf
-rw-r--r-- 1 root root       9563 Sep 23 06:03 locale.gen
lrwxrwxrwx 1 root root         27 Aug 21 10:04 localtime -> /usr/share/zoneinfo/Etc/UTC
drwxr-xr-x 4 root root       4096 Aug 21 10:06 logcheck
-rw-r--r-- 1 root root      12345 Feb 22  2024 login.defs
-rw-r--r-- 1 root root        586 Apr  8  2024 logrotate.conf
drwxr-xr-x 2 root root       4096 Sep 25 06:29 logrotate.d
-rw-r--r-- 1 root root        104 Aug  1 14:21 lsb-release
drwxr-xr-x 3 root root       4096 Aug 21 10:06 lvm
-r--r--r-- 1 root root         33 Aug 31 03:27 machine-id
-rw-r--r-- 1 root root        111 Mar 31  2024 magic
-rw-r--r-- 1 root root        111 Mar 31  2024 magic.mime
-rw-r--r-- 1 root root       5230 Apr  8  2024 manpath.config
drwxr-xr-x 2 root root       4096 Aug 21 10:06 mdadm
-rw-r--r-- 1 root root      75113 Jul 12  2023 mime.types
-rw-r--r-- 1 root root        744 Apr  8  2024 mke2fs.conf
drwxr-xr-x 2 root root       4096 Aug 21 10:15 modprobe.d
-rw-r--r-- 1 root root        212 Aug 21 10:04 modules
drwxr-xr-x 2 root root       4096 Aug 21 10:15 modules-load.d
lrwxrwxrwx 1 root root         19 Aug 21 10:04 mtab -> ../proc/self/mounts
drwx------ 2 root root       4096 Aug 31 03:27 multipath
-rw-r--r-- 1 root root         41 Apr  7  2024 multipath.conf
-rw-r--r-- 1 root root      11424 May 23  2023 nanorc
drwxr-xr-x 6 root root       4096 Aug 21 10:06 needrestart
-rw-r--r-- 1 root root        767 Mar 31  2024 netconfig
drwxr-xr-x 2 root root       4096 Aug 31 03:27 netplan
drwxr-xr-x 5 root root       4096 Aug 21 10:15 network
drwxr-xr-x 8 root root       4096 Aug 21 10:04 networkd-dispatcher
-rw-r--r-- 1 root root         91 Apr 22  2024 networks
drwxr-xr-x 2 root root       4096 Aug 21 10:04 newt
-rwxr-xr-x 1 root root        243 Oct 19  2023 nftables.conf
-rw-r--r-- 1 root root        526 Aug 21 10:04 nsswitch.conf
drwxr-xr-x 2 root root       4096 Aug 21 10:04 opt
lrwxrwxrwx 1 root root         21 Aug  1 14:21 os-release -> ../usr/lib/os-release
-rw-r--r-- 1 root root       6920 Jul  3  2024 overlayroot.conf
-rw-r--r-- 1 root root        112 Aug 21 10:07 overlayroot.local.conf
-rw-r--r-- 1 root root        552 Oct 13  2022 pam.conf
drwxr-xr-x 2 root root       4096 Oct  1 06:52 pam.d
-rw-r--r-- 1 root root       1850 Aug 31 03:27 passwd
-rw-r--r-- 1 root root       1801 Aug 21 10:15 passwd-
drwxr-xr-x 3 root root       4096 Aug 21 10:05 perl
drwxr-xr-x 4 root root       4096 Aug 21 10:06 pki
drwxr-xr-x 2 root root       4096 Feb 25  2025 plymouth
drwxr-xr-x 3 root root       4096 Aug 21 10:06 pm
drwxr-xr-x 3 root root       4096 Aug 21 10:06 polkit-1
drwxr-xr-x 2 root root       4096 Aug 21 10:06 pollinate
drwxr-xr-x 4 root root       4096 Aug 21 10:15 ppp
-rw-r--r-- 1 root root        582 Apr 22  2024 profile
drwxr-xr-x 2 root root       4096 Aug 21 10:06 profile.d
-rw-r--r-- 1 root root       3144 Oct 17  2022 protocols
drwxr-xr-x 2 root root       4096 Aug 21 10:04 python3
drwxr-xr-x 2 root root       4096 Sep  1 06:09 python3.12
drwxr-xr-x 2 root root       4096 Aug 21 10:16 rc0.d
drwxr-xr-x 2 root root       4096 Aug 21 10:16 rc1.d
drwxr-xr-x 2 root root       4096 Aug 21 10:16 rc2.d
drwxr-xr-x 2 root root       4096 Aug 21 10:16 rc3.d
drwxr-xr-x 2 root root       4096 Aug 21 10:16 rc4.d
drwxr-xr-x 2 root root       4096 Aug 21 10:16 rc5.d
drwxr-xr-x 2 root root       4096 Aug 21 10:16 rc6.d
drwxr-xr-x 2 root root       4096 Aug 21 10:06 rcS.d
lrwxrwxrwx 1 root root         39 Aug 21 10:04 resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
lrwxrwxrwx 1 root root         13 Apr  8  2024 rmt -> /usr/sbin/rmt
-rw-r--r-- 1 root root        911 Oct 17  2022 rpc
-rw-r--r-- 1 root root       1213 Mar 22  2024 rsyslog.conf
drwxr-xr-x 2 root root       4096 Aug 21 10:06 rsyslog.d
-rw-r--r-- 1 root root       3663 Jun 20  2016 screenrc
drwxr-xr-x 4 root root       4096 Sep 23 06:03 security
drwxr-xr-x 2 root root       4096 Aug 21 10:04 selinux
drwxr-xr-x 2 root root       4096 Aug 21 10:06 sensors.d
-rw-r--r-- 1 root root      10593 Mar 31  2024 sensors3.conf
-rw-r--r-- 1 root root      12813 Mar 27  2021 services
drwxr-xr-x 2 root root       4096 Aug 21 10:06 sgml
-rw-r----- 1 root shadow      899 Aug 31 03:27 shadow
-rw-r----- 1 root shadow      899 Aug 31 03:27 shadow-
-rw-r--r-- 1 root root        148 Aug 21 10:06 shells
drwxr-xr-x 2 root root       4096 Aug 21 10:04 skel
drwxr-xr-x 6 root root       4096 Aug 21 10:06 sos
drwxr-xr-x 4 root root       4096 Aug 31 03:27 ssh
drwxr-xr-x 4 root root       4096 Oct  2 06:57 ssl
-rw-r--r-- 1 root root         20 Aug 31 03:27 subgid
-rw-r--r-- 1 root root          0 Aug 21 10:04 subgid-
-rw-r--r-- 1 root root         20 Aug 31 03:27 subuid
-rw-r--r-- 1 root root          0 Aug 21 10:04 subuid-
-rw-r--r-- 1 root root       4343 Apr  8  2024 sudo.conf
-rw-r--r-- 1 root root       9804 Apr  8  2024 sudo_logsrvd.conf
-r--r----- 1 root root       1800 Jan 29  2024 sudoers
drwxr-x--- 2 root root       4096 Aug 31 03:27 sudoers.d
drwxr-xr-x 2 root root       4096 Aug 21 10:04 supercat
-rw-r--r-- 1 root root       2209 Mar 24  2024 sysctl.conf
drwxr-xr-x 2 root root       4096 Aug 21 10:15 sysctl.d
drwxr-xr-x 2 root root       4096 Aug 21 10:06 sysstat
drwxr-xr-x 6 root root       4096 Aug 21 10:15 systemd
drwxr-xr-x 2 root root       4096 Aug 21 10:04 terminfo
-rw-r--r-- 1 root root          8 Aug 21 10:05 timezone
drwxr-xr-x 2 root root       4096 Aug 21 10:06 tmpfiles.d
drwxr-xr-x 2 root root       4096 Aug 21 10:05 ubuntu-advantage
-rw-r--r-- 1 root root       1260 Jan 27  2023 ucf.conf
drwxr-xr-x 4 root root       4096 Aug 21 10:05 udev
drwxr-xr-x 2 root root       4096 Sep  1 06:09 udisks2
drwxr-xr-x 3 root root       4096 Aug 21 10:06 ufw
drwxr-xr-x 3 root root       4096 Aug 21 10:06 update-manager
drwxr-xr-x 2 root root       4096 Aug 21 10:06 update-motd.d
drwxr-xr-x 2 root root       4096 Apr  2  2025 update-notifier
-rw-r--r-- 1 root root       1523 Apr  8  2024 usb_modeswitch.conf
drwxr-xr-x 2 root root       4096 Dec 16  2023 usb_modeswitch.d
lrwxrwxrwx 1 root root         16 Aug 21 10:04 vconsole.conf -> default/keyboard
drwxr-xr-x 2 root root       4096 Sep 17 06:12 vim
drwxr-xr-x 4 root root       4096 Oct  1 06:52 vmware-tools
lrwxrwxrwx 1 root root         23 Feb 26  2024 vtrgb -> /etc/alternatives/vtrgb
-rw-r--r-- 1 root root       4942 Jun 19  2024 wgetrc
-rw-r--r-- 1 root root        681 Apr  8  2024 xattr.conf
drwxr-xr-x 4 root root       4096 Aug 21 10:04 xdg
drwxr-xr-x 2 root root       4096 Aug 21 10:06 xml
-rw-r--r-- 1 root root        460 Jan 20  2023 zsh_command_not_found
ubuntu@ip-172-31-39-75:/etc$ cat sudoers
cat: sudoers: Permission denied
ubuntu@ip-172-31-39-75:/etc$ sudo cat sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# This fixes CVE-2005-4890 and possibly breaks some versions of kdesu
# (#1011624, https://bugs.kde.org/show_bug.cgi?id=452532)
Defaults        use_pty

# This preserves proxy settings from user environments of root
# equivalent users (group sudo)
#Defaults:%sudo env_keep += "http_proxy https_proxy ftp_proxy all_proxy no_proxy"

# This allows running arbitrary commands, but so does ALL, and it means
# different sudoers have their choice of editor respected.
#Defaults:%sudo env_keep += "EDITOR"

# Completely harmless preservation of a user preference.
#Defaults:%sudo env_keep += "GREP_COLOR"

# While you shouldn't normally run git as root, you need to with etckeeper
#Defaults:%sudo env_keep += "GIT_AUTHOR_* GIT_COMMITTER_*"

# Per-user preferences; root won't have sensible values for them.
#Defaults:%sudo env_keep += "EMAIL DEBEMAIL DEBFULLNAME"

# "sudo scp" or "sudo rsync" should be able to use your SSH agent.
#Defaults:%sudo env_keep += "SSH_AGENT_PID SSH_AUTH_SOCK"

# Ditto for GPG agent
#Defaults:%sudo env_keep += "GPG_AGENT_INFO"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "@include" directives:

@includedir /etc/sudoers.d


sudoers 파일은 root 이외의 사용자는 파일에 대한 어떠한 권한도 없어서 파일 내용 출력시 Permission denied 에러 메시지가 뜬다.
sudo 명령어를 붙이고 다시 명령어를 실행하면 권한이 없음에도 잘 작동한다.

sudo 명령어는 권한에 제약없이 어떠한 기능들도 사용할 수 있게 만들어주는 명령어다.


3. root 사용자로 로그인 vs sudo 명령어 활용
명령어 실행시, Permission denied 에러 메시지가 뜨면 권한이 부족하다는 뜻이다.
이를 쉽게 해결하는 방법 2가지가 있다.

1) 슈퍼 사용자(root 사용자)로 접근해서 명령어 실행
sudo su : root 사용자로 전환

2) 명령어 앞에 sudo를 붙여서 명령어 실행
sudo [실행하고자 하는 명령어]

첫 번째 방법은 root 사용자로 전환하여 명령어를 실행시키기 때문에, sudo 를 붙이지 않아도 되는 편리함이 있다.
두 번째 방법은 권한이 필요할 때마다 sudo 를 매번 붙여야 하는 번거로움이 있다.

하지만 root 사용자로 전환하여 명령어를 조작하다가 실수로 시스템에 치명적인 명령어를 실행해 시스템이 손상될 위험이 있다.
따라서 일반 사용자로 명령어를 입력하다가, 정말 권한이 필요한 명령어만 sudo 를 붙여 사용하는 방식을 권장한다.


참고링크 : https://www.inflearn.com/course/%EB%B9%84%EC%A0%84%EA%B3%B5%EC%9E%90%EB%8F%84-%EC%9D%B4%ED%95%B4%ED%95%A0-%EC%88%98-%EC%9E%88%EB%8A%94-%EB%A6%AC%EB%88%85%EC%8A%A4-%EC%9E%85

 

비전공자도 이해할 수 있는 리눅스 입문/실전| JSCODE 박재성 - 인프런 강의

현재 평점 5.0점 수강생 279명인 강의를 만나보세요. 비전공자 입장에서도 쉽게 이해할 수 있고, 실전에서 바로 적용 가능한 '리눅스 입문' 강의를 만들어봤습니다! 리눅스를 처음 배우시는 분, Per

www.inflearn.com

댓글