Introduction #
Ubuntu, as a popular Linux distribution, offers better ecosystem support compared to other Linux distros. The most notable advantage is that when you encounter issues, you’re more likely to find tutorials and solutions for Ubuntu.
This article primarily focuses on the GUI-based personal edition of Ubuntu. For server-specific Ubuntu systems, operations depend on your actual business needs. The article Cloud Service Deployment can serve as a reference.
Ubuntu Installation #
The installation was done a long time ago, so no detailed records exist. If needed, please search for keywords like “installing Ubuntu on a portable hard drive.” Here’s a relatively recent guide: Installing Ubuntu on a Portable Hard Drive.
The installation process is no longer traceable. The current setup involves installing Ubuntu on a portable hard drive, allowing it to be used on-the-go.
To use it, simply plug in the hard drive before powering on the computer. Quickly press a specific key to enter the BIOS boot menu, set the priority to the highest, save, and exit to boot into Ubuntu.
To switch back to Windows, just unplug the hard drive and power on normally—no additional steps are required.
Interface Customization #
I personally prefer an Apple-style interface, so I specifically chose an Apple-inspired theme: WhiteSur.
The installation process is straightforward:
git clone https://github.com/vinceliuice/WhiteSur-gtk-theme.git --depth=1
cd WhiteSur-gtk-theme
./install.sh # Run the installation script
For detailed configuration, refer to the instructions on the GitHub page.
As for updates, the official guide doesn’t specify, presumably assuming users already know:
git pull # Fetch the latest code
./install.sh # Re-run the installation script
Fcitx 5 #
Main reference: Install and Configure Fcitx 5 Chinese Input Method on Ubuntu. I initially considered using Sogou Input Method, but the official installation process seemed overly complicated, and it also required installing Fcitx 5. So, I figured I might as well just use Fcitx 5 directly.
To be honest, I was reluctant to use Fcitx at first 🥲 because its interface is so “plain” that it’s hard to accept. I believe the author of the blog post above must have felt the same way 👆.
Using Windows Fonts #
Approach: Copy font files from Windows to Ubuntu’s dedicated font directory, assign appropriate permissions, refresh Ubuntu’s font cache, and load the new fonts.
# Windows font directory: C:/Windows/Fonts
sudo cp /mnt/C/Windows/Fonts/LXGWWenKai-Regular.ttf /usr/share/fonts/custom/LXGWWenKai-Regular.ttf
# Grant permissions
sudo chmod u+rwx /usr/share/fonts/custom/*
# Navigate to the font directory
cd /usr/share/fonts/custom/
# Create font cache
sudo mkfontscale
# Refresh cache
sudo fc-cache -fv
Alternatively, you can download a new .ttf
file from the web and copy it to the target directory. If you’re using a GUI-based Ubuntu system, you can simply double-click the font file to install it 🥰.
Mounting Hard Drives #
Since my Ubuntu system is installed on a portable hard drive, the main goal here is to access Windows partitions from Ubuntu. This section doesn’t cover detailed partition operations. For tasks like formatting partitions, refer to: How to Partition and Mount Disks in Ubuntu.
# View disks and partitions (sudo privileges required)
sudo fdisk -l
# Create a mount point (essentially creating a folder)
# The subfolder under /mnt is named "E" because it’s intended to mount the E drive
sudo mkdir /mnt/E
# Mount the new partition directly
sudo mount /dev/vdb /mnt/E
# Set auto-mount at boot
# Check the partition’s UUID
sudo blkid
# Edit the specific file
vim /etc/fstab
# Append to the end of the file
UUID=xxxxxxxx /mnt/E ntfs defaults 0 2
- Replace the UUID above with the output from
blkid
. Replacentfs
with the appropriate filesystem type (common types includentfs
andext 4
). defaults
: This is a combination of default mount options, such asrw
(read-write) andrelatime
(reduces inode access time updates).0
and2
: These values control backup and filesystem check order. Typically, the first value is0
(no backup), and the second is1
or2
(1
for the root filesystem,2
for others).
Testing method:
# If no errors occur, the configuration is correct
sudo mount -a
Creating Shortcuts #
A common task: placing a quick link to a frequently used folder on the desktop for easy access.
# Place a link to /target/dir in the Desktop folder
# Replace with your target directory
ln -s /target/dir ~/Desktop
# Test—if you can cd into it, it works
cd ~/Desktop/dir
Configuring Git #
One of the standout features of Linux is its extreme simplicity, which is why using the command line to manage Git is the preferred choice for Linux users 😃. Ubuntu comes with Git pre-installed, so there’s no need to install it separately. If you want to upgrade, follow these steps:
git --version # Check the Git version
sudo add-apt-repository ppa:git-core/ppa # Add the official repository
sudo apt update && sudo apt upgrade # If possible, proceed with the upgrade
GitHub-SSH #
Of course, you can also use HTTPS directly, but the downside is that you’ll need to enter your password every time. Moreover, with GitHub’s increasing security measures, the password isn’t necessarily your account password but rather a dedicated token 🥲.
Such a cumbersome process is unbearable on Linux. I’d rather go through a tedious setup once than have to enter a long token every time.
This section is mainly referenced from: Configuring Git to Push by Default Without Entering Credentials (Ubuntu, SSH).
git config --global user.name 'xx' # Configure the global username
git config --global user.email 'xxx@qq.com' # Configure the global email account
# Generate an SSH key pair. Here, I choose to press Enter all the way through.
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Start the SSH agent and load the private key into the agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
# View and copy the public key content
cat ~/.ssh/id_rsa.pub
# Add this new SSH key to your GitHub account.
# Change an existing HTTPS-linked repository to an SSH link
git remote rm origin
git remote add origin git@github.com:username/repository.git
Installing and Managing Software #
Software installation on Ubuntu generally falls into the following categories:
- Via the built-in Snap store
- Via
apt
- Via
.deb
packages - Via
curl
Different installation methods require different management approaches. curl
installations are the most cumbersome to manage, while others can be handled easily with their respective package managers.
Snap #
Simply open the Snap store to install software effortlessly, though the packages are often outdated.
apt #
# Software source operations can be performed graphically in the desktop version via "Software & Updates"
# Add a software source
sudo add-apt-repository ppa:libreoffice/ppa && sudo apt update
# Remove a software source
sudo add-apt-repository --remove ppa:libreoffice/ppa
# Install software
sudo apt install xxx
# Update packages
sudo apt update # Sync package info from remote repositories without upgrading
apt list --upgradable # View upgradable packages
# Upgrade all available packages without handling dependency changes
sudo apt upgrade
sudo apt full-upgrade # Full upgrade
sudo do-release-upgrade # Upgrade across major Ubuntu versions
# Check software packages
sudo apt-cache search wps # Search for all packages containing "wps" and their description information
sudo apt-cache pkgnames | grep -i wps # View package names containing the keyword "wps"
# Remove packages
sudo apt remove xxx
sudo apt autoremove # Clean up residuals
deb #
After downloading a .deb
package from a browser, double-clicking it will install it directly. Internally, this uses apt
, so management is the same as with apt
.
# Install via double-click
# Uninstall via apt
sudo apt remove xxx
sudo apt autoremove # Clean up residuals
AppImage #
AppImage is a portable software packaging format for Linux systems, designed to simplify application distribution and execution. Its core philosophy is “one app = one file,” allowing users to run applications directly without installation or administrator privileges.
In newer versions of Ubuntu, attempting to run the file directly may result in an error. To resolve this, you need to install libfuse2
using the following command:
sudo apt install libfuse2
Then grant executable permissions to the AppImage package:
chmod +x file_name.AppImage
After installation, you can simply double-click the package to launch the application 😃.
If you want to uninstall the software, it’s very straightforward: just delete the package. However, if you’re a perfectionist like me, you can check the following directories to completely clean up any residual files:
ls ~/.config -a # Check configuration files
ls ~/.local/share -a # Check shared configuration files
ls ~/.cache -a # Check cache
du -sh ~/.cache/* | sort -h -r # Check disk usage of folders under .cache
curl #
Download and execute installation scripts directly from a URL using curl
. Software installed this way is harder to manage because the actual installation process is script-driven and difficult to monitor.
# Example: Installing the Zed editor
curl -f https://zed.dev/install.sh | sh
# Uninstalling is usually messy
# First, fetch the installation script
curl -f https://zed.dev/install.sh -o install.sh
# Have an AI parse the script
# Then follow the AI’s instructions to manually uninstall
Major Version Updates #
Performing major version updates is completely unnecessary for server OSes, as the related software packages usually haven’t caught up yet. Chasing the “latest version” isn’t wise. However, for desktop users, it’s quite useful—after all, updating allows them to experience the newest system features. In short, it’s just for fun. 🤓
This section primarily references the WeChat public article: How to Upgrade from Ubuntu 24.04 to Ubuntu 25.04.
Data Backup #
This step is essential. Although it might take up dozens of gigabytes of disk space, a major version update is still a risky operation. Better safe than sorry. 😅 You can always delete the backup and free up space after a successful upgrade.
# Install the backup tool
sudo apt install deja-dup
# Run directly
deja-dup
Update Software Packages #
Ensuring the system is up to date minimizes compatibility issues. Execute the following commands one by one:
sudo apt update
sudo apt full-upgrade
sudo apt autoremove
sudo apt autoclean
sudo reboot # Reboot the system
Version Upgrade #
The logic is straightforward: point the old version’s software sources to those of the new version. Below are some relevant files that may need modification:
- Upgrade policy file:
/etc/update-manager/release-upgrades
- Software sources configuration file:
/etc/apt/sources.list.d/ubuntu.sources
If you want to upgrade from an LTS version to a non-LTS version, you’ll need to modify the policy file. The policy file actually contains just one line—change it to the following:
Prompt=normal
Next, modify the software source configuration file by running the following command:
sudo sed -i 's/noble/oracular/g' /etc/apt/sources.list.d/ubuntu.sources
After modifying the files:
# Refresh the index and perform a full upgrade, including the kernel, drivers, and all packages
sudo apt update && sudo apt full-upgrade -y
-y
option means “automatic confirmation.” If you prefer to manually type “yes,” you can omit it. 😃 Personally, I’d rather not.
After the upgrade completes:
sudo reboot # Reboot to apply changes
lsb_release -a # Verify the system version
Office Suite #
As we all know, Microsoft Office cannot run directly on Linux 😅. However, viewing and editing doc
files is often unavoidable.
Therefore, here’s a recommended Office alternative for Linux: LibreOffice. The installation steps are as follows:
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt update
sudo apt install libreoffice
Before installing LibreOffice, I also tried using WPS to edit Office files, but for some reason, it kept causing system errors, so I eventually abandoned it.
Storage Cleanup #
Common Cleanup Tasks #
# Remove orphaned dependencies
sudo apt autoremove
# Clear apt cache
sudo du -sh /var/cache/apt # Check apt cache size
sudo apt autoclean # Auto-clean
sudo apt clean # Full clean
# Clear system logs
journalctl --disk-usage # Check system log size
sudo journalctl --vacuum-time=3 d # Remove logs older than 3 days
# Clear .cache
du -sh ~/.cache/* | sort -h -r # Check cache size
rm -r folder_name # delete the folder recursively
# Clean up old Snap versions
snap list --all # List all Snap packages
# List all disabled packages (single-line command)
echo -e "\033[1 mDisabled Snap Packages and Their Sizes:\033[0 m" && snap list --all | awk '/disabled|已禁用/{print $1}' | while read -r pkg; do size=$(snap info "$pkg" | awk '/installed:/ {print $4}'); printf "%-30 s %10 s\n" "$pkg" "$size"; done | sort -k 2 -h
# Remove all disabled Snap packages (single-line command)
snap list --all | awk '/disabled|已禁用/{print $1, $3}' | while read snapname revision; do sudo snap remove "$snapname" --revision="$revision"; done
# Clean up old kernels
sudo dpkg --list | grep linux-image # List all kernels
sudo apt autoremove --purge # Automatically remove unnecessary kernels
Auto Clean on Boot #
Manually checking and cleaning up your system every time can be a hassle. A smart computer should learn to clean itself 😋
Run the following command to open a new script file:
sudo nano /usr/local/bin/system-clean-up.sh
Then paste the following content into the file:
#!/bin/bash
set -e
echo "[1] Running apt autoremove..."
apt autoremove -y
echo "[2] Running apt autoclean..."
apt autoclean -y
echo "[3] Cleaning journal logs older than 2 days..."
journalctl --vacuum-time=2d
echo "[4] Removing disabled snap revisions..."
snap list --all | awk '/disabled|已禁用/ {print $1, $3}' | while read snapname revision; do
echo "Removing snap: $snapname revision $revision"
snap remove "$snapname" --revision="$revision"
done
echo "[5] Cleaning ~/.cache/ directories larger than 200MB..."
for userdir in /home/*; do
cache_root="$userdir/.cache"
[ -d "$cache_root" ] || continue
for dir in "$cache_root"/*; do
if [ -d "$dir" ]; then
size_kb=$(du -s "$dir" | awk '{print $1}')
if [ "$size_kb" -gt 204800 ]; then
echo "Removing large cache directory: $dir ($(($size_kb / 1024)) MB)"
rm -rf "$dir"
fi
fi
done
done
echo "[Done] Clean-up finished."
This script includes five safe automatic cleanup tasks:
apt autoremove
apt autoclean
- Deletes system logs older than 2 days
- Removes disabled Snap packages
- Deletes
.cache
subfolders larger than 200MB
After saving the file, grant execute permission:
sudo chmod +x /usr/local/bin/system-clean-up.sh
Then configure automatic startup on boot: The directory /etc/systemd/system
contains service scripts that run automatically at startup, all with the .service
extension.
To enable the script to run automatically at system boot, create a new systemd service file:
sudo nano /etc/systemd/system/clean-up.service
Paste in the following content:
[Unit]
Description=Clean up system caches, logs, and snaps at boot
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/system-clean-up.sh
User=root
[Install]
WantedBy=multi-user.target
After editing is completed, run the following command to enable this service script, so it will automatically run once upon the next boot but will not run immediately.
sudo systemctl daemon-reexec && sudo systemctl enable clean-up.service
You can also run it manually to test if it works properly:
# Run immediately
sudo systemctl start clean-up.service
# Check the system journal
sudo journalctl -u clean-up.service
One-Click Auto Setup Script #
If you find the above script configuration process too cumbersome, we also provide a one-click automated setup script. You can delete it after running it once.
Create a file named setup-cleanup.sh
in any directory and paste the following content:
#!/bin/bash
set -e
echo "🚀 Creating cleanup script at /usr/local/bin/system-clean-up.sh..."
cat << 'EOF' | sudo tee /usr/local/bin/system-clean-up.sh > /dev/null
#!/bin/bash
set -e
echo "[1] Running apt autoremove..."
apt autoremove -y
echo "[2] Running apt autoclean..."
apt autoclean -y
echo "[3] Cleaning journal logs older than 2 days..."
journalctl --vacuum-time=2d
echo "[4] Removing disabled snap revisions..."
snap list --all | awk '/disabled|已禁用/ {print $1, $3}' | while read snapname revision; do
echo "Removing snap: $snapname revision $revision"
snap remove "$snapname" --revision="$revision"
done
echo "[5] Cleaning ~/.cache/ directories larger than 200MB..."
for userdir in /home/*; do
cache_root="$userdir/.cache"
[ -d "$cache_root" ] || continue
for dir in "$cache_root"/*; do
if [ -d "$dir" ]; then
size_kb=$(du -s "$dir" | awk '{print $1}')
if [ "$size_kb" -gt 204800 ]; then
echo "Removing large cache directory: $dir ($(($size_kb / 1024)) MB)"
rm -rf "$dir"
fi
fi
done
done
echo "[Done] Clean-up finished."
EOF
sudo chmod +x /usr/local/bin/system-clean-up.sh
echo "✅ Cleanup script created."
echo "🚀 Creating systemd service clean-up.service..."
cat << EOF | sudo tee /etc/systemd/system/clean-up.service > /dev/null
[Unit]
Description=Clean up system caches, logs, and snaps at boot
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/system-clean-up.sh
User=root
[Install]
WantedBy=multi-user.target
EOF
echo "✅ Service file created."
echo "🔄 Reloading systemd..."
sudo systemctl daemon-reexec
echo "✅ systemd reloaded."
echo "🧩 Enabling clean-up.service at boot..."
sudo systemctl enable clean-up.service
echo "✅ Enabled."
echo "⚙️ Running cleanup task now..."
sudo systemctl start clean-up.service
echo "✅ Cleanup complete. You can check logs with: sudo journalctl -u clean-up.service"
Finally, run this setup script once and you’re done:
sudo chmod +x setup-cleanup.sh && sudo ./setup-cleanup.sh
Miscellaneous #
This section includes some simple yet commonly used commands.
System Control #
-
Shut down immediately:
shutdown now
-
Restart immediately:
sudo reboot
Extracting Files #
The command varies depending on the file format you need to extract.
# Extract a .zip file
unzip file.zip -d /target/directory
# Extract a .tar file
tar -xvf file.tar
# Extract a .tar.gz file
tar -xzvf file.tar.gz
Temporary Environment Variables #
Sometimes, even with a VPN proxy enabled, the terminal may still be unable to access the internet properly. This is likely due to the terminal being unable to automatically detect the proxy port. The solution is to modify the environment variables, which can be changed permanently (by writing to a file) or temporarily, as shown below:
# For use in the PowerShell terminal on Windows
$env:HTTPS_PROXY="http://127.0.0.1:7890"
# For use in bash or cmd terminals
set HTTPS_PROXY=http://127.0.0.1:7890