Setting Up Ubuntu

hacking skills






Guidance on setting up a fresh Ubuntu installation.


This post is where I keep notes on configurations for Ubuntu (GNOME) and some applications for personal reference.

Controlling the boot process

The grub file controls the behavior of the GRand Unified Bootloader, which is a flexible and powerful boot loader program. The full path to the file is /etc/default/grub; use the following command to edit the file:

sudo nano /etc/default/grub

There are two settings that may be of particular interest:

  1. GRUB_DEFAULT=0: choose Ubuntu as the default operating system.
  2. GRUB_TIMEOUT=5: boot the default system in five seconds if no keyboard input is performed during this time.

Remember to run the following command after changing the settings to update the /boot/grub/grub.cfg file:

sudo update-grub

Dealing with a dual-boot system time conflict

When Linux and Windows constitute a dual-boot system, there will be an issue concerning system time. The solution is to use the following command to tell Ubuntu that the hardware clock is set to ‘local’ time:

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

Note that invoking timedatectl set-local-rtc 1 will also synchronize the RTC (i.e., real-time clock, which stores hardware time) from the system clock (which stores system time), unless --adjust-system-clock is passed.

The following command can be used to update system time, but note that the program is no longer installed on Ubuntu by default (install it with sudo apt install ntpsec-ntpdate).

sudo ntpdate

Auto mount a partition on boot

Use the lsblk command to find out the UUID of a partition; example:


# sdb    447.1G ntfs    data   32FBCAAA07932A36           
# └─sdb1 447.1G ntfs    newvol D0BE3DB6BE3D95C7           

Use the id command to find out user and group IDs; example:


# userid=1000(username) groupid=1000(username) group=1000(username)

Edit the /etc/fstab file to auto mount a partition (e.g., to /data) on boot. Note that you should specify the UUID of a partition, not that of a disk. In the given example, it should be D0BE3DB6BE3D95C7 (sdb1), not 32FBCAAA07932A36 (sdb). An example entry could be:

UUID="D0BE3DB6BE3D95C7" /data ntfs uid=1000,gid=1000,umask=0077

Cron jobs

Use crontab -e to add the following entries (custom commands and scripts can be found in the “Custom commands and scripts” section of this post):

# move expired files/directories from /data/tmp/ to trash
0 */2 * * * ${HOME}/.local/bin/cleanup --expiration-time 1209600 directory --directory /data/tmp/ >> ${HOME}/cleanup.log 2>&1

# delete expired files/directories from trash 
0 */2 * * * export XDG_RUNTIME_DIR=/run/user/$(id -u); ${HOME}/.local/bin/cleanup --expiration-time 2419200 trash >> ${HOME}/cleanup.log 2>&1

Note that by default, crons job are executed with a very limited set of environment variables. Therefore, it is necessary to declare variables (either right before the command, or at the top of crontab file) before executing a command that requires them. Also note that cron sees the percentage sign (i.e., %) as a special character, and therefore it should be escaped with a leading backslash (i.e., \%) when included in a command.

Environment variables

Set LANGUAGE=en to ensure various messages (e.g., man pages and help info for commands) are shown in English:

echo "export LANGUAGE=en" >> ~/.profile

Input method

To enable the sogoupinyin Chinese input method, follow these steps:

  1. Install fcitx and other dependencies.

    sudo apt install fcitx \
      libqt5qml5 libqt5quick5 libqt5quickwidgets5 qml-module-qtquick2 libgsettings-qt1 # additional dependencies for sogoupinyin
  2. Download sogoupinyin from the official site and install it.

    sudo apt install <path-to-sougoupinyin.deb-file>
  3. Configure autostart for fcitx.

    sudo cp /usr/share/applications/fcitx.desktop /etc/xdg/autostart/ # system-wide
    # cp /usr/share/applications/fcitx.desktop ~/.config/autostart # user-specific
  4. Open the “Language Support” app from Ubuntu app menu, choose fcitx for “Keyboard input method system”.

  5. Restart computer.

  6. Open the “Fcitx Configuration” app from Ubuntu app menu (or from the top bar), go to “Input Method” tab, and add sogoupinyin (may need to uncheck “Only Show Current Language” to show all available methods).

  7. Open sogoupinyin preference menu (either from its tool bar or from the top bar), and make custom adjustments.


To install some frequently used applications:

sudo apt install python3-pip curl aria2 ffmpeg filezilla flameshot gimp git keepassxc meld tree virtualbox virtualbox-ext-pack vlc obs-studio kdenlive
pip3 install --upgrade yt-dlp

After installing flameshot, add an entry to the “Startup Applications” app to launch it at startup (e.g., Name: flameshot; Command: /usr/bin/flameshot). Then, add a keyboard shortcut in “Settings” -> “Keyboard” -> “Keyboard Shortcuts” -> “View and Customize Shortcuts” -> “Custom Shortcuts” (e.g., Name: flameshot; Command: /usr/bin/flameshot gui; Shortcut: Ctrl + Alt + A). Note that while the command for the startup setting is /usr/bin/flameshot, the command for the shortcut is /usr/bin/flameshot gui.

More detailed installation/setup guides for some other software are listed below:

File templates

Save the following templates to ~/Templates/ (in English locale) or ~/模板/ (in Chinese locale):

Custom commands and scripts

Save the following scripts to ~/.local/bin/ and make them executable (chmod u+x ~/.local/bin/*):