Ubuntu 20.04 best configuration guide for Engineers

Time:2020-9-15

Recently, Ubuntu released 20.04 lts version, and I installed it for the first time. Since various Linux distributions are not out of the box like MacOS and windows, a lot of configuration is needed. You need to consult various materials for each configuration. Although there are many configuration articles on the network, there are basically some problems:

  1. Only teach how to do, don’t say why;
  2. The document is old and not updated;
  3. The content is missing and not rich

Therefore, I hope to compile a best configuration guide, which not only records what needs to be done, but also explains the principle and technical background behind it. On the one hand, it is convenient for me to consult in the future. On the other hand, I also want to share this guide with you and gradually improve it with you.Therefore, this is a continuously updated, practical operation principle, rich content of the best configuration guide.

Official accountBaronTalk, reply to Ubuntu to download the latest PDF version of the configuration document.

1、 System configuration

1. Turn off sudo password

To avoid entering the password every time we use the sudo command, we can turn the password off. Operation method:

  1. Terminal input commandsudo visudo, open visudo;
  2. find%sudo ALL=(ALL:ALL) ALLChange the line to read%sudo ALL=(ALL:ALL) NOPASSWD:ALL

2. Modify the software source

The default software source of Ubuntu is overseas, and there will be some speed problems. We can select the domestic image in “software & Updates”.

Ubuntu 20.04 best configuration guide for Engineers

3. Update the system

#Update local package database
sudo apt update

#Update all installed packages (you can also use full upgrade)
sudo apt upgrade

#Automatically remove unwanted packages
sudo apt autoremove

Here, several common cleaning commands are added:

command describe
apt autoclean Remove the. DEB installation file of the deleted package from your hard disk
apt clean Same as above, but the installation package of installed software package will be deleted
apt autoremove Remove packages that were installed to satisfy the dependencies of other packages, but are no longer needed now
Apt remove [package name] Remove installed packages (keep profile)
Apt — purge remove [package name] Remove installed packages without retaining configuration files

4. High resolution screen adaptation

By default, UI elements appear too small in high screen, so you need to adjust the scale of the interface. Ubuntu20.04 is the GNOME desktop by default. Gnome can be downloaded from theSettings > displaysIn order to adjust the screen scale by integer multiple. It can also be set by using the following command:

#Scaling factor can only be set to integers 1 = 100%, 2 = 200%, 3 = 300%
gsettings set org.gnome.desktop.interface scaling-factor 2

For integer multiple scaling settings, UI elements on some devices are either too large or too small, so we need to further adjust them.

Use the following command to view the window system (usually Wayland / X11) on your Linux device

echo $XDG_SESSION_TYPE

Wayland

For Wayland, use the following command to start the experimental non integer multiple scaling function.

gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"

Then open it againSettings>DisplaysTo select non integer multiple scaling (125%, 150%, 175%). Ubuntu20.04 is already inSettings>DisplaysProvides a graphical interface to turn on the experimental non integer multiple zoom function, so there is no need to open it through the above command.

I’ve tried it out, but it doesn’t work properly on my device. I judge that it is because the default window system of ubuntu20.04 is X11 instead of Wayland. If you have Wayland on your device, it should be set normally. Or you can choose Ubuntu on Wayland when you log in to your desktop system, which is also theoretically possible.

X11

For X11, we can use scaling factor and xrandr to achieve non integer multiple scaling, which can make TTF font be scaled correctly and prevent blurring when using xrandr alone. You can use gsettings or use theSettings>DisplaysTo specify the magnification factor and xrandr to specify the reduction factor.

First, set the interface scaling factor to the minimum factor of “UI looks too big”, which is usually 2 (200%). If it is not large enough, continue to try a factor of 3 or greater. Then use xrandr to set the reduction factor, which I set to 1.25. If the UI looks too large, it will increase the coefficient, otherwise it will decrease the coefficient. The order is as follows:

xrandr --output DP-4 --scale 1.25x1.25

You may encounterwarning: output DP-4 not founnd; gnoringOr the interface does not change after executing the command. At this point you need to executexrandrCommand to view your output parameters (that is, the name of the current display interface, the log shows connected), for example, DP-4 on my device.

<div align=”center”><img width = “80%” align=center /></div>

After the command is executed correctly, the UI element may be too small. Go backSettings>DisplaysTo see if the integer multiple scaling has been restored to 100%, and if it is to re select the appropriate scale (such as 200%).

After restart, the setting of xrandr will be invalid. We can set a script to start automatic execution, such as start- service.sh :

# start-service.sh
#!/bin/bash
xrandr --output DP-4 --scale 1.25x1.25
exit 0

Then start- service.sh Grant executive authority

sudo chmod +x start-service.sh

Then search for “sartup applications” in Ubuntu and add the script:

Ubuntu 20.04 best configuration guide for Engineers

At this point, it can perfectly support 4K screen display.

5. Install Python 2

Ubuntu 20.04 comes with Python 3, but some third-party tools or scripts still use Python 2, so we need to install them ourselves

apt install python

6. Install Git

apt install git

7. Chinese input method

Because Sogou input method does not support ubuntu20.04 at present, and it is not friendly to high-resolution screen support, so IBus libpinyin is no longer selected.

#Installation
sudo apt install ibus-libpinyin 
sudo apt install ibus-clutter

Then find “language support” in the application and change “keyboard input method system” to “IBus”. Restart the system, and then in theSettings > region & language > input sourcesChinese input method can be used by adding “Chinese (Intelligent Pinyin)”.

2、 Build your command line tool (Terminator & Zsh)

1. Install terminator

If you are used to iterm2 on the Mac platform, you will love its split screen function. However, the terminal provided by Ubuntu is not easy to use. Fortunately, there are various open source terminals under Linux. I recommend terminator, which is powerful, such as iterm2, and supports split screen.

#Installation
sudo add-apt-repository ppa:gnome-terminator
sudo apt update
sudo apt install terminator

The default interface of terminator is ugly, but the configuration is flexible. You can adjust it according to your preference.

2. Configure shell (install Zsh and oh my Zsh)

After finishing terminal, configure the shell. Execute the following command:

cat /etc/shells

You can see that Ubuntu has built-in shells:

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh

Bash is the default shell used by most Linux distributions on the market, but Zsh is much more powerful than bash.

#Installing Zsh
apt install zsh

#Set Zsh as the system default shell
sudo chsh -s /bin/zsh

However, the configuration of Zsh is too complex. Fortunately, someone has developed oh my Zsh, which can make it easier for us to configure Zsh.

#Automatic installation. If you don't install git, you need to install git first
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

#Or you can choose to install it manually
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

Restart terminal and you’ll see the change.

3. Zsh configuration

The configuration of Zsh is mainly concentrated in ~ /. Zshrc file. For example, we can configure aliases for common commands

alias cls='clear'
alias ll='ls -l'
alias la='ls -a'
alias vi='vim'
alias grep="grep --color=auto"

Or choose a theme for Zsh

ZSH_THEME="robbyrussell"

Oh my Zsh has many built-in themes. The corresponding theme files are stored in ~ /. Oh my Zsh / themes directory. You can select or edit themes according to your preferences.

4. Zsh plug-in installation

Oh my Zsh also supports various plug-ins, which are stored in ~ /. Oh my Zsh / plugins directory. Here are some suggestions:

Autojump: quick switch directory plug-in

#Installation
apt install autojump

#Use
j Document/

Zsh autosuggestions: a historical command suggestion plug-in for command line command typing

#Installation
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Zsh syntax highlighting: command line syntax highlighting plug-in

#Installation
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

After the plug-in is installed, it needs to be configured in ~ /. Zshrc file before it can be used. The configuration is as follows:

#Open the ~ /. Zshrc file, find the following line of configuration code, and append the plug-in name after it
Plugins = (other plug-ins name autojump Zsh autosuggestions Zsh syntax highlighting)

5. Fun command line toys

With terminator and Zsh configured, we can also add some interesting toys to the command line.

CMatrix(https://github.com/abishekvas…

Terminal hacker empire screen saver

#Installation
sudo apt install cmatrix

#Run (plus the - LBA parameter looks more like a movie, plus the - ol parameter looks more like a win / Mac screen saver)
cmatrix

design sketch:

Ubuntu 20.04 best configuration guide for Engineers

Steam Locomotive(https://github.com/mtoyoda/sl)

Terminal small train dynamic efficiency

#Installation
sudo apt install sl

#Operation
sl

design sketch:

Ubuntu 20.04 best configuration guide for Engineers

Screenfetch(https://github.com/KittyKatt/…

The bash screenshot information tool is used to display system information and ASCII Linux distribution icon on the terminal

#Installation
sudo apt install screenfetch

#Operation
screenfetch

design sketch:

Ubuntu 20.04 best configuration guide for Engineers

3、 Software installation

1. Install clam (set up a Tizi, you know)

Step 1: arrive https://github.com/Dreamacro/clash/releases Download the latest version of dash for Linux, for example: crash-linux-amd64-v0.19.0.gz. After decompressing, the executable file crash-linux-amd64-v0.19.0 is obtained

tar -zxvf clash-linux-amd64-v0.19.0.gz

Step 2: use the MV command to move to / usr / local / bin / crash:

sudo mv clash-linux-amd64-v0.19.0 /usr/local/bin/clash

Step 3: input sudo Chmod + X / usr / local / bin / crash to add the execution permission;

sudo chmod +x /usr/local/bin/clash

Step 4: the terminal executes the crash command and runs crash;

#Run crash
clash

Two files are generated in the / home / {user ID} /. Config / crash Directory: config.yaml And Country.mmdb ; Editor config.yaml File, configure proxy server information and rules, some businesses will provide yaml file, download and copy it;

Restart crash (close and re open the terminal, execute the crash command) to load the updated configuration file;

Keep the crash running and open the browser for access clash.razord.top Configure the policy, select the proxy line, etc. (you may need to enter IP, port and password according to the prompt, and the specific content can be found in config.yaml View in;

Keep the crash running and set the manual proxy in the system network settingsSettings > Network > network proxy > manual, configuration information reference config.yaml Or log output by the terminal when starting crash. At this point, you can access the network through crash.

After the configuration is done in the previous way, the terminal needs to be opened and the crash command is executed every time the system starts. The terminal can not be closed, otherwise the whole crash process will be finished. If you don’t want to keep the terminal open all the time, you can use the nohup crash command to start the background operation. Or if you want to start the crash automatically, you can set thenohup clashThis command adds to the start mentioned earlier- service.sh Scriptedlast

2. Install typoa (open source markdown editor)

# or run:
# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
wget -qO - https://typora.io/linux/public-key.asc | sudo apt-key add -

# add Typora's repository
sudo add-apt-repository 'deb https://typora.io/linux ./'
sudo apt update

# install typora
sudo apt install typora

3. JetBrains family bucket

After installing the toolbox app of JetBrains, you can install all kinds of IDE, including Android studio.

Ubuntu 20.04 best configuration guide for Engineers

4. Installation of other applications

If the. DEB installation file of Ubuntu version has been provided on the official website, you can download the. DEB installation file on the official website and execute the following command to install it:

#Installation
sudo apt install ./<file>.deb

If you are an earlier Linux distribution, you need to use the following command to install (the same below)

sudo dpkg -i <file>.deb
sudo apt-get install -f # Install dependencies
application Download address
Chrome https://www.google.com/chrome
VS Code https://code.visualstudio.com
ZOOM https://zoom.us/download#client_4meeting
WPS https://www.wps.cn/product/wpslinux
NetEase cloud music https://music.163.com/#/download
Baidu network disk Baidu network disk? What are you doing with this rubbish thing!!!

Note: some applications are not controlled by the scale scaling factor, so even in theSettings > displaysWhen the scale is set to 200%, the UI elements are still too small in the high screen. For example: zoom, Netease cloud music, etc., in order to solve this problem, you can use the following command to start, which can be displayed normally.

#Start zoom, and the zoom ratio can be adjusted according to your needs
QT_SCALE_FACTOR=2 zoom

#Launch Netease cloud music
QT_SCALE_FACTOR=2 netease-cloud-music

5. Use deepin wine to install QQ / Tim / wechat / Office /

For the official website does not provide the Ubuntu version. DEB installation file, but some applications in deepin can be installed by using deepin wine.

Wine is a technology that implements part of windows system API on Linux platform, which allows users to use Windows platform applications seamlessly on Linux platform.

Deepin wine is a modified wine program on deepin Linux by the deep community in China, and many windows software, such as wechat, QQ, Tim, are ported on the deepin wine.

Someone on GitHub has developed a project called deepin wine Ubuntu, which has migrated deepin wine and various DEB software packages adapted on it to Ubuntu. To install wechat, QQ and other software, we need to install deep wine Ubuntu first. The method is as follows:

#First, clone deepin wine Ubuntu source code to the local
git clone [email protected]:wszqkzqk/deepin-wine-ubuntu.git

#Switch to the source directory
cd deepin-wine-ubuntu

#Install script authorization
sudo chmod +x install_2.8.22.sh

#Install deep wine Ubuntu
./install_2.8.22.sh

After the installation of deep wine Ubuntu is completed, we can download various DEB software provided by the deep community. The specific installation method is the same as that in Section 4

#Installation
sudo apt install ./<file>.deb

Download address of various DEB software provided by deep community:

Software Download address
QQ https://mirrors.aliyun.com/deepin/pool/non-free/d/deepin.com.qq.im
TIM https://mirrors.aliyun.com/deepin/pool/non-free/d/deepin.com.qq.office
WeChat https://mirrors.aliyun.com/deepin/pool/non-free/d/deepin.com.wechat

More installation methods and software address can refer to https://github.com/wszqkzqk/deepin-wine-ubuntu

If your system language is not Chinese, the software launched through deepin wine will be garbled in Chinese. You need to add / opt / deepinwine / tools/ run.sh Wine in file_ The line of CMD is amended as follows:

WINE_CMD="LC_ALL=zh_CN.UTF-8 deepin-wine"

6. Install RMP format software

Many software only provide RMP format installation package, but not DEB format installation package, such as XMIND. Therefore, we need to convert it to DEB installation package and install it again. Let’s take XMIND as an example to see how to operate.

For example, we downloaded xmind-2020.rpm:

#Add universe repository (if not added)
sudo add-apt-repository universe

#Update
sudo apt update

#Install alien
sudo apt install alien

#Convert the. RPM package to. DEB package (a DEB installation package will be generated in the current directory, such as xmind-2020. DEB)
sudo alien XMind-2020.rpm

#Installation
sudo dpkg -i XMind-2020.deb

4、 Desktop beautification

1. Install tweet

sudo apt install gnome-tweak-tool

2. Install plug-in extension support

#Let Gnome support plug-in extensions
sudo apt install gnome-shell-extensions 

#Chrome browser extension support, you can use the browser to install plug-ins
sudo apt install chrome-gnome-shell

3. List of common plug-ins

Plug in name explain
Dash to Dock Custom dock
Screenshot Tool Screenshot plug-in
Clipboard Indicator Expand the pasteboard to see the historical pastes
Coverflow Alt-Tab Modify alt tab to apply switching effect
Applications Menu Add an application entry in the top status bar
OpenWeather The top status bar displays weather data
Places Status Indicator Add file directory access entry to the top status bar
Status Title Bar Displays the title of the current window in the top status bar
GTK Title Bar Remove title bar for non GTK applications
Hide Top Bar Auto hide status bar
Transparent Top Bar Transparent status bar

More extension plug-ins are available https://extensions.gnome.org Explore.

4. Theme

Various desktop themes, shell themes and icon themes can be downloaded from gnome-look

Install desktop or shell themes

#Unzip the downloaded theme file
tar -xvf  FileName.tar  //Decompress

#Copy the extracted theme file to / usr / share / themes
sudo cp -r FileName /usr/share/themes

Install icon theme

#Unzip the downloaded theme file
tar -xvf  FileName.tar  //Decompress

#Copy the extracted theme file to / usr / share / icons
sudo cp -r FileName /usr/share/icons

After that, open tweets and select the theme to install

Ubuntu 20.04 best configuration guide for Engineers

5. Wallpaper

Several websites for downloading 4K 8K UHD wallpaper are recommended:

https://pixabay.com

https://unsplash.com

https://wallpapersite.com

https://wallpapershome.com

Finally, post a beautified desktop (applications theme: suru + +; icons theme: reverse)

Ubuntu 20.04 best configuration guide for Engineers

5、 Use problem record

Problem 1: the time of windows and Ubuntu is not unified

If you are a dual system, after installing Ubuntu and setting the system time, you will find that the time is not uniform when you return to windows. In order to understand why, we need to understand some basic knowledge first:

  • UTC(coordinated universal time), coordinated universal time (universal time);
  • GMTGreenwich mean time, Greenwich mean time.

Windows and UNIX like systems (UNIX / Linux / MAC) treat the hardware time differently

  • Windows regards computer hardware time as local time, so the time displayed in Windows system is the same as that displayed in BIOS.
  • The UNIX like system takes the computer hardware time as UTC, so after the system starts, it will add the number of time zones set by the computer (8 for China). Therefore, the time displayed in Ubuntu is always 8 hours faster than that in windows.

When you set the system display time correctly in Ubuntu, the computer hardware time will be reduced by 8 hours from this time, so when you switch to Windows system, it is 8 hours slower, which is why.

Solution: in Ubuntu, change the computer hardware time to system display time, that is, disable UTC in Ubuntu

timedatectl set-local-rtc 1 --adjust-system-clock

Question 2: Ubuntu circular login

I encountered this problem in Ubuntu 19.10, but I didn’t verify it in version 20.04. I’m not sure if there is the same problem.

Before solving the problem, a key knowledge point is added: display manager, which is used to provide graphical login, display graphical login interface to users, and handle user authentication. Common display managers in Linux include gdm3, KDM, lightdm, etc

  • Gdm3: gdm3 is the successor of GDM, which is the display manager of gnome;
  • KDM: KDM is the display manager of KDE;
  • Lightdm: lightdm is a lightweight display manager, which is the standard solution of display manager.

reason:

The initial conclusion is that automatic login is enabled in the settings, which triggers some bug in dgm3. (Ubuntu 19.10 uses GNOME desktop system by default, and gdm3 is Gnome display manager)

Solution: replace gdm3 with lightdm

Step 1: install lightdm (since you can’t access the graphical desktop, you need to use the CTL + Alt + F2 shortcut key on the login page to enter the command line mode, enter the account password to log in, and then use the following command to install)

sudo apt-get install lightdm

After the installation, the system will automatically pop up a box asking you to select the display manager installed in the current system and select lightdm.

Step 2: restart

sudo reboot

You can log in normally after restarting.

At this time, you will find that the login interface has changed. If you want to switch back to the previous login interface, turn off the automatic login after entering the system, and then implement the following command to re select the gdm3 display manager

sudo dpkg-reconfigure gdm3

The gdm3 bug can not be avoided after the auto login is turned off. This may only apply to my Ubuntu 19.10 installation; the reason I’m talking about here may not be applicable to everyone. But one thing is certain, if there is a circular login situation, replacing the display manager can usually solve the problem.

If you want to view the display manager currently running on the system, you can use the following command:

cat /etc/X11/default-display-manager

Problem 3: NVIDIA driver repair

Ubuntu 20.04 comes with NVIDIA graphics card driver, but I accidentally play bad. It is mainly manifested in the following aspects:

  1. The xrandr command mentioned above is invalid, and can’t realize decimal scaling;
  2. Open the NVIDIA X server settings client;
  3. Command line executionnvidia-settingsCommand error;
  4. Settings > displaysCannot set multiple resolutions and so on.

If you have the same problem as me, or if you want to install the graphics driver manually, you can follow the steps below. (you need to download the video card driver of your device from NVIDIA official website first)

#Install some dependent libraries first
sudo apt install build-essential libglvnd-dev pkg-config

#Stop the desktop manager and enter the command line
sudo telinit 3

#Remove installed NVIDIA drivers
sudo apt purge "nvidia*"

#Manual installation of graphics card driver
sudo bash NVIDIA-Linux-x86_64-440.82.run 

#Restart
sudo reboot

For more installation methods of graphics card drivers, please refer to: https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-20-04-focal-fossa-linux


Reference documents:

  • Hidpi š non integer multiple scaling # non integer multiple scaling)
  • The ultimate shell
  • How to install the NVIDIA drivers on Ubuntu 20.04 Focal Fossa Linux

This document will continue to update, pay attention to the official account.BaronTalk, reply to Ubuntu to download the latest PDF version of the configuration document.