Let's go to the terminal and see some practical examples! Only root can manage packages so all commands 1
should be executed by root. As to make things easier and to not prefix each command with sudo I’m temporary 2
becoming root by running sudo su. 3
I am root in this terminal. APT uses an index or a local database that holds records of available packages 4
from the repositories enabled in the system. 5
To update the package index run as root apt update; this will pull the latest changes from the apt 6
repositories. 7
It's recommended to run this command each time before installing or upgrading new packages. 8
Note that the command doesn't install or update any software application. 9
It just updates an index. 10
To install a new program run apt install and the package name. I'm installing the Apache Web server apt 11
install apache2 12
Apache2 being the name of the package. 13
It will install the specified package and all its dependencies. It's displaying a summary about its operation 14
and prompting for yes or no; if you write 15
Yes it will download and install those packages. 16
I'm installing it. 17
It failed to start the server because probably another Web server listens on port 80 "Address already 18
in use" so I suppose the ngnix from the previous lectures. 19
Let's check it! 20
systemctl status ngnix 21
ngnix is active and running! So port80 is already used. I am stopping ngnix. 22
And I'm starting Apache: systemctl start apache2 23
It has started successfully, let's check its status! 24
It's running! 25
I can connect to the server, so I'm connecting to localhost. 26
Great! 27
It works. If you want to install multiple packages with one, command specify them 28
as a space-separated list: apt install gparted vlc 29
gparted is a graphical application to manage disks, and vlc is a media player. 30
In fact, I won't install them. 31
Using apt, it's also possible to install a program from a local deb file, just run app install 32
and provide the full path to the file 33
as argument. Let's go to the directory where the Chrome browser was saved. 34
home/ student/ downloads and I'm installing it. 35
apt install and the path to the file home /student/ downloads/ google chrome /stable. 36
is is installing Google Chrome. 37
It will called dpkg behind the scenes. 38
I've got permission denied, so I have to prefix the command with sudo. 39
So seudo apt install and the path to the file. 40
If you don't provide the full path, the apt command will try to retrieve and install the package from 41
the apt repositories, so from the Internet; so if I just provide the file's name, I'll probably 42
get an error. 43
"Unable to locate package"! so always provide the full path when installing an application from a deb 44
file using apt. To get a list of all packages that can be upgraded run apt list -- 45
upgradable 46
If the package already exists apt install will upgraded to the latest version, so apt install 47
python3 apt. 48
It already exists and it will update the program to its latest version. 49
If you want to upgrade the system as a whole run apt full -upgrade. 50
This will remove some installed packages if that is needed, to upgrade the whole system; if you want 51
to run this command from a Shell script, then pass the -Y option, which means assume yes as answer 52
to all prompts and run non interactively like this. 53
To remove uninstalled package apt remove and the package name: apt remove apache 54
2 55
Provide multiple packages separated by spaces to remove them all. The remove command will uninstall 56
the given packages, but it may leave some configuration files behind. 57
If you want to remove the package, including all configuration files, use purge instead of remove. 58
So sudo apt purge apache2 59
It was purged. 60
Take a look at this message! Whenever a new package is installed on the system, the package dependencies 61
will be installed too; when the package is removed, using apt remove or apt purge, the dependencies 62
will not be removed as well. 63
You can always remove these dependency packages since they are no longer used! To remove the unneeded 64
dependencies, run apt auto remove. 65
autoremove writen in a single word. 66
By default, Ubuntu keeps every package that has been downloaded and installed in a cache directory 67
on the disk. 68
This is the cache directory /var/cache/apt/archives 69
This is the directory that contains all installed and upgraded packages. 70
Let's check its size! 71
It's pretty big. To clear out the local repository of retrieved package files run apt clean. 72
It removes everything but the log file from that directory. 73
Let's check the contents of the directory again; and it's empty. 74
It's only the log file there. 75
Let's go ahead and see how to get information about the available or installed packages! To list all 76
available packages run apt list. 77
There are tens of thousands of available packages in the repositories. Let's see 78
how many there! So | wc -l 79
There are a lot. 80
To search whether a specific package is available, filter the output with the grep command, for 81
example: grep postfix 82
This is a well known email server. 83
And it's available. 84
To find packages whose description contains a word or a phrase run apt search in the phrase between 85
double quotes, for example " transparent proxy". 86
And it found a few packages! To get a list of only the installed packages add the -- installed 87
option. 88
So apt list -- installed. 89
These are all installed packages on the system. 90
Let's see how many they are! 91
1722 92
To find information about an available or uninstalled package including its dependencies, download 93
size and the description of its contents run apt show and the package name, for example: apt show 94
apache2 95
OK, or apt show zzuf 96
There are also graphical package managers, aptitude or synaptic being some of them. They enable 97
you to install, upgrade and remove software packages in a user friendly way. 98
Let's install and start synaptic! 99
sudo apt install synaptic 100
It was installed and I am starting it. 101
This is synaptic! 102
You can search for remove or upgrade packages in a graphical way. 103
In this video, you've learned how to use apt to manage application packages on Ubuntu and other 104
Debian distributions. 105
Thank you!