"sudo apt install/remove" - Install/Remove Package

This section provides a tutorial example on how to use the 'apt install/remove' command to install or remove a given software package.

Installing a software package on your Ubuntu computer is very simple, just run the "apt install" command as shown below.

1. Try to install "smem" package.

herong$ apt install smem   
E: Could not open lock file /var/lib/dpkg/lock-frontend - 
  open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), 
  are you root?

2. Install "smem" package with root privilege.

herong$ sudo apt install smem   

Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
  ca-certificates-mono cli-common libgdiplus libglib2.0-cil libgtk2.0-cil
  libllvm7 libllvm9 libmono-addins-gui0.2-cil libmono-addins0.2-cil
  libmono-cairo4.0-cil libmono-corlib4.5-cil libmono-i18n-west4.0-cil
  ...
Use 'sudo apt autoremove' to remove them.

The following NEW packages will be installed:
  smem
0 to upgrade, 1 to newly install, 0 to remove and 6 not to upgrade.
Need to get 10.5 kB of archives.
After this operation, 36.9 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 smem all 1.4-2build1 [10.5 kB]
Fetched 10.5 kB in 0s (63.6 kB/s)
Selecting previously unselected package smem.

(Reading database ... 201425 files and directories currently installed.)
Preparing to unpack .../smem_1.4-2build1_all.deb ...
Unpacking smem (1.4-2build1) ...
Setting up smem (1.4-2build1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

3. Verify the package status.

herong$ apt list smem 

Listing... Done
smem/bionic,bionic,now 1.4-2build1 all [installed]

4. Remove the package, since I no longer need it.

herong$ sudo apt remove  smem 

Reading package lists... Done
Building dependency tree       
Reading state information... Done

The following packages will be REMOVED:
  smem
0 to upgrade, 0 to newly install, 1 to remove and 6 not to upgrade.
After this operation, 36.9 kB disk space will be freed.
Do you want to continue? [Y/n] Y

(Reading database ... 201429 files and directories currently installed.)
Removing smem (1.4-2build1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Table of Contents

 About This Book

 Introduction to Ubuntu Systems

 GNOME - Desktop Interface and Environment

 Shell - The Command-Line Interpreter

 Process Management

 Memory Management

 Files and Directories

APT (Advanced Package Tool)

 What Is APT

 "apt list" - List Software Packages

 "apt show" - Show Software Package Details

"sudo apt install/remove" - Install/Remove Package

 "sudo apt autoremove" - Remove Unneeded Packages

 Manage "apt" Package Repositories

 APT Configuration Settings and Overrides

 APT Package Archives and Metadata

 Network Connection on Ubuntu

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Administrative Tasks

 References

 Full Version in PDF/EPUB