Update and Install With the Command Line Using Apt


We have demonstrated GUI tools to install and update packages or software, but what about the command line? The command line holds the power of Linux, giving life to most of the GUI tools for updating and installing packages, interfacing with the command line as partners. I like using apt and do so frequently but I admit I have to turn to the GUI simply because I do not know the commands as well as I like and I do not know all of the package names.

Updating the package list should come first most of the time and is run with super user privileges. In Debian based distributions:

sudo apt-get update

To upgrade all available updates run:

sudo apt-get upgrade (You will be asked to confirm Y/N.)

If you need to update the distribution, (After an apt-get upgrade you may see some packages held back.):

sudo apt-get dist-upgrade (You will be asked to confirm Y/N.)

Installing a single or multiple packages is easy with:

sudo apt-get install package-name(s) (Separate each package name with a space.)

These are the four commands I use the most, but there are more available. To see the help text run as sudo or normal user:

apt-get -h or -help

This is the output of the help file on my system:

apt 0.9.7.5ubuntu5.1 for amd64 compiled on Mar 13 2013 21:25:25
Usage: apt-get [options] command
apt-get [options] install|remove pkg1 [pkg2 ...]
apt-get [options] source pkg1 [pkg2 ...]

apt-get is a simple command line interface for downloading and
installing packages. The most frequently used commands are update
and install.

Commands:
update – Retrieve new lists of packages
upgrade – Perform an upgrade
install – Install new packages (pkg is libc6 not libc6.deb)
remove – Remove packages
autoremove – Remove automatically all unused packages
purge – Remove packages and config files
source – Download source archives
build-dep – Configure build-dependencies for source packages
dist-upgrade – Distribution upgrade, see apt-get(8)
dselect-upgrade – Follow dselect selections
clean – Erase downloaded archive files
autoclean – Erase old downloaded archive files
check – Verify that there are no broken dependencies
changelog – Download and display the changelog for the given package
download – Download the binary package into the current directory

Options:
-h This help text.
-q Loggable output – no progress indicator
-qq No output except for errors
-d Download only – do NOT install or unpack archives
-s No-act. Perform ordering simulation
-y Assume Yes to all queries and do not prompt
-f Attempt to correct a system with broken dependencies in place
-m Attempt to continue if archives are unlocatable
-u Show a list of upgraded packages as well
-b Build the source package after fetching it
-V Show verbose version numbers
-c=? Read this configuration file
-o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp
See the apt-get(8), sources.list(5) and apt.conf(5) manual
pages for more information and options.
This APT has Super Cow Powers

As you can see there are many options just in the help text. This simple command line tool is the basis for most all Debian based package management. I have never touched the full power of apt, but I am still learning.
This short post only scratches the surface for the power and flexibility of one tool. And there are several more each with broad capabilities just waiting for you.

penguin2sm3

 

 

2 thoughts on “Update and Install With the Command Line Using Apt

  1. Andrew

    You can do sudo apt-get update && sudo apt-get upgrade, it make it lot easier for daily updates check.

    Reply
    1. Jraz Post author

      Thanks for the tips. Like I mentioned, I have a lot to learn. That is one of the things I like about Linux is the amount of options there are to do just about anything. I have used this method before but not yours.

      sudo apt-get update && sudo apt-get upgrade

      Jraz

      Reply

Leave a Reply