관리 메뉴

웹개발자의 기지개

[Ubuntu] 우분투 설치와 초기설정, jdk (자바설치) 본문

리눅스서버/Ubuntu

[Ubuntu] 우분투 설치와 초기설정, jdk (자바설치)

http://portfolio.wonpaper.net 2023. 11. 28. 01:29

 

 

 



https://lindarex.github.io/ubuntu/ubuntu-initial-setting/


1. root 비밀번호 설정

$ sudo passwd root
[sudo] password for rex:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

rex@lindarex:~$ su - root
Password:
root@lindarex:~#



2. 패키지(package) 업데이트(update)

‘apt update’ command로 package 인덱스를 update합니다.

$ sudo apt update
[sudo] password for rex:

‘apt upgrade’ command로 업그레이드 가능한 모든 package를 update합니다.

$ sudo apt upgrade -y
[sudo] password for rex:

ubuntu를 재시작합니다.
$ sudo reboot
[sudo] password for rex:


3. 유용한 package 설치

‘apt install’ command로 arp, ifconfig, netstat, rarp 등 네트워크 제어 command를 포함한 net-tools package를 설치합니다.

$ sudo apt install net-tools -y
[sudo] password for rex:

‘apt install’ command로 압축 program인 unzip package를 설치합니다.

$ sudo apt install unzip -y
[sudo] password for rex:

‘apt install’ command로 tree 구조로 디렉터리를 조회할 수 있는 tree package를 설치합니다.

$ sudo apt install tree -y
[sudo] password for rex:


4. 사용자(user) 계정 생성

adduser’ command로 user 계정을 추가합니다.

$ sudo adduser rex2
[sudo] password for rex:


root 계정의 password 설정 시와 동일하게, ‘passwd’ command로 user 계정의 password를 설정합니다.

$ sudo passwd rex2
[sudo] password for rex:


‘visudo’ command로 생성한 user 계정에 root(sudo) 권한을 추가합니다.

‘/etc/sudoers’를 vi로 수정할 수도 있지만, 설정 유효성과 문법 체크를 위해 ‘visudo’ command로 수정하시기 바랍니다.


$ sudo visudo
[sudo] password for rex:


----------------------------------------
#
# 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
rex     ALL=(ALL:ALL) ALL
rex2    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
----------------------------------------


‘visudo’ command로 생성한 user 계정에 root(sudo) 권한 추가와 함께 password 입력 없이 사용할 때는 아래와 같이 설정합니다.
sudo password 입력 없이 사용하면, 보안상 안전하지 않을 수 있으니 주의하시기 바랍니다.

$ sudo visudo
[sudo] password for rex:


----------------------------------------
~
# User privilege specification
root    ALL=(ALL:ALL) ALL
rex     ALL=NOPASSWD:ALL
rex2    ALL=NOPASSWD:ALL
~
----------------------------------------




5. 시스템(system) 언어(locale) 설정

‘locale’ command로 현재 locale 설정을 조회합니다.

$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

‘locale -a’ command로 설치되어 있는 locale을 조회합니다.

$ locale -a
C
C.UTF-8
en_US.utf8
POSIX

‘apt install’ command로 한국어(Korean) package를 설치합니다.

$ sudo apt install language-pack-ko -y
[sudo] password for rex:


Korean 설정을 합니다.


$ sudo vi /etc/default/locale
[sudo] password for rex:


----------------------------------------
LANG="ko_KR.UTF-8"
LANGUAGE="ko_KR:ko:en_US:en"
----------------------------------------


설정 후 재접속하여 한글 출력을 확인합니다.


$ sudo ls
[sudo] rex의 암호:
죄송합니다만, 다시 시도하십시오.
[sudo] rex의 암호:


‘locale -a’ command로 설치된 Korean locale을 조회합니다.


$ locale -a
C
C.UTF-8
en_US.utf8
ko_KR.utf8
POSIX


6. 시스템(system) 시간(timezone) 설정

‘date’ command로 현재 시각을 조회합니다.

$ date
Mon Mar 14 07:29:26 UTC 2020

‘timedatectl’ command로 자세한 timezone 설정을 조회합니다.

$ timedatectl
                      Local time: Mon 2020-03-14 07:26:52 UTC
                  Universal time: Mon 2020-03-14 07:26:52 UTC
                        RTC time: Mon 2020-03-14 07:26:53
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no



‘timedatectl set-timezone’ command로 ‘Asia/Seoul’ timezone으로 설정합니다.

$ sudo timedatectl set-timezone Asia/Seoul


‘date’ command로 설정한 timezone이 적용된 현재 시각을 조회합니다.


$ date
Mon Mar 14 16:35:27 KST 2020


‘timedatectl’ command로 ‘Asia/Seoul’으로 설정한 timezone 설정을 조회합니다.

$ timedatectl
                      Local time: Mon 2020-03-14 16:35:29 KST
                  Universal time: Mon 2020-03-14 07:35:29 UTC
                        RTC time: Mon 2020-03-14 07:35:30
                       Time zone: Asia/Seoul (KST, +0900)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no





[ 한글 폴더 영문으로 ]

https://kibua20.tistory.com/42
https://hcnam.tistory.com/29

#한글이름 폴더를 영문으로 변경

$ export LANG=C; xdg-user-dirs-gtk-update 

# 영문에서 다시 한글로 변경

$ echo “C” > ~/.config/user-dirs.locale
$ export LANG=ko_KR.utf8; xdg-user-dirs-gtk-update


 

[ 우분투 즉시 종료 ] 

sudo shutdown now

 

[ jdk 설치]

 

sudo apt-get update
sudo apt-get upgrade 

# Java 8 설치$ 

sudo apt-get install openjdk-8-jdk


# Java 11 설치$ 

sudo apt-get install openjdk-11-jdk

java -version


현재 설치된 자바 버전중에 변경 가능한 버전 확인하고 선택하기
sudo update-alternatives --config java

 

 

 

참고 (java, 환경변수) : https://backendcode.tistory.com/262

참고 (java 여러개) : https://goyunji.tistory.com/7

 

 

 

Comments