How do I update Ubuntu using terminal command line
Introduction: Ubuntu Linux is a free and open source operating system based on GNU userland and Linux kernel. Ubuntu is well known for ease of use. It is popular on both desktop and servers. One can update Ubuntu Linux using terminal bash shell. This page shows how to upgrade Ubuntu using terminal session.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | Linux terminal |
Category | Package Manager |
OS compatibility | Debian • Mint • Pop!_OS • Ubuntu • WSL |
Est. reading time | 3 minutes |
How do I update Ubuntu using terminal?
- Open the terminal application
- For remote server use the ssh command to login. For example:ssh user@server-name
- Fetch update software list by running the sudo apt-get update command
- Update Ubuntu software by running the sudo apt-get upgrade command
- Finally, reboot the Ubuntu box by running the sudo reboot command.
Let us see all commands in details with examples.
How do I upgrade Ubuntu using terminal?
You need to use either apt command or apt-get command. The apt command provides a high-level command line interface for the package management system. One can install new packages, update packages, remove/delete packages and performer other sysadmin duties for package management using apt.
How to sync the package index files from their sources via Internet
First, open the terminal application. Then run the following command:$ sudo apt-get update
OR$ sudo apt update
How to install the newest versions of all installed packages on Ubuntu
Next, execute the following command to apply package updates and patches:$ sudo apt-get upgrade
OR$ sudo apt upgrade
Sometimes a new Linux kernel is installed to fix security bugs at the kernel level. Hence, you may need to reboot the Ubuntu Linux server if kernel was updated.
Issue the following command for your cloud server or desktop:$ sudo reboot
How to update already installed package named nginx
Want to upgrade existing packages to fix security or other issues? No problem. The syntax is as follows:$ sudo apt install PackageNameHere
Alternatively, you can use the following syntax too:$ sudo apt-get install PackageNameHere
Now, let us upgrade nginx package:$ sudo apt install nginx
If nginx package is already installed it will try to update to latest version:
Reading package lists... Done Building dependency tree Reading state information... Done nginx is already the newest version (1.10.3-0ubuntu0.16.04.2). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Conclusion
You learned how to update or upgrade Ubuntu Linux using terminal based session. The apt command or apt-get command have many more options. Therefore, I suggest that you consult the following manul pages using the help command or man command:$ man apt
$ man apt-get
$ apt --help
Comments