0. 安裝 epel 源html
$ sudo yum install epel-release.noarchnode
若是想強制服務器使用 tuna 的鏡像,能夠以下修改 /etc/yum.repos.d/epel.repo,
python
[epel] name=Extra Packages for Enterprise Linux 7 - $basearch baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch #metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug #metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS #metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1
而後更新 package cache,使用命令 $ sudo yum makecache 測試一下。mysql
1. 高分屏字體調整linux
$ sudo yum install gnome-tweak-tool.noarchgit
Applications > Accessories > Tweaks > Fonts > Scaling Factor sql
2. 支持 exfat 的 U 盤shell
添加 nux 源,npm
$ sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpmdjango
由於 nux 倉庫和其它第三方倉庫可能有兼容性問題,因此通常不建議啓用 nux 倉庫,打開文件 /etc/yum.repos.d/nux-dextop.repo,修改 enable=0
安裝 exfat 相應驅動,
$ sudo yum --enablerepo=nux-dextop install fuse-exfat exfat-utils
注意:安裝完成以後,插入 exfat 格式的 U 盤,可能不能自動掛載,這時就只能手動 mount 使用了,例如 $ sudo mount -t exfat /dev/sdb1 /mnt/
3. 編譯安裝 python3.7 (默認的 $ sudo yum install python36.x86_64,安裝的版本是 3.6)
參見:http://www.javashuo.com/article/p-rxspnbbu-ge.html
4. 編譯安裝 gvim 8.x (默認的 $ sudo yum install vim-X11.x86_64 ,安裝的版本是 7.x ,ycmd 補全時,會有些許兼容性問題)
參見:http://www.javashuo.com/article/p-nwewnnxb-gk.html
5. 安裝 emacs 及 ycmd 相關配置工具
# yum install vim-X11.x86_64
# yum install emacs.x86_64
# yum install clang.x86_64
# yum install python-devel.x86_64
# yum install cmake
6. 一些小工具
# yum install p7zip.x86_64 # 注意,CentOS 下的 7z,使用命令爲 "7za"
# yum install tree.x86_64
# yum install chromium.x86_64
# yum install screen.x86_64
7. Python3 異步開發相關
# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ aiohttp
# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ jinja2
# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ aiomysql
# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ flask
# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ mysql-connector-python
# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ sqlalchemy
8. 安裝 pycharm 和 vscode
參見官方網站。
9. 安裝配置 mysql 5.7
注意:在安裝 CentOS Server with GUI 版本時,選擇軟件的時候,最好不要選擇安裝 MariaDB,不然以後安裝 MySQL 可能會出現兼容性問題。若是已經默認安裝 MariaDB,則卸載方法以下:
# rpm -qa | grep mariadb # 檢查相關包
# yum remove akonadi-mysql-1.9.2-4.el7.x86_64
# yum remove mariadb-server-5.5.60-1.el7_5.x86_64
# yum remove mariadb-5.5.60-1.el7_5.x86_64
# yum remove mariadb-libs-5.5.60-1.el7_5.x86_64
參見: http://www.javashuo.com/article/p-pdwwmllh-go.html
10. 安裝 MySQL python 接口 mysqlclient (Django need this)
# yum install mysql-community-devel.x86_64
# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ mysqlclient
11. 編譯安裝 sqlite3
由於 CentOS7 默認的 sqlite3 版本是 3.7.17,而 django 2.2.1 本地開發要求 sqlite3 版本最小爲 3.8.3,因此須要編譯安裝。
獲取源代碼包 https://www.sqlite.org/download.html sqlite-autoconf-3280000.tar.gz
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
$ sudo mv /usr/bin/sqlite3 /usr/bin/sqlite3.ori.bak
$ sudo ln -s /usr/local/bin/sqlite3 /usr/bin/sqlite3
$ sudo
$ sudo ldconfigecho "/usr/local/lib" > /etc/ld.so.conf.d/sqlite3.conf
這樣 sqlite 會裝在 /usr/local/bin/ 下,由於在 CentOS 的默認 PATH 路徑中 /usr/local/bin/ 在 /usr/bin/ 以前,因此最終生效的就是這個新安裝的 sqlite3 (能夠把 /usr/bin/sqlite 刪掉了),測試以下,
$ which sqlite3 /usr/local/bin/sqlite3 $ sqlite3 --version 3.28.0 2019-04-16 19:49:53 884b4b7e502b4e991677b53971277adfaf0a04a284f8e483e2553d0f83156b50 $ python3 Python 3.6.8 (default, Apr 25 2019, 21:02:35) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> import sqlite3 >>> sqlite3.sqlite_version '3.28.0' $ python Python 2.7.5 (default, Apr 9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import sqlite3 >>> sqlite3.sqlite_version '3.28.0'
12. 安裝 rar
由於 7za 在 CentOS 上不支持 rar 壓縮解壓 ( RAR (it was removed due a non-free license) ),因此須要安裝專有工具 rar,
下載安裝包 https://www.rarlab.com/download.htm RAR 5.71 for Linux x64
解壓縮後,不用編譯,直接 sudo make install,則 rar 和 unrar 會自動安裝在 /usr/local/bin 下,通常僅使用 rar 便可。
經常使用命令選項和 7za 相似, x 爲解壓,a 爲添加到壓縮包,其它選項,直接在命令行輸入 $ rar 運行查看便可。
X1. 解決 yum 安裝軟件時出現 Another app is currently holding the yum lock; waiting for it to exit...
$ sudo rm -f /var/run/yum.pid $ sudo yum install yum-cron.noarch $ sudo vim /etc/yum/yum-cron.conf
修改
[commands]
# What kind of update to use:
# default = yum upgrade
# security = yum --security upgrade
# security-severity:Critical = yum --sec-severity=Critical upgrade
# minimal = yum --bugfix update-minimal
# minimal-security = yum --security update-minimal
# minimal-security-severity:Critical = --sec-severity=Critical update-minimal
update_cmd = default
# Whether a message should be emitted when updates are available,
# were downloaded, or applied.
update_messages = yes
# Whether updates should be downloaded when they are available.
download_updates = no
X2. 筆記本電腦安裝 CentOS7 後,默認狀況下,WiFi 指示燈在鏈接狀態下,會一直保持閃爍,太晃眼睛。將其更改成鏈接狀態下常亮
查看 WiFi 的 mode 名稱,
$ lsmod | grep iwl iwldvm 189350 0 mac80211 718956 1 iwldvm iwlwifi 223575 1 iwldvm cfg80211 632335 3 iwlwifi,mac80211,iwldvm
在 /etc/modprobe.d/ 下新建配置文件 wlanled.conf (文件名可任意),
$ cd /etc/modprobe.d/ $ sudo touch wlanled.conf
打開此文件,並插入如下內容,
# Add for adjust the wifi led mode: # wifi on - light on always (CentOS7 default mode is blinking) # wifi off - light off options iwlwifi led_mode=1
Reboot 便可。
X3. 安裝 thefuck
$ sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ thefuck
配置 .bashrc
# for thefuck eval "$(thefuck --alias fuck)" # to supress the python2 warning: eval "$(thefuck --alias fuck 2>/dev/null)"
而後命令行有 typo 時就能夠 fuck 修正了。
X4. Gnome 版本查詢
$ gnome-shell --version GNOME Shell 3.28.3
X5. Gnome Night Light 色溫調節
安裝 dconf-editor
$ sudo yum install dconf-editor.x86_64
啓動 dconf-editor,在 org/gnome/settings-daemon/plugins/color/night-light-temperature,經常使用色溫值以下,
X6. Chromium 指定默認搜索引擎爲百度
Settings > Search engine > Manage search engines > Add, set as following,
Search engine: Baidu
Keyword: baidu
URL with %s in place of query: https://www.baidu.com/s?wd=%s
then, Make default.
X7. 關閉 tracker 索引功能
安裝
$ sudo yum install tracker-preferences.x86_64
運行打開 UI 配置界面,把能去掉的都去掉
$ tracker-preferences
(關於 tracker 的功能,請參閱 https://wiki.gnome.org/Projects/Tracker/WhatIsTracker)
X8. pycharm 2019.1 輸入中文的問題 (Ubuntu 18.04 沒有這個問題,CentOS7 有這個問題)
修改 .bashrc,加入以下配置
# for pycharm with zh export GTK_IM_MODULE=ibus export QT_IM_MODULE=ibus export XMODIFIERS=@im=ibus
X9. Nodejs
因爲 CentOS7 默認安裝的 gcc 版本太舊,編譯安裝 Nodejs 要先升級 gcc,因此直接使用官方的預編譯版本。
在 https://nodejs.org/en/download/ 下載 node-v10.16.0-linux-x64.tar.gz
解壓縮到 /usr/local/ 下,在 /usr/local/bin/ 下加入軟連接便可,
$ sudo ln -s /usr/local/node-v10.16.0-linux-x64/bin/node /usr/local/bin/node $ sudo ln -s /usr/local/node-v10.16.0-linux-x64/bin/npm /usr/local/bin/npm $ sudo ln -s /usr/local/node-v10.16.0-linux-x64/bin/npx /usr/local/bin/npx
X10. CentOS7添加/刪除用戶和用戶組
新建用戶 (例如 peter)
# adduser peter # passwd peter
建工做組 (例如 xxx)
# groupadd xxx
新建用戶 peter 並將其添加到工做組 xxx
# useradd -g xxx peter
將已有用戶 peter 添加到工做組 xxx
# usermod -G xxx peter
臨時關閉用戶 peter 的帳戶
# passwd peter -l
從新打開用戶 peter 的帳戶
# passwd peter -u
刪除用戶 peter 的帳戶
# userdel peter
刪除工做組 xxx
# groupdel xxx
查看當前登錄用戶
# who
查看登錄歷史記錄
# last
X11. 安裝 Opera 瀏覽器
導入已簽名密鑰
sudo rpm --import https://rpm.opera.com/rpmrepo.key
添加 repo
sudo tee /etc/yum.repos.d/opera.repo <<RPMREPO [opera] name=Opera packages type=rpm-md baseurl=https://rpm.opera.com/rpm gpgcheck=1 gpgkey=https://rpm.opera.com/rpmrepo.key enabled=1 RPMREPO
更新本地 cache 及安裝
$ sudo yum makecache $ sudo yum install opera-stable.x86_64
更多信息參見 https://rpm.opera.com/manual.html
Debian 系列可參考 https://deb.opera.com/manual.html
X12. 關閉 SELinux
$ sudo vim /etc/selinux/config
改成,
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
reboot 後,查看結果,
$ sestatus
X13. 關閉 kdump
$ sudo service kdump stop $ sudo chkconfig kdump off $ reboot
X14. 安裝 redhat-lsb (這樣就能使用 lsb_release -a 查看當前系統的版本信息了)
$ sudo yum install redhat-lsb
X15. 升級 Git (直接官網下載 tarball,編譯安裝便可)
$ tar --xz -xvf git-2.23.0.tar.xz $ cd git-2.23.0/ $ ./configure --prefix=/usr/local $ make $ sudo make install # (若是 PATH 中 /usr/bin 在 /usr/local/bin 以前,則備份好原文件,作軟鏈接,添加 load config 文件到 /etc/ld.so.conf.d/xxx.conf,而後 sudo ldconfig) $ git --version git version 2.23.0
Note: tarball 方式安裝的 Git 沒有 tab 自動補全功能,解決方法以下:
$ cp git-2.23.0/contrib/completion/git-completion.bash ~/.git-completion.bash
在 ~/.bashrc 中添加語句,
source ~/.git-completion.bash
而後 source .bashrc 便可。
X16. Linux 下 PDF 分割,剪切,合併等神器 cpdf
直接下載預編譯的二進制文件,將對應系統的文件拷貝到 /usr/local/bin 下便可。
下載地址及經常使用操做方法見: http://community.coherentpdf.com/
(待續)