Ubuntu 16.04 Desktop Environment Setup

修改 Terminal,將完整路徑改為當前目錄

1
2
sed -i 's/\\w/\\W/g' ~/.bashrc
source ~/.bashrc

開啟 Minimise On Click

1
gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-minimize-window true

設定關閉螢幕之閒置時間

1
2
# 600 單位為秒
gsettings set org.gnome.desktop.session idle-delay 600

關閉升級版本(Upgrade)通知

1
sudo sed -i 's/Prompt=lts/Prompt=never/' /etc/update-manager/release-upgrades

開啟防火牆

1
2
sudo ufw enable
sudo ufw default deny incoming

設定網路環境(固定 IP)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Set network interface
sudo tee --append /etc/network/interfaces <<< ''
sudo tee --append /etc/network/interfaces <<< '# The primary network interface'
sudo tee --append /etc/network/interfaces <<< "auto $device"
sudo tee --append /etc/network/interfaces <<< "iface $device inet static"
sudo tee --append /etc/network/interfaces <<< "address $ipaddr"
sudo tee --append /etc/network/interfaces <<< 'netmask $netmask'
sudo tee --append /etc/network/interfaces <<< 'gateway $gateway'
sudo tee --append /etc/network/interfaces <<< "hwaddress $mac"
sudo tee --append /etc/network/interfaces <<< 'dns-nameservers 1.1.1.1 8.8.8.8'

# Flush ip address
sudo ip addr flush $device
sudo systemctl restart networking.service

# Add nameservers
sudo tee --append /etc/resolv.conf <<< 'nameserver 1.1.1.1'
sudo tee --append /etc/resolv.conf <<< 'nameserver 8.8.8.8'

安裝 SSH

1
2
3
4
5
6
7
8
9
10
11
12
13
# 安裝 OpenSSH Server
sudo apt install -y openssh-server

# 修改 SSH Port 為 6666
sudo sed -i 's/Port 22/Port 6666/g' /etc/ssh/sshd_config

# 禁止 Root 登入
sudo sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
sudo systemctl restart ssh.service
sudo systemctl enable ssh.service

# 若有開啟防火牆則建立允許規則
sudo ufw allow 6666/tcp

安裝 xRDP 與 Xfce4 桌面環境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 安裝 xRDP
sudo apt install -y xrdp

# 修改 xRDP Port 為 9999
sudo sed -i 's/port=3389/port=9999/g' /etc/xrdp/xrdp.ini
sudo systemctl restart xrdp.service
sudo systemctl enable xrdp.service

# 若有開啟防火牆則建立允許規則
sudo ufw allow 9999/tcp

# Set Xfce4 to be xRDP default desktop environment
sudo sed -i 's/. \/etc\/X11\/Xsession/#. \/etc\/X11\/Xsession/g' /etc/xrdp/startwm.sh
sudo tee --append /etc/xrdp/startwm.sh <<< 'startxfce4'

安裝 Chrome

1
2
3
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y -f ./google-chrome-stable_current_amd64.deb
rm -f google-chrome-stable_current_amd64.deb

安裝字型 Source Code Pro

系統字型

1
2
3
4
sudo mkdir -p /usr/share/fonts/opentype
sudo apt install -y git
sudo git clone https://github.com/adobe-fonts/source-code-pro.git /usr/share/fonts/opentype/source-code-pro
sudo fc-cache -f -v

使用者字型

1
2
3
4
5
6
7
8
9
10
mkdir -p "$FONT_HOME/adobe-fonts/source-code-pro"
# find "$FONT_HOME" -iname '*.ttf' -exec echo '{}' \;

sudo apt install -y git
(git clone \
--branch release \
--depth 1 \
'https://github.com/adobe-fonts/source-code-pro.git' \
"$FONT_HOME/adobe-fonts/source-code-pro" && \
fc-cache -f -v "$FONT_HOME/adobe-fonts/source-code-pro")

安裝 VSCode

安裝 VSCode 主程式

1
2
3
4
5
6
7
8
9
sudo apt install -y curl
sudo curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f microsoft.gpg

sudo apt install -y apt-transport-https
sudo apt update
sudo apt install -y code

安裝 VSCode 擴充元件與建立使用者自訂設定

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 安裝擴充元件
code --install-extension abusaidm.html-snippets
code --install-extension bierner.markdown-emoji
code --install-extension bierner.markdown-preview-github-styles
code --install-extension felixfbecker.php-debug
code --install-extension felixfbecker.php-intellisense
code --install-extension felixfbecker.php-pack
code --install-extension formulahendry.auto-close-tag
code --install-extension formulahendry.auto-rename-tag
code --install-extension MS-CEINTL.vscode-language-pack-zh-hant
code --install-extension mshr-h.systemverilog
code --install-extension mshr-h.veriloghdl
code --install-extension slevesque.vscode-hexdump
code --install-extension xabikos.JavaScriptSnippets
code --install-extension Zignd.html-css-class-completion

# 若使用者自訂設定檔案存在,則複製
if [ -f ./settings.json ]; then
cp ./settings.json ~/.config/Code/User/settings.json
fi
0%