Yanyg - Software Engineer

LINUX(Debian)开发环境初始化

目录

1 Debian

1.2 install

sudo cp debian-10.6.0-amd64-DVD-1.iso /dev/sdc
sudo sync
sudo eject /dev/sdc
  • insert usb stick and loader from usb
  • select install(not graphical install)

2 Network

wireless card firmware MAY not installed, so no network can be builded. Find the missing firmware:

### MUST BE root
~# dmesg | grep "firmware.*failed"
### Or
~# grep "firmware.*failed" /var/log/messages
Dec 27 03:32:03 x1 kernel: [    4.456922] iwlwifi 0000:04:00.0: Direct firmware load for iwlwifi-8000C-22.ucode failed with error -2
Dec 27 03:33:07 x1 kernel: [   55.124505] bluetooth hci0: Direct firmware load for intel/ibt-11-5.sfi failed with error -2
Dec 27 03:40:37 x1 kernel: [    1.518927] i915 0000:00:02.0: Direct firmware load for i915/skl_dmc_ver1_27.bin failed with error -2

Download linux-firmware git repo by other net-connected computer:

## In other computer
~$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
# then copy the linux-firmware to usbstick and transfer to the new debian computer.

For example with 2016 x1 carbon, copy iwlwifi-8000C-22.ucode to /lib/firmware:

~# cp linux-firmware/iwlwifi-8000C-22.ucode /lib/firmware/
~# cp --parents intel/ibt-11-5.sfi /lib/firmware/
~# /sbin/reboot

Now connect to your WIFI.

3 Config /etc/apt/sources.list

Visit http://deb.debian.org is very slow in China. Use the mirror site.

deb https://mirrors.aliyun.com/debian buster main contrib non-free
deb-src https://mirrors.aliyun.com/debian buster main contrib non-free

deb https://mirrors.aliyun.com/debian-security/ buster/updates main contrib non-free
deb-src https://mirrors.aliyun.com/debian-security/ buster/updates main contrib non-free

deb https://mirrors.aliyun.com/debian buster-backports main contrib non-free
deb-src https://mirrors.aliyun.com/debian buster-backports main contrib non-free

Candidate mirror:

4 System config

  • download from github:
~$ git clone [email protected]:yygcode/system-config
~$ cd system-config
~$ ./install.sh -f
### -f means force overwrite file if exist

5 Install packages

Pleapse set /etc/apt/sources.list first.

~$ su
~# apt update
~# yes | sudo apt-get install gcc tmux terminator manpages manpages-dev \
              manpages-zh manpages-posix manpages-posix-dev \
              gconf-service gconf2-common libappindicator1 libdbusmenu-glib4 \
              libdbusmenu-gtk4 libgconf-2-4 libindicator7 \
              libappindicator3-0.1-cil ntp autoconf automake libtool cmake \
              info texinfo texi2html gettext gettext-doc autopoint \
              libasprintf-dev libgettextpo-dev libxaw7-dev libxaw3dxft8-dev \
              libxaw-doc libxt-doc libx11-dev libgtk3.0-cil-dev libwxgtk3.0-dev \
              libgnutls28-dev libtiff5-dev giflib-tools libgif-dev libjpeg-dev \
              gmp-doc libgmp10-doc libmpfr-dev gnutls-doc gnutls-bin liblzma-doc \
              libtinfo-dev libncursesw5-dev libncurses5-dev mailutils \
              mailutils-doc xaw3dg-dev libcairo2-dev librsvg2-dev \
              liblcms2-dev imagemagick libmagick++-dev libdbus-1-dev \
              libdbus-glib-1-dev libdbus-c++-dev gconf2 libgconf2-dev \
              libm17n-dev libotf-dev libxft-dev libcairo2-dev \
              gir1.2-poppler-0.18 libpoppler-dev libpoppler-glib-dev \
              libpoppler-dev libpoppler-glib-dev libpoppler-private-dev \
              global fcitx-googlepinyin fonts-arphic-bkai00mp fonts-arphic-bsmi00lp \
              fonts-arphic-gbsn00lp fonts-arphic-gkai00mp fonts-arphic-ukai \
              rdesktop mplayer ffmpeg vlc mjpegtools fonts-liberation flameshot \
              libssl-dev

6 Keymap

Change Caps and Ctrl:

6.1 vconsole

~$ cat ~/Caps2Ctrl.map
keymaps 0-127
keycode 58 = Control
keycode 29 = Caps_Lock
~$ sudo loadkeys ~/Caps2Ctrl.map

6.2 gnome

  • Search 'tweak' -> 'Keyboard & mouse' -> Additional Layout Options
    • Control position - Swap Ctrl and Caps Lock

7 Shortcuts

  • Search 'Keyboard' in gnome, Select keyboard to add additional shortcuts.
    • emacs-gui: TERM=xterm LC_CTYPE=zh_CN.UTF-8 emacs; Ctrl-Super-E
    • Screenshot: flameshot gui; Shitf-Alt-A
    • terminator: terminator; Ctrl-Super-T

8 google chrome

Install chrome:

~$ sudo apt-get install fonts-liberation libappindicator3-1
~$ sudo dpkg -i google-chrome-stable_current_amd64.deb
~$ sudo apt --fix-broken install # run if fail

9 fcitx

  • Run dpkg to add locales
~$ sudo dpkg-reconfigure locales
## Select en_US.UTF-8, zh_CN.UTF-8
  • Run Fcitx Configuration
    • Input method add and disable 'Only show current language'
    • Input method add 'Google pinyin'
    • Global config, Trigger input method set to 'Ctrl-Alt-Space'
  • Reboot
  • Try 'Ctrl-Alt-Space' switch to google-pinyin

10 emacs

  • download and compile
~$ git clone https://git.savannah.gnu.org/git/emacs.git
~$ cd emacs
~$ git checkout emacs-27.1
~$ ./configure --without-pop --with-mailutils
~$ make -j2 && sudo make install
  • config
~$ [email protected]:yygcode/.emacs.d
# Use https if you are not contributor:
~$ https://github.com/yygcode/.emacs.d.git
  • Start emacs
    • MAY need restart multi times
  • Need set LANG=zh_CN.UTF-8 if start emacs in X windows
  • Run emacs daemon
~$ emacs --daemon

11 gcc and g++ manpages

11.1 gcc

debian8还没有gcc-doc,可以用之前版本的,把下列两行加到/etc/apt/sources.list:

deb http://deb.debian.org/debian buster-backports main contrib non-free
deb-src http://deb.debian.org/debian buster-backports main contrib non-free

执行update然后install:

~$ sudo apt update
~$ sudo apt install -t buster-backports gcc-doc

11.2 g++

下载manpages,解压到 /usr/share/man/man3/目录:

~$ wget --continue --tries=0 --timeout=10 ftp://gcc.gnu.org/pub/gcc/libstdc++/doxygen//libstdc++-man.4.4.0.tar.bz2
~$ tar xvf libstdc++-man.4.4.0.tar.bz2
~$ cd libstdc++-man.4.4.0
~$ cp man3/* /usr/share/man/man3/

试试:man std::iostream.

12 Music

Download neteaseCloudMusic(网易云音乐):

wget --continue --tries=0 --timeout=10 http://d1.music.126.net/dmusic/netease-cloud-music_1.2.1_amd64_ubuntu_20190428.deb
sudo dpkg -i netease-cloud-music_1.2.1_amd64_ubuntu_20190428.deb

可以使用wine安装Windows版本,CPU使用比较高,在我的X1 Carbon上占用2个cpu核,1个80%,另一个40%左右。

13 Misc

13.1 Switch only in current workspace

[yanyg@x1{192.168.1.109} ~/Downloads ] <2020-12-29 23:14:17>
$ gsettings get org.gnome.shell.app-switcher current-workspace-only
false
[yanyg@x1{192.168.1.109} ~/Downloads ] <2020-12-29 23:15:40>
$ gsettings set org.gnome.shell.app-switcher current-workspace-only true
[yanyg@x1{192.168.1.109} ~/Downloads ] <2020-12-29 23:15:45>
$ gsettings get org.gnome.shell.app-switcher current-workspace-only
true

13.2 login screen resolution

登录界面的分辨率会导致休眠唤醒时,terminator分辨率异常,需要重新退出-进入全屏。设置登录界面的分辨率和当前登录用户的一致:

~$ sudo cp ~/.config/monitors.xml /var/lib/gdm3/.config/

13.3 disable auto upgrade

sudo systemctl disable unattended-upgrades.service
sudo systemctl stop unattended-upgrades.service