Ubuntu Software Installation: A Beginner's Guide to the apt install Command

In Ubuntu, there are many ways to install software, but for beginners, the most common and safest method is using the apt command. apt is the abbreviation for Advanced Package Tool, a powerful utility for managing software packages in the Ubuntu system. The apt install command is the core command specifically designed to install software packages. This article will guide you through using apt install step by step, making it easy to install software on Ubuntu.

1. Open the Terminal: Start Your Command Journey

All commands in Ubuntu are executed in the Terminal. If you’re unsure how to open it, use one of these methods:
- Press the shortcut key combination Ctrl + Alt + T (the fastest way).
- Click the “Show Applications” icon in the bottom-left corner of the screen, search for “Terminal,” and open it.

2. Understanding apt install

apt install is a subcommand of the apt tool. Its function is to download and install software packages from software sources (Ubuntu’s official or third-party software repositories). In simple terms, a software source is like an “app store” containing all software packages supported by Ubuntu, and apt install helps you find and install the software you need from these sources.

3. Preparation Before Installation: Update Software Source Information

Before installing software, it’s recommended to update the system’s “software source information.” This is similar to updating the app store list on your phone, ensuring you can install the latest versions of software and avoiding installation failures due to outdated information.

Execute the following command to update the software sources (requires administrative privileges, so prefix with sudo):

sudo apt update
  • sudo: Obtains administrative privileges (equivalent to “running as a superuser”). After execution, you’ll be prompted to enter your Ubuntu password (the password won’t be displayed on the screen; simply press Enter after typing).
  • apt update: Updates the local software source list, so the system knows which software packages are available and their versions.

If you see output similar to the following (the exact package list may vary), the update was successful:

Hit:1 http://cn.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://cn.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://cn.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

4. Basic apt install Command for Installing Software

After updating the software sources, you can use apt install to install software. The basic format is:

sudo apt install 软件包名称
  • Software Package Name: The exact name of the software to install (note: the software name must exactly match the official source name. For example, to install the text editor nano, use nano; to install the browser firefox, use firefox).

Example: Install the Text Editor nano

  1. Execute the installation command:
   sudo apt install nano
  1. The system will check dependencies and ask for confirmation (enter y and press Enter):
   Reading package lists... Done
   Building dependency tree... Done
   Reading state information... Done
   The following NEW packages will be installed:
     nano
   0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
   Need to get 455 kB of archives.
   After this operation, 1,384 kB of additional disk space will be used.
   Do you want to continue? [Y/n]

Enter y and press Enter to start downloading and installing nano.

  1. After installation, verify success:
   nano --version

If version information (e.g., GNU nano 6.2) is displayed, the installation was successful!

5. Installing Multiple Software Packages at Once

If you need to install multiple software packages, you can list all package names in one command instead of running apt install repeatedly:

sudo apt install 软件包1 软件包2 软件包3

Example: Install nano (text editor), zip (compression tool), and htop (system monitoring tool) simultaneously

sudo apt install nano zip htop

The system will automatically handle the installation of all packages. The process is similar to installing a single package, and you only need to confirm once (enter y).

6. Troubleshooting Installation Failures

If you encounter errors during installation, the issues may be:
1. Incorrect Software Name: For example, typing nan instead of nano. The system will prompt “Unable to locate package.” Check the software name for accuracy (search on the official source website or use apt search 关键词 to find it).

  1. Unavailable Software Source: If the update fails with “unable to connect,” it may be a network issue or an incorrect software source address. Check your network first, or temporarily switch to a domestic mirror source (e.g., Aliyun, Tsinghua Source). For beginners, the default official source is recommended initially.

  2. Insufficient Permissions: Ensure you use sudo to execute the command; otherwise, you may get “permission denied.”

7. Uninstalling Software: Easy Removal After Installation

To uninstall software after installation, use apt remove (only removes the software, retains configuration files) or apt purge (completely removes the software and its configuration files):

# Remove software (retains configuration files)
sudo apt remove 软件包名称

# Completely remove (including configuration files)
sudo apt purge 软件包名称

Example: Uninstall nano

sudo apt remove nano

8. Security Tip: Only Install Trusted Software

Ubuntu’s official software sources are strictly verified and secure. Never manually install .deb files from non-official websites, as this may infect your system with viruses or cause damage. If a software is not found in the official source, consider alternative installation methods like Snap or Flatpak (but apt is sufficient for beginners).

Summary

Using apt install to install software is a must-learn skill for Ubuntu beginners. The core steps are:
1. Open the terminal and update the software sources with sudo apt update.
2. Install software with sudo apt install 软件名, confirm when prompted, and wait for completion.
3. Verify the installation (e.g., 软件名 --version), and use apt remove to uninstall when needed.

Practice a few times, and you’ll find installing software becomes very straightforward! If issues arise, first check if the software name is correct, if the network is working, or try re-updating the software sources (sudo apt update).

Xiaoye