반응형
우분투 20.04에서 초기 서버 설정하는 방법
테스트 환경
OS
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
Architecture
$ getconf LONG_BIT
64
1. 기본 에디터 변경 (nano → vim)
우분투의 기본 CLI 편집기는 nano입니다.
운영 환경에서는 vim을 기본 에디터로 변경하는 경우가 많습니다.
현재 기본 에디터 확인 및 변경
sudo update-alternatives --config editor
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
* 0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 15 manual mode
3번( vim.basic ) 선택
Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode
2. CLI 환경에서 네트워크 설정 (고정 IP)
우분투 20.04부터는 netplan을 사용하여 네트워크를 설정합니다.
네트워크 인터페이스 이름 확인
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
...
Netplan(00-installer-config.yaml) 설정 파일 편집
sudo vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
addresses:
- 192.168.100.10/24
gateway4: 192.168.100.1
nameservers:
addresses:
- 8.8.8.8
version: 2
네트워크 설정 적용
sudo netplan apply
728x90
3. sudo 패스워드 없이 사용하기
특정 사용자에게 sudo 사용 시 비밀번호 입력 없이 권한을 부여할 수 있습니다.
권장 방식: /etc/sudoers.d/ 사용
/etc/sudoers 직접 수정은 실수 시 sudo 사용 불가 위험이 있음
sudo visudo -f /etc/sudoers.d/user2
user2 ALL=NOPASSWD: ALL
권한 확인
sudo -l -U user2
sudoers 설정
sudo vim /etc/sudoers
user1 ALL=(ALL:ALL) ALL
user2 ALL=NOPASSWD: ALL
visudo
#
# 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"
# 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
user1 ALL=(ALL:ALL) ALL
user2 ALL=NOPASSWD: ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
비권장 방식 (직접 echo 명령어로 파일 편집)
echo 'user2 ALL=NOPASSWD: ALL' >> /etc/sudoers
sudo 동작 확인
user1
echo 'user1 ALL=(ALL:ALL) ALL' >> /etc/sudoers
$ sudo su -
[sudo] password for user1:
root@linux:~#
user2
echo 'user2 ALL=NOPASSWD: ALL' >> /etc/sudoers
$ sudo su -
root@linux:~#
728x90
반응형
'리눅스' 카테고리의 다른 글
| Ubuntu Server 22.04 LTS를 설치하는 방법 (0) | 2022.04.21 |
|---|---|
| Ubuntu Server 22.04 LTS (Jammy Jellyfish) (0) | 2022.04.21 |
| Ubuntu 18.04 LTS에서 Python 3.9으로 업그레이드하는 방법 (0) | 2022.04.01 |
| CentOS 7에서 Kubernetes를 제거하는 방법 (0) | 2022.04.01 |
| VMware ESXi 환경에서 리눅스 가상 머신(VM)의 하드 디스크 용량을 증설하는 방법 - CentOS (0) | 2022.03.30 |