
apt-get update - Retrieve new lists of packages
You many have noticed that most of the examples where you have to install a new package, apt-get update command is used before doing an apt-get install, if you are wondering why we need to make use of this command, lets find out.
apt-get is a package manager for Debian, and Debian-based Linux. When you try to look or install a package it first looks at the list of the packages that are available at the repository from which it downloads the packages. This list is stored locally on your system. If this list is not up to date, you will get an error saying Unable to locate package.
Let's see an example, I have installed a fresh Ubuntu Linux OS in a container, its a minimal OS that does not have all commands installed, not even Sudo, so when I run any command with sudo I get "sudo: not found", if I try to use the apt-get command to install sudo I still get an error,
# apt-get install sudo
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package sudo
#
This is because the local package list does not have information about sudo, if I run apt-get update and then try to install it, it works!
# apt-get update
Get:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease [265 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease [114 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease [108 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [114 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports focal/restricted arm64 Packages [1317 B]
Get:6 http://ports.ubuntu.com/ubuntu-ports focal/main arm64 Packages [1234 kB]
Get:7 http://ports.ubuntu.com/ubuntu-ports focal/multiverse arm64 Packages [139 kB]
Get:8 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 Packages [11.1 MB]
Get:9 http://ports.ubuntu.com/ubuntu-ports focal-updates/multiverse arm64 Packages [9090 B]
Get:10 http://ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 Packages [1079 kB]
Get:11 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 Packages [1433 kB]
Get:12 http://ports.ubuntu.com/ubuntu-ports focal-updates/restricted arm64 Packages [3933 B]
Get:13 http://ports.ubuntu.com/ubuntu-ports focal-backports/main arm64 Packages [51.1 kB]
Get:14 http://ports.ubuntu.com/ubuntu-ports focal-backports/universe arm64 Packages [26.0 kB]
Get:15 http://ports.ubuntu.com/ubuntu-ports focal-security/restricted arm64 Packages [3694 B]
Get:16 http://ports.ubuntu.com/ubuntu-ports focal-security/main arm64 Packages [1076 kB]
Get:17 http://ports.ubuntu.com/ubuntu-ports focal-security/universe arm64 Packages [796 kB]
Get:18 http://ports.ubuntu.com/ubuntu-ports focal-security/multiverse arm64 Packages [3254 B]
Fetched 17.6 MB in 14s (1219 kB/s)
Reading package lists... Done
As you can see when I ran apt-get it fetched around 17.6 MB of information about the packages available for my arm64 based system and updated it locally.
Now lets try to install sudo command,
# apt-get install sudo
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
sudo
Preparing to unpack .../sudo_1.8.31-1ubuntu1.2_arm64.deb ...
Unpacking sudo (1.8.31-1ubuntu1.2) ...
Setting up sudo (1.8.31-1ubuntu1.2) ...
- Terminal display next month Calendar
- How to change bash terminal prompt string and color
- How to exit from nano command
- How to Display content of a file in Terminal Screen?
- Copy entire directory using Terminal Command [Linux, Mac, Bash]
- 3 Commands to stop Nginx Server
- How to check file permissions for your file using Linux/Unix/macOS Terminal Command
- Create Hidden File or Directory using Shell Command
- bash: cls: command not found
- How to install python pip on Ubuntu using apt command
- The Date Command and its usage [Linux - Unix - macOS]
- SCP Copy all files from directory to Local Folder
- Create and write file in single Linux/macOS command
- Install OpenSSL on Linux/Ubuntu
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- Check SSH/OpenSSH version Command
- Execute .bin and .run file Ubuntu Linux
- What does apt-get update command does?
- How to ls command to output one entry per line [macOS/Linux/Bash]
- 3 ways to clear screen on Linux Terminal
- How to backup a file in Linux/Unix
- How to quit or exit SFTP Prompt on Terminal
- How to use SCP Command to Copy Directory
- zsh hello world example
- How to remove/delete a directory in Linux/macOs
- Country ISO Codes List - Java
- SQLite with Android Easy to Understand Tutorial that covers Select, Insert, Update and Delete - Android
- Amp Hello World Example - AMP
- Android : Exception raised during rendering: action_bar API 22 - Android
- 3 Python program to add two numbers - Python
- How to install powershell on macOS - Powershell
- Remove ActionBar from Activity that extends appcompat-v7 - Android
- The service instance - SharePoint