本文記錄在OpenSUSE Leap桌面環境中進行系統配置,安裝常用軟件。

Initial Settings

初始化操作,如配置sudo、更換repo、更新更新系統等。

sudo Privileges

爲當前用戶配置sudo權限,將其加入用戶組wheel

sudo設置

1
2
[[ -f /etc/sudoers ]] || zypper in -yl sudo 1> /dev/null
sed -r -i 's@#*[[:space:]]*(%wheel[[:space:]]+ALL=\(ALL\)[[:space:]]+ALL)@# \1@;s@#*[[:space:]]*(%wheel[[:space:]]+ALL=\(ALL\)[[:space:]]+NOPASSWD: ALL)@\1@' /etc/sudoers

如果是當前用戶,可執行如下操作

1
2
3
# add user to group wheel
sudo gpasswd -a $USER wheel
# sudo usermod -a -G wheel $USER

如果是創建新用戶(ordinary user),可執行如下操作

1
2
sudo useradd -mN -G wheel "$new_username" 1> /dev/null
sudo bash -c "echo $new_password | passwd --stdin $new_username &> /dev/null"

/etc/hosts

修改hosts文件,數據來自racaljk/hosts,如何從GitHub下載單個文件,可參考本人的Use Script Download Single File From GitHub

1
2
3
sudo cp -pv /etc/hosts{,.bak}
sudo systemctl restart network.service
#or NetworkManager.service

Change Repositories

更換鏡像源,中國大陸地區可選擇aliyunUCTS的鏡像源。

可通過如下命令查看本機外網IP是否屬於中國大陸地區

1
curl -fsSL ipinfo.io | sed -r -n '/country/s@.*\: \"(.*)\",@\[email protected]'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
version_id=$(sed -r -n '/^VERSION_ID=/s@.*="?([^"]*)"?@\L\[email protected]' /etc/os-release)
[[ ${version_id%%.*} -eq 42 ]] && repo_keyword="leap/$version_id" || repo_keyword="$version_id"
sudo zypper mr -da
# Repo 1 - USTC
sudo zypper ar -fcg https://mirrors.ustc.edu.cn/opensuse/distribution/$repo_keyword/repo/oss USTC:$repo_keyword:OSS &> /dev/null
sudo zypper ar -fcg https://mirrors.ustc.edu.cn/opensuse/distribution/$repo_keyword/repo/non-oss USTC:$repo_keyword:NON-OSS &> /dev/null
sudo zypper ar -fcg https://mirrors.ustc.edu.cn/opensuse/update/$repo_keyword/oss USTC:$repo_keyword:UPDATE-OSS &> /dev/null
sudo zypper ar -fcg https://mirrors.ustc.edu.cn/opensuse/update/$repo_keyword/non-oss USTC:$repo_keyword:UPDATE-NON-OSS &> /dev/null
# Repo 2 - aliyun
sudo zypper ar -fcg https://mirrors.aliyun.com/opensuse/distribution/$repo_keyword/repo/oss/ aliyun-Oss
sudo zypper ar -fcg https://mirrors.aliyun.com/opensuse/distribution/$repo_keyword/repo/non-oss/ aliyun-Non-Oss
sudo zypper ar -fcg https://mirrors.aliyun.com/opensuse/update/$repo_keyword/oss aliyun-Update-Oss
sudo zypper ar -fcg https://mirrors.aliyun.com/opensuse/update/$repo_keyword/non-oss/ aliyun-Update-Non-Oss
# Refresh all repositories
sudo zypper ref 1> /dev/null
unset version_id
unset repo_keyword

System Update

執行如下命令更新系統

1
2
3
4
5
6
7
8
9
10
11
12
# Refresh all repositories
sudo zypper ref -f 1> /dev/null
# Update installed packages with newer versions
sudo zypper up -yl 1> /dev/null
# Perform a distribution upgrade
sudo zypper dup -l 1> /dev/null
# Install needed patches.
sudo zypper patch -yl 1> /dev/null
# sudo zypper pchk -yl 1> /dev/null

Essential Packages

根據個人情況選擇安裝

1
2
3
4
sudo zypper in -yl bash-completion rng-tools haveged &> /dev/null
sudo zypper in -yl psmisc tree &> /dev/null
# sudo zypper in -yl nmap tcpdump traceroute iproutes &> /dev/null
# sudo zypper in -yl ftp lftp wget curl &> /dev/null

bash-completion可在Termianl中,實現命令在Tab下自動補全

1
zypper se --match-words bash-completion

Change Timezone

執行如下命令更改時區爲Asia/Shanghai,通過chrony同步網路時間

1
2
3
4
5
6
7
8
9
10
# install chrony, and remove ntp
sudo zypper in -yl chrony -ntp
[[ -f /etc/ntp.conf.rpmsave ]] && sudo rm -f /etc/ntp.conf.rpmsave
sudo systemctl start chronyd.service
sudo systemctl enable chronyd.service
# timedatectl setting
sudo timedatectl set-timezone Asia/Shanghai
sudo timedatectl set-local-rtc false
sudo timedatectl set-ntp true

命令timedatectl可查看系統時間信息

1
2
3
4
5
6
7
8
9
[email protected]:~> timedatectl
Local time: Fri 2017-02-10 14:59:20 CST
Universal time: Fri 2017-02-10 06:59:20 UTC
RTC time: Fri 2017-02-10 06:59:20
Time zone: Asia/Shanghai (CST, +0800)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
[email protected]:~>

Zypper Usage

zypper命令相關

1
2
3
4
5
# 移除軟件時自動移除不需要的依賴關係
zypper rm -yu
# 移除不需要的安裝包
zypper rm -yu $(zypper packages --unneeded | awk 'match($1,/^i/){ORS=" ";print $(NF-4)}')

參考 Remove unused packages with zypper or yast


GNome Desktop Setting

Recent Files

GNome 3桌面環境中,默認會記錄當前用戶打開的文件,在 Recent 窗口中列出。

方案1: 禁止Recent按鈕出現,參考鏈接,通過gsettings設置

1
2
3
gsettings get org.gnome.desktop.privacy remember-recent-files
gsettings set org.gnome.desktop.privacy remember-recent-files false

方案2:通過GNome Extension Recent Items手動清理,參考鏈接

可將二者結合起來使用。

Remove Unneeded Packages

移除GNome中不需要的軟件

1
2
3
4
5
6
sudo zypper rm -yu evolution totem empathy brasero bijiben
sudo zypper rm -yu gnome-{maps,music,clocks,contacts,weather}
# Game
sudo zypper rm -yu gnome-{chess,sudoku,mahjongg,mines}
sudo zypper rm -yu aisleriot swell-foop lightsoff quadrapassel iagno

Input Method

輸入法,主要是中文輸入,此處使用Fcitx框架,安裝RIME輸入法。

參考Fcitx官方文檔,順序執行如下操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# search
sudo zypper ref
zypper se fcitx*
# install fcitx and rime
sudo zypper in -y fcitx fcitx-rime
# This overwrites the system default set in /etc/sysconfig/language
sed -i '/^INPUT_METHOD=/d' ~/.profile
tee -a ~/.profile <<-EOF
INPUT_METHOD="fcitx"
EOF
fcitx-config-gtk3

Input Method窗口下方點擊符號+,取消勾選Only Show Current Language後,在搜索框中輸入rime進行搜索,點擊添加。

參考官方文檔Install input method,執行如下操作重啓fcitx服務。

1
fcitx -r

通過組合鍵Ctrl+Space啓動Rime輸入法,通過按鍵L Shift進行輸入法臨時切換。

SuSEfirewall2

此處只開啓ssh(22),http(80)端口

1
2
3
4
5
6
7
sudo command -v SuSEfirewall2 &> /dev/null || sudo zypper in -yl SuSEfirewall2 1> /dev/null
sudo SuSEfirewall2 open EXT TCP ssh http
# SuSEfirewall2 open EXT TCP ssh http https
sudo systemctl restart SuSEfirewall2 &> /dev/null
sudo systemctl enable SuSEfirewall2 &> /dev/null

Text Editor

文本編輯器

Vim Editor

在OpenSUSE/CentOS中vim編輯器的全局配置文件路徑爲

1
/etc/vimrc

具體配置過程參見本人Blog VIM Editor Configuration

Atom Editor

Atom是一款擁有豐富擴展的文本編輯器,OpenSUSE與CentOS一樣,使用rpm包,故需要下載rpm安裝包,下載鏈接

1
https://atom.io/download/rpm

下載文件名稱爲atom.x86_64.rpm,執行如下命令進行安裝

1
sudo zypper in -y ~/Downloads/atom.x86_64.rpm

Atom安裝完成後的配置及插件安裝,參見本人Blog —— Install and Configure Atom Editor


Web Browsers

Mozilla Firefox

安裝、配置過程參考本人Blog的相關部分

SRWare Iron

安裝、配置過程參考本人Blog的相關部分


Email

Thunderbird

安裝、配置過程參考本人Blog的相關部分


Database Relevent

Oracle SQL Developer

Oracle SQL Developer的下載頁面爲

1
http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html

需要JDK環境,JDK8的下載頁面

1
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

此處下載解壓即可使用的軟件包(下載目錄爲~/Downloads)

  1. jdk-8u131-linux-x64.tar.gz
  2. sqldeveloper-4.2.0.17.089.1709-no-jre.zip

安裝Shell Script如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
[[ "$UID" -ne 0 ]] && printf "Sorry, this script requires superuser privileges (eg. root, su).\n" && exit
printf "Operation is processing, just be patient!\n"
script_current_path=$(dirname $(readlink -f "$0"))
jdk_pack=$(find "$script_current_path" -type f -name "jdk*linux-x64.tar.gz" -print)
sqldeveloper_pack=$(find "$script_current_path" -type f -name "sqldeveloper*no-jre.zip" -print)
jdk_path='/opt/jdk-8'
sqldeveloper_path='/opt/sqldeveloper'
[[ -d "$jdk_path" ]] && rm -rf "$jdk_path"
mkdir -p "$jdk_path"
tar xf "$jdk_pack" -C $jdk_path --strip-components=1
[[ -d "$sqldeveloper_path" ]] && sudo rm -rf "$sqldeveloper_path"
unzip -q "$sqldeveloper_pack" -d /opt
[[ -n $USER && -z $SUDO_USER ]] && now_user="$USER" || now_user="$SUDO_USER"
[[ "$now_user" == 'root' ]] && user_home='/root' || user_home="/home/$now_user"
[[ -d $user_home/.sqldeveloper ]] && rm -rf $user_home/.sqldeveloper
sed -i '/sqldeveloper/d' $user_home/.bashrc
tee -a $user_home/.bashrc &> /dev/null <<-EOF
alias sqldeveloper='bash /opt/sqldeveloper/sqldeveloper.sh &>/dev/null &'
EOF
. $user_home/.bashrc
printf "Please execute command $(tput bold)$(tput setaf 4)%s$(tput sgr0) first;\n" "bash "$sqldeveloper_path"/sqldeveloper.sh"
printf "Then input JDK path $(tput bold)$(tput setaf 1)%s$(tput sgr0);\n" "$jdk_path"
unset script_current_path
unset jdk_pack
unset sqldeveloper_pack
unset jdk_path
unset sqldeveloper_path
unset now_user
unset user_home
# Script End

執行如下命令啓動sqldeveloper

1
bash /opt/sqldeveloper/sqldeveloper.sh

初次啓動時,出現如下交互提示

Type the full pathname of a JDK installation (or Ctrl-C to quit), the path will be stored in /home/$USER/.sqldeveloper/4.2.0/product.conf

根據提示要求,輸入JDK的路徑/opt/jdk-8即可。

查看文件~/.sqldeveloper/4.2.0/product.con,出現

1
SetJavaHome /opt/jdk-8

可通過如下命令創建命令別名

1
2
3
4
5
tee -a ~/.bashrc <<-EOF
alias sqldeveloper='bash /opt/sqldeveloper/sqldeveloper.sh &>/dev/null &'
EOF
. ~/.bashrc

References


Change Logs

  • 2017.02.10 17:23 Fri Asia/Shanghai
    • 初稿完成
  • 2017.03.16 10:02 Thu Asia/Shanghai
    • 優化,移除Docker相關
  • 2017.05.04 08:52 Thu America/Boston
    • 添加zypper命令的刪除操作
  • 2017.05.16 15:56 Tue America/Boston
    • 添加Shell Script實現sqldeveloper安裝