Recently Ubuntu 20.04 LTS was released and I was the first to install it. Because the various Linux distributions don’t work out of the box like MacOS and Windows, a lot of configuration is required. Each configuration needs to consult various materials, although there are many configuration articles on the network, but basically there will be some problems:

  1. Teach how, not why;
  2. The documents are old and not updated;
  3. Lack of content, not rich; .

So I wanted to put together a best practices guide that not only documented what needed to be done, but also explained the rationale 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. So this is a practical, principled, and informative guide to best practices that will be updated continuously.

Follow the BaronTalk and reply to Ubuntu to download the latest PDF version of the configuration document.

I. System configuration

1. Disable the sudo password

To avoid having to enter the password every time we use sudo, we can turn the password off. Operation method:

Step 1: Terminal input command sudo visudo, open visudo;

Step 2: Find %sudo ALL=(ALL:ALL) ALL and change this line to %sudo ALL=(ALL:ALL) NOPASSWD:ALL

2. Modify the software source

Ubuntu’s default Software source is foreign. There are some speed problems, so we can select the domestic image in “Software & Updates”.

3. Update your system

Update the local report database
sudo apt update

Update all installed packages (full-upgrade is also available)
sudo apt upgrade

# Automatically remove unwanted packages
sudo apt autoremove
Copy the code

Here are some common cleanup commands to add:

The command describe
apt autoclean Delete the. Deb installation file from the hard disk
apt clean Same as above, but the installation package of the installed software package will also be deleted
apt autoremove Remove packages that were installed to satisfy dependencies of other packages but are no longer needed
Apt remove [software package name] Deleting installed Software packages (reserving configuration files)
Apt –purge remove [package name] Deleting installed packages (without reserving configuration files)

4. High score screen adaptation

By default, UI elements are too small on a high score screen, so you need to adjust the scale of the screen. Ubuntu20.04 is the default GNOME desktop. GNOME will enable HiDPI support in **Settings>Displays ** to adjust the screen scale in multiples. It can also be set by using the following command:

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

The integer multiple zoom setting makes the UI elements look either too large or too small on some devices, so we need to adjust it further.

Use the following command to view the Window System (Graphical interface protocol) on your Linux device, usually Wayland/X11

echo $XDG_SESSION_TYPE
Copy the code

Wayland

In the case of Wayland, use the following command to enable the experimental non-integer multiple scaling feature.

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

After you turn on Settings>Displays again, you can select non-integer multiples (125%, 150%, 175%). Ubuntu20.04 already provides a graphical interface in Settings>Displays to turn on the experimental non-multiples zoom feature, so you don’t need to go through the above command to do so.

In my experiments, this does not work properly on my device for non-integer multiples. I assume this is because the default Windows System of Ubuntu20.04 is X11, not Wayland. If your device is Wayland, this should work. Alternatively, it is theoretically possible to choose Ubuntu On Wayland when logging in to your desktop system.

X11

For X11, we can use scaling-factor and xrandr to achieve non-integer multiple scaling at the same time, which can make THE TTF font be scaled correctly and prevent the fuzzy phenomenon when xRANDr is used alone. You can use gSettings or Settings>Displays to specify the zoom factor, and xRANDr to specify the zoom factor.

First set the interface zoom factor to the minimum for “the UI looks too big”, usually 2 (200%). If not, try 3 or more. Then use xrandr to set the zoom out factor, which I set myself at 1.25, to raise the factor if the UI looks too big, and lower it if not. The command is as follows:

Xrandr --output dP-4 --scale 1.25x1.25Copy the code

Using the above command you might encounterwarning: output DP-4 not founnd; gnoring“, or the interface does not change after the command is executed. At this point you need to executexrandrCommand to view your output parameters (i.e., the name of the interface currently displayed, as shown in the log), such as DP-4 on my device.

If the UI element is too small, go back to Settings>Displays to see if the integer multiple scale is restored to 100%. If the scale is appropriate (for example, 200%).

The setup of xrandr will be invalid after the restart, we can set a script to start the automatic execution, such as start-service.sh:

# start-service.sh
#! /bin/bashXrandr --output dP-4 --scale 1.25x1.25exit 0
Copy the code

Then grant execution permission to start-service.sh

sudo chmod +x start-service.sh
Copy the code

Then search for “sartup Applications” in Ubuntu and add the script to it:

At this point, you can support 4K display perfectly.

5. Install Python2

Ubuntu20.04 comes with python3, but some third-party tools or scripts still use python2, so we need to install it ourselves

apt install python
Copy the code

6. Install Git

apt install git
Copy the code

7. Chinese input

Sogou input does not yet support Ubuntu20.04, and its support for high score screens is not very friendly, so I chose ibus-libpinyin instead.

# installation
sudo apt install ibus-libpinyin 
sudo apt install ibus-clutter
Copy the code

Next, go to “Language Support” in your application and change “Keyboard Input Method System” to “IBUS”. Restart the system, then go to **Settings>Region & Language>Input Sources (Settings>Region and Language>Input Sources) and add “Chinese(Intelligent Pinyin)” in ** to use the Chinese Input method.

2. Create your command line tool (Terminator && ZSH)

1. Install Terminnator

If you’re used to iTerm2 on the Mac, you’ll love the split screen feature, but Ubuntu’s built-in Terminal doesn’t work. Fortunately, there are various open source Terminal under Linux, personally recommend Terminator, as powerful as iTerm2, the same support split screen.

# installation
sudo add-apt-repository ppa:gnome-terminator
sudo apt update
sudo apt install terminator
Copy the code

The default Terminator interface is ugly, but the configuration is flexible and you can adjust it according to your preferences.

2. Configure Shell (install ZSH and OH-my-zsh)

With Terminal out of the way, let’s configure the Shell. Execute the following command:

cat /etc/shells
Copy the code

As you can see, Ubuntu already has various shells built in:

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
Copy the code

Bash is usually the default Shell used by most Linux distributions on the market, but ZSH is far more powerful than bash.

# installation ZSH
apt install zsh

Set ZSH to the default shell
sudo chsh -s /bin/zsh
Copy the code

However, the configuration of ZSH is too complicated. Fortunately, someone developed OH-My-ZSH, which can make it more convenient for us to configure ZSH.

If you don't have Git installed, install git first
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

You can also choose to install manually
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
Copy the code

Restart Terminal and you’ll see the change.

3. The ZSH configuration

ZSH configuration is concentrated in the ~/.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"
Copy the code

Or select the theme of ZSH

ZSH_THEME="robbyrussell"
Copy the code

Oh-my-zsh has a number of built-in themes. The corresponding theme files are stored in the ~/. Oh-my-zsh /themes directory. You can choose or edit the themes as you like.

4. Install the ZSH plug-in

Oh-my-zsh also supports various plugins, stored in the ~/. Oh-my-zsh /plugins directory. Here are a few:

Autojump: Quick directory switch plugin

# installation
apt install autojump

# use
j Document/
Copy the code

ZSH -autosuggestions: History command suggestion plug-in when the command line command is typed

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

Zsh-syntax -highlighting: New command line highlighting plugin

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

After the plug-in is installed, you need to configure it in the ~/.zshrc file. The configuration is as follows:

Open the ~/.zshrc file, find the following line of configuration code, and append the plug-in nameAutojump zsh-autosuggestions zsh-syntax-highlighting (update/update/update/update)Copy the code

5. Fun command line toys

With the Terminator and ZSH configured, we can add some interesting toys to the command line.

CMatrix(Github.com/abishekvash…)

Terminal Matrix screensaver

# installation
sudo apt install cmatrix

# Run (plus -lba looks more like a movie, plus -ol looks more like a Win/Mac screensaver)
cmatrix
Copy the code

Effect:

Steam Locomotive(github.com/mtoyoda/sl)

Terminal small train dynamic effect

# installation
sudo apt install sl

# run
sl
Copy the code

Effect:

Screenfetch(Github.com/KittyKatt/s…)

The Bash Screenshot Information Tool is used to display system Information and The ASCII Linux distribution map on The terminal

# installation
sudo apt install screenfetch

# run
screenfetch
Copy the code

Effect:

Iii. Software installation

1. Install Clash(take a tizi, you know)

Step 1: Go to github.com/Dreamacro/c… Download the latest Linux Clash, for example, Clash -linux-amd64-v0.19.0.gz. You can extract an executable file clash-linux-amd64-v0.19.0:

Tar - ZXVF clash - Linux - amd64 - v0.19.0. GzCopy the code

Step 2: Use mv command to move to /usr/local/bin/clash:

Sudo mv clash - Linux - amd64 - v0.19.0 / usr /local/bin/clash
Copy the code

Step 3: Enter sudo chmod +x /usr/local/bin/clash on the terminal to add the execution permission.

sudo chmod +x /usr/local/bin/clash
Copy the code

Step 4: The terminal runs the clash command to run the clash.

# running clash
clash
Copy the code

Two files, config.yaml and country.mmdb, are generated in /home/{user ID}/.config/clash. Edit the config.yaml file and configure the proxy server information and rules. Some vendors will provide yamL files.

Restart the Clash (close and reopen the terminal and run the clash command) to load the updated configuration file.

Keep Clash running, open a browser and access clash. Razord. top to configure policies, select agent lines, and so on (you may need to enter IP, port, and password as prompted, which can be viewed in config.yaml;

To keep Clash running, choose Settings>Network>Network Proxy>Manual (Settings>Network> Proxy>Manual) in the system Network Settings. For the configuration information, see config.yaml or the log output by the terminal when Clash is started. At this point you can access the network through the Clash.

After the preceding configuration, the terminal must be opened and the clash command must be executed each time the system starts. The terminal must not be closed; otherwise, the entire Clash process will end. If you do not want to keep the terminal open all the time, run the nohup clash command to start the background running. Or if you want to start Clash on startup, add the nohup clash command to the end of the start-service.sh script mentioned earlier.

2. InstallTyproa(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
Copy the code

3. JetBrains

With JetBrains’ ToolBox App, you can install a variety of its ides, including Android Studio, with no brainpower.

4. Install other applications

You can download the.deb installation file from the official website and run the following command to install Ubuntu.

# installation
sudo apt install ./<file>.deb
Copy the code

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

sudo dpkg -i <file>.deb
sudo apt-get install -f # Install dependencies
Copy the code
application Download address
Chrome www.google.com/chrome
VS Code code.visualstudio.com
ZOOM Zoom. Us/download# cl…
WPS www.wps.cn/product/wps…
Netease Cloud Music music.163.com/#/download
Baidu cloud Baidu Web disk… ? What are you doing with this garbage?!!
. .

Note: Some applications are not controlled by the Scale Scale factor, so even if the Scale is set to 200% on **Settings>Displays **, UI elements will still display too small on high score screens. For example: ZOOM, netease Cloud music, in order to solve this problem, you can use the following command to start, you can display normally.

# Start zoom, the zoom can be adjusted as needed
QT_SCALE_FACTOR=2 zoom

Start netease Cloud Music
QT_SCALE_FACTOR=2 netease-cloud-music
Copy the code

5. Install QQ/TIM/ wechat /Office/…

The Ubuntu. Deb installation file is not available on the official website, but deepin can use Deepin-wine to install some applications.

Wine is a technology that implements part of the Windows API on the Linux platform, allowing users to seamlessly use Windows applications on the Linux platform.

Deepin-wine is a wine program modified by deepin Linux, and the community has transplanted many Windows software on Deepin-Wine, such as wechat, QQ, TIM and so on.

Someone on Github has developed a project, Deepin-wine-Ubuntu, to migrate Deepin-wine and its various DeBs to Ubuntu. To install wechat, QQ and other software, we need to install deep-wine-Ubuntu first. Here’s how:

Clone deepin-wine-Ubuntu source code to local first
git clone [email protected]:wszqkzqk/deepin-wine-ubuntu.git

Switch to the source directory
cd deepin-wine-ubuntu

Install script authorizationSudo chmod + x install_2. 8.22. Sh# installed deep - wine - ubuntu. / install_2. 8.22. ShCopy the code

Once deep-wine-Ubuntu has been installed, you can download the various Debs provided by the Deep Community. For details, see section 4:

# installation
sudo apt install ./<file>.deb
Copy the code

Deep community offers various deb download address:

software Download address
QQ Mirrors.aliyun.com/deepin/pool…
TIM Mirrors.aliyun.com/deepin/pool…
WeChat Mirrors.aliyun.com/deepin/pool…
. .

For more installation methods and software addresses, see github.com/wszqkzqk/de…

If your system language is not Chinese, the software launched through Deepin-wine will show garbled Chinese characters. You need to/opt/deepinwine/tools/run. The sh file WINE_CMD this line is amended as:

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

6. Install the RMP software

Many software packages offer only RMP packages and do not offer Deb packages, such as Xmind. Therefore, we need to convert it into a DEB installation package and install it again. Let’s take xMind as an example to see how this works.

For example, we downloaded the xmind installation package xmind-2020.rpm:

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

# update
sudo apt update

# Alien for installation
sudo apt install alien

Convert the.rpm package to a.deb package (xmind-2020.deb)
sudo alien XMind-2020.rpm

# installation
sudo dpkg -i XMind-2020.deb
Copy the code

Four. Desktop beautification

1. Install tweek

sudo apt install gnome-tweak-tool
Copy the code

2. Install plug-in extension support

# Make GNOME support plug-in extensions
sudo apt install gnome-shell-extensions 

# Chrome extension support, plugins can be installed using the browser
sudo apt install chrome-gnome-shell
Copy the code

3. List of common plug-ins

The plugin name instructions
Dash to Dock Custom dock
Screenshot Tool Screenshot of the plugin
Clipboard Indicator Extend the paste board to see the history paste content
Coverflow Alt-Tab Modify the switching effect of the Alt-Tab application
Applications Menu Add an application entry in the top status bar
OpenWeather The top status bar shows weather data
Places Status Indicator Added file directory access to the top status bar
Status Title Bar Displays the title of the current window in the top status bar
GTK Title Bar Remove the title bar of the non-GTK application
Hide Top Bar Automatically hides the status bar
Transparent Top Bar Transparent status bar
. .

More extensions can be found at extensions.gnome.org.

4. The theme

A variety of desktop, Shell, and icon themes are available for download on Gnome-Look

Install a desktop or shell theme

Unzip the downloaded theme fileTar -xvf filenames. Tar // Decompress the file# Copy the decompressed theme file to /usr/share/themes
sudo cp -r FileName /usr/share/themes
Copy the code

Install icon theme

Unzip the downloaded theme fileTar -xvf filenames. Tar // Decompress the fileCopy the extracted theme file to /usr/share/icons
sudo cp -r FileName /usr/share/icons
Copy the code

Then open Tweeks and select the theme to install

5. The wallpaper

Here are a few sites to download 4K 8K ultra HD wallpapers:

pixabay.com

unsplash.com

wallpapersite.com

wallpapershome.com

(use Theme: SURU++; The Icons Theme: Reversal)

Five. Use problem record

Problem 1: The time of the Windows and Ubuntu operating systems is inconsistent

If you have a dual system, after installing Ubuntu and setting the system time, you will find that the time is not uniform when you go back to Windows. To understand why, let’s start with the basics:

  • Coordinated Universal Time (UTC);

  • Greenwich Mean Time (GMT).

Windows and UNIX-like systems (Unix/Linux/Mac) look at system hardware time differently:

  • Windows treats the hardware time as local time, so the time displayed on the Windows system is the same as the time displayed in the BIOS.

  • Unix-like systems treat the computer hardware time as UTC, so when the system starts up, it adds the number of time zones the computer has set (plus 8 in China), so the time displayed in Ubuntu is always 8 hours faster than the time displayed in Windows.

When you set the system display time correctly in Ubuntu, the hardware time of the computer becomes the time minus 8 hours, so when you switch to Windows it’s 8 hours slower, that’s why.

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

timedatectl set-local-rtc 1 --adjust-system-clock
Copy the code

Problem 2: Ubuntu looping login

This is the problem I encountered with Ubuntu19.10, and I’m not sure if I have the same problem with 20.04 because I didn’t verify it.

Before we solve the problem, let’s add a key point: The Display Manager, which is used to provide a graphical login, Display a graphical login interface to the user, and handle user authentication. Common display managers in Linux include GDM3, KDM, LightDM, and so on:

  • Gdm3: GDM3 is the successor to GDM, which is the display manager for GNOME;
  • KDM: KDM is the display manager of KDE;
  • LightDM: LightDM is a lightweight display manager that is the canonical solution to display managers.

The reason:

In the practical verification, it was preliminarily concluded that the automatic login was enabled in the Settings, which triggered some bug of DGM3. (Ubuntu19.10 uses the GNOME desktop system by default, and gdm3 is the GNOME display manager)

Solution: Replace GDM3 with LightDM

Step 1: Install LightDM (since you cannot access the graphical desktop now, you need to use the CTL + Alt + F2 shortcut on the login page to enter the command line mode, enter the account and password, and then use the following command to install LightDM)

sudo apt-get install lightdm
Copy the code

When the installation is complete, a dialog box will automatically ask you to select the display manager installed in the current system and select LightDM.

Step 2: Restart

sudo reboot
Copy the code

After the restart, you can log in normally.

You will notice that the login screen has changed. If you want to switch back to the previous login screen, disable automatic login after entering the system and re-select the GDm3 display manager using the following command (requires a restart).

sudo dpkg-reconfigure gdm3
Copy the code

Gdm3 bugs are not guaranteed to be avoided by turning autologon off, which probably only applies to my Ubuntu19.10 installation; The reasons I’m saying here don’t necessarily apply to everyone. One thing is for sure, however, is that changing the display manager usually solves the problem if you have a recurring login.

If you want to see which display managers are currently running on your system, you can use the following command:

cat /etc/X11/default-display-manager
Copy the code

Problem 3: The NVIDIA driver is fixed

Ubuntu 20.04 comes with an Nvidia graphics driver, but I accidentally broke it. Mainly manifested in:

  1. The previously mentioned xrandr command fails to perform decimal scaling;
  2. NVIDIA X Server Settings client open blank;
  3. Command line executionnvidia-settingsCommand error;
  4. **Settings>Displays **

If you have the same problem as I did, or want to install the graphics driver manually, follow the steps below. (You need to download the graphics driver for your device from NVIDIA’s website first.)

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

Stop the desktop manager and go to the command line to explore
sudo telinit 3

# Remove the installed nvidia driver
sudo apt purge "nvidia*"

Install the graphics driver manuallySudo bash NVIDIA - Linux - x86_64-440.82. The run# to restart
sudo reboot
Copy the code

More graphics card drivers can refer to: linuxconfig.org/how-to-inst…


Reference documents:

  • HiDPI# 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 be updated. Please follow the BaronTalk account and reply to Ubuntu to download the latest PDF version of the configuration document.

If you like my posts, follow my BaronTalk, Zhihu.com column, or add a Star on GitHub.

  • Wechat official account: BaronTalk
  • Zhihu column: zhuanlan.zhihu.com/baron
  • GitHub:github.com/BaronZ88
  • Personal blog: baronzhang.com