다운로드:
1.optimize_ubuntu_server_no_root.sh
2.optimize_ubuntu_server_root.sh
#!/bin/sh
###########################################################
#
# Ubuntu 최적화 스크립트 1/2 (일반 계정으로 실행)
#
# 이 스크립트는
# Ubuntu 16.04.1 LTS 에서 시험되었으며,
# 반드시 인터넷이 가능하고 일반계정으로 실행해야 한다.
#
# Author: 이존석 (hasu0707@gmail.com)
#
###########################################################
IFACE_NAME="ens33"
IF_IP_ADDR="10.10.10.39"
IF_NETMASK="255.255.255.0"
IF_GATEWAY="10.10.10.254"
sudo sync
###########################################################
#
# root 패스워드 설정
#
###########################################################
sudo echo "################################################"
sudo echo "#"
sudo echo "# PLEASE, ENTER NEW ROOT PASSWORD."
sudo echo "#"
sudo echo "################################################"
sudo passwd root
###########################################################
#
# /etc/apt/sources.list 업데이트
#
###########################################################
sudo apt-get -y update
###########################################################
#
# 로케일 설정
#
###########################################################
sudo apt-get -y install language-pack-ko
sudo locale-gen "ko_KR.UTF-8"
###########################################################
#
# 타임존 셋팅
#
###########################################################
sudo chmod 666 /etc/timezone
sudo echo "Asia/Seoul" > /etc/timezone
#sudo echo "Etc/UTC" > /etc/timezone
sudo chmod 644 /etc/timezone
###########################################################
#
# 네트워크 셋팅
#
###########################################################
sudo cp /etc/network/interfaces /etc/network/interfaces.old
sudo chmod 666 /etc/network/interfaces
sudo sed -i "s/iface ${IFACE_NAME} inet dhcp/iface ${IFACE_NAME} inet static/g" /etc/network/interfaces
sudo echo "address ${IF_IP_ADDR}" >> /etc/network/interfaces
sudo echo "netmask ${IF_NETMASK}" >> /etc/network/interfaces
sudo echo "gateway ${IF_GATEWAY}" >> /etc/network/interfaces
sudo echo "dns-nameservers 8.8.8.8" >> /etc/network/interfaces
sudo chmod 644 /etc/network/interfaces
###########################################################
#
# 네트워크 셋팅 (DNS)
#
###########################################################
sudo chmod 666 /etc/resolv.conf
sudo echo "search local" > /etc/resolv.conf
sudo echo "nameserver 8.8.8.8" >> /etc/resolv.conf
sudo chmod 644 /etc/resolv.conf
###########################################################
#
# 전체 패키지 업데이트
#
###########################################################
sudo apt-get update -y
sudo apt-get upgrade -y
###########################################################
#
# 불필요한 파일 정리
#
###########################################################
sudo rm -f /var/log/*log
sudo rm -rf /tmp/*
###########################################################
#
# 필요한 패키지 설치
# (설치가 안될 수 있으니 리부팅 후 확인 요망)
#
###########################################################
###########################################################
#
# 필수 유틸리티 설치
#
###########################################################
sudo add-apt-repository ppa:eugenesan/ppa
sudo apt-get -y install lrzsz snapd
sudo apt-get -y install gzip bzip2 tar unrar arj p7zip minicom mc ftp lsof lftp
sudo apt-get -y install iptables bridge-utils isc-dhcp-server iperf
sudo apt-get -y install ntfs-3g
sudo apt-get -y install exfat-fuse exfat-utils
###########################################################
#
# X-Window 설치
#
###########################################################
sudo apt-get -y install xorg gdm
sudo apt-get -y install language-pack-ko language-pack-gnome-ko-base
sudo apt-get -y install fbterm
sudo apt-get -y install fonts-nanum-coding
###########################################################
#
# X-Window로 부팅되지 않도록 셋팅
#
###########################################################
sudo systemctl enable multi-user.target --force
sudo systemctl set-default multi-user.target
###########################################################
#
# 개발도구 설치
#
###########################################################
sudo apt-get -y install git subversion build-essential pkg-config
sudo apt-get -y install zlib1g-dev liblzma-dev python-magic
sudo apt-get -y install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
sudo apt-get -y install linux-headers-`uname -r`
sudo apt-get -y install python-dev
sudo apt-get -y install uncrustify
sudo apt-get -y install flex bison
###########################################################
#
# vsftpd 설치 (/etc/vsftpd.conf)
#
###########################################################
sudo apt-get -y install vsftpd
sudo systemctl disable vsftpd.service
###########################################################
#
# Oracle JDK 설치
#
###########################################################
sudo apt-get -y install python-software-properties
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get -y update
sudo apt-get -y install oracle-java8-installer
###########################################################
#
# mysql 패키지 설치
#
###########################################################
sudo apt-get -y install mysql-server mysql-client
sudo chmod 666 /etc/mysql/mysql.conf.d/mysqld.cnf
sudo sed -i "s/127.0.0.1/0.0.0.0/g" /etc/mysql/mysql.conf.d/mysqld.cnf
sudo chmod 644 /etc/mysql/mysql.conf.d/mysqld.cnf
###########################################################
#
# apache2,php 패키지 설치
#
###########################################################
sudo apt-get -y install apache2
sudo apt-get -y install apache2-utils
sudo apt-get -y install php libapache2-mod-php
sudo apt-get -y install php-mysql php-cli php-xml-parser
sudo a2enmod rewrite
###########################################################
#
# 커널 업그레이드
#
###########################################################
sudo apt-get -y install linux-generic linux-headers-generic linux-image-generic
sudo apt-get -y install ubuntu-core-launcher
###########################################################
#
# 불필요한 서비스 제거
#
# enable 되어있는 서비스 보기
# ls -1 /etc/rc$(runlevel| cut -d" " -f2).d/S* | awk -F'[0-9][0-9]' '{print "Startup :-> " $2}'
# systemctl -t service -a
#
###########################################################
sudo systemctl disable acpid.service
sudo systemctl disable apparmor.service
sudo systemctl disable apport.service
sudo systemctl disable avahi-daemon.service
sudo systemctl disable bluetooth.service
sudo systemctl disable cryptdisks-early.service
sudo systemctl disable cryptdisks.service
sudo systemctl disable dbus.service
sudo systemctl disable gdm3.service
sudo systemctl disable grub-common.service
sudo systemctl disable iscsid.service
sudo systemctl disable lxcfs.service
sudo systemctl disable lxd-containers.service
sudo systemctl disable lxd.service
sudo systemctl disable mdadm.service
sudo systemctl disable ModemManager.service
sudo systemctl disable nfs-client.target
sudo systemctl disable nfs-config.service
sudo systemctl disable nfs-kernel-server.service
sudo systemctl disable nscd.service
sudo systemctl disable nslcd.service
sudo systemctl disable open-iscsi.service
sudo systemctl disable open-vm-tools.service
sudo systemctl disable plymouth-log.service
sudo systemctl disable plymouth.service
sudo systemctl disable polkitd.service
sudo systemctl disable rpcbind.service
sudo systemctl disable rsync.service
sudo systemctl disable setvtrgb.service
sudo systemctl disable snapd.service
sudo systemctl disable ufw.service
sudo systemctl disable uuidd.service
sudo systemctl disable vsftpd.service
sudo systemctl disable x11-common.service
sudo systemctl enable atd.service
sudo systemctl enable console-setup.service
sudo systemctl enable cron.service
sudo systemctl enable getty@tty1.service
sudo systemctl enable ifup@ens33.service
sudo systemctl enable irqbalance.service
sudo systemctl enable keyboard-setup.service
sudo systemctl enable kmod-static-nodes.service
sudo systemctl enable lvm2-lvmetad.service
sudo systemctl enable lvm2-monitor.service
sudo systemctl enable networking.service
sudo systemctl enable ondemand.service
sudo systemctl enable rc-local.service
sudo systemctl enable resolvconf.service
sudo systemctl enable rsyslog.service
sudo systemctl enable ssh.service
sudo systemctl enable systemd-journal-flush.service
sudo systemctl enable systemd-journald.service
sudo systemctl enable systemd-logind.service
sudo systemctl enable systemd-modules-load.service
sudo systemctl enable systemd-random-seed.service
sudo systemctl enable systemd-remount-fs.service
sudo systemctl enable systemd-sysctl.service
sudo systemctl enable systemd-timesyncd.service
sudo systemctl enable systemd-tmpfiles-setup-dev.service
sudo systemctl enable systemd-tmpfiles-setup.service
sudo systemctl enable systemd-udev-trigger.service
sudo systemctl enable systemd-udevd.service
sudo systemctl enable systemd-update-utmp.service
sudo systemctl enable systemd-user-sessions.service
sudo systemctl enable user@0.service
###########################################################
#
# Ubuntu 자동 업데이트 비활성화
#
###########################################################
sudo sed -i 's/Update-Package-Lists "1"/Update-Package-Lists "0"/g' /etc/apt/apt.conf.d/10periodic
###########################################################
#
# sshd root 계정 활성화
#
###########################################################
sudo sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config
sudo sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
###########################################################
#
# 설치되어 있는 모든 패키지 업그레이드
#
###########################################################
sudo apt-get -y upgrade
###########################################################
#
# 불필요한 파일들 삭제
#
###########################################################
sudo apt-get -y -f autoremove
sudo apt-get -y autoclean
sudo apt-get -y clean
sudo sync