APT 4 Newbies

Homitsu
  13 years ago
  41

- INTRO -

The Advanced Packaging Tool, or APT, is a free user interface that works with core libraries to handle the installation and removal of software on the Debian GNU/Linux distribution and its variants. APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages.
 
When you launch Software Manager or Update Manager or Synaptic Package Manager, you're using APT via different GUIs. But you can control APT even via command lines in an easy and quick way.
 

- WHAT YOU NEED TO KNOW -

To understand this tutorial you must know:
  • how to open a terminal;
  • your root password;
  • what is a repository;
  • how to connect your computer to the internet.
Every first "sudo" command will be followed by a password request. Remember that when you type a password in terminal, you see nothing on screen.
 
All command lines are wrote in "classical syntax"; they work in Mint, Ubuntu, Debian and other distros supporting APT. A lot of commands have this structure:
 
sudo apt-get myspecificcommand
 
In Mint you can use just "apt", without "sudo" and "-get" [thanks remoulder]:
 
apt myspecificcommand
 
Of course, for security reasons, system will still ask you the root password.
 

- TO ADD A REPO -

If you need a software that is not in the official list, you must add its repository to your software sources. To know the repository data, browse the software site.
 
Let's make an example with Ubuntu-Tweak [a kind of "Swiss Tool", partially compatible with Mint]. It's not listed in the software manager.
 
Browsing official site, you find the repository id is ppa:tualatrix/ppa. To add it to your sources, open a terminal and write this string.
sudo add-apt-repository ppa:tualatrix/ppa
Your system will contact the repo and import all the needed data. So, the command line to add a repo is
sudo add-apt-repository ppa:your-repo/ppa

- TO UPDATE SOFTWARE LIST -

This one is used to resynchronize the package index files from their sources.
sudo apt-get update
System will contact all repos to update the local index of available software. An update should always be performed before an "upgrade". Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.
 

- TO UPGRADE ALL YOUR SOFTWARE -

This one is used to install the newest versions of all packages currently installed on your system.
sudo apt-get upgrade
upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
 

- TO FIND THE REAL NAME OF A SOFTWARE - 

When you don't know the complete name of a software listed in your local index you can use this command [even without "sudo"].
apt-cache search mysoftware
 

- TO INSTALL A SOFTWARE -

This one is easy to understand.
sudo apt-get install mysoftware
Do you need to install more than one software? Yes, you can.
sudo apt-get install mysoftware-1 mysoftware-2 mysoftware-3
All packages required by the package(s) specified for installation will also be retrieved and installed.
 

- TO UNINSTALL A SOFTWARE -

Basic command is

sudo apt-get remove mysoftware
It is identical to "install" except that packages are unistalled instead.
 

- TO PURGE A SOFTWARE -

sudo apt-get purge mysoftware         
It is identical to "remove" except that packages are removed and purged (any configuration files are deleted too).
 

- SPRING CLEANING -

"clean" clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
 
"autoclean" clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control.
 
"autoremove" is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed.
 
You can concatenate commands with "&&".
sudo apt-get autoclean && sudo apt-get autoremove

- TO CALL A COW -

apt-get moo

- MAIN REFERENCE - 

man apt-get
 
- INTRO -
The Advanced Packaging Tool, or APT, is a free user interface that works with core libraries to handle the installation and removal of software on the Debian GNU/Linux distribution and its variants. APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, 
 
When you launch Software Manager or Update Manager or Synaptic Package Manager, you're using APT via different GUIs.
 
But you can control APT even via command lines in an easy and quick way.
 
- WHAT YOU NEED TO KNOW -
 
To understand this tutorial you must know:
 
how to open a terminal;
your root password;
what is a repository;
how to connect your computer to the internet.
 
- TO ADD A REPO -
 
If you need a software that is not in the official list, you must add its repository to your software sources. To know the repository data, browse the software site.
 
Let's make an example with Ubuntu-Tweak [a kind of "Swiss Tool", partially compatible with Mint]. It's not listed in the software manager.
 
Browsing official site, you find the repository id is ppa:tualatrix/ppa. To add it to your sources, open a terminal and write this string.
 
sudo add-apt-repository ppa:tualatrix/ppa
 
Your system will contact the repo and import all the needed data. So, the command line to add a repo is
 
sudo add-apt-repository ppa:YOUR-REPOSITORY/ppa
 
- TO UPDATE SOFTWARE LIST -
This one is used to resynchronize the package index files from their sources.
 
sudo apt-get update
 
System will contact all repos to update the local index of available software. An update should always be performed before an "upgrade". Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.
 
 
- TO UPGRADE ALL YOUR SOFTWARE -
This one is used to install the newest versions of all packages currently installed on your system.
 
sudo apt-get update
 
upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
 
 
- TO FIND THE REAL NAME OF A SOFTWARE - 
When don't know the complete name of a software listed in your local index you can use this command [even without "sudo"].
 
apt-cache search MYSOFTWARE
 
- TO INSTALL A SOFTWARE -
This one is easy to understand.
 
sudo apt-get install MYSOFTWARE
 
Do you need to install more than one software? Yes, you can.
 
sudo apt-get install MYSOFTWARE-1 MYSOFTWARE-2 MYSOFTWARE-3
 
All packages required by the package(s) specified for installation will also be retrieved and installed.
 
- TO UNINSTALL A SOFTWARE -
Basic command is
 
sudo apt-get remove MYSOFTWARE
 
It is identical to "install" except that packages are unistalled instead.
 
- TO PURGE A SOFTWARE -
sudo apt-get purge MYSOFTWARE
           
It is identical to "remove" except that packages are removed and purged (any configuration files are deleted too).
 
 
- SPRING CLEANING -
"clean" clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
 
"autoclean" clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control.
 
"autoremove" is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed.
 
You can concatenate commands with "&&".
 
sudo apt-get autoclean && autoremove
 
- TO CALL A COW -
 
apt-get moo
 
- MAIN REFERENCE - 
 
man apt-get
Comments
rpr-nospam 10 years ago

The tutorial does not explain how to remove a repository added with add-apt-repository. The --remove option mentioned on the man page for Ubuntu 14.04 (http://manpages.ubuntu.com/manpages/trusty/man1/add-apt-repository.1.html) does not exist in the Mint version of the add-apt-repository command.

It seems the only way is to remove the corresponding file in the /etc/apt/sources.list.d directory:

sudo rm -i /etc/apt/sources.list.d/repository-name*


DarrenG 10 years ago

very nice


philsoft 10 years ago

thanks great info..helps newbiesss...like me


DestinTheGreat 11 years ago

Thx


MagicMint 11 years ago

As the capabilities of apt and its derivatives are overwhelming, it is essential to have a comprehensive list of the main use cases — and your tutorial excels at this job.

A little precision though: besides maybe LMDE, in Linux Mint the password you have to enter for sudo is your own, not the one for root.


sujitnag 11 years ago

very informative.


jaderiver 11 years ago

Clear, concise tutorial with steps and definitions clearly explained for learning or memory refresh. Both newbies and longtime linuxheads can appreciate.

Thank you!


Mintification 12 years ago

aptitude moo
aptitude -v moo
aptitude -vvv moo
aptitude -vvvv moo
(sorry, couldn't resists) :D


roht 12 years ago

simple but helpful!


traction2012 12 years ago

Hope you don't mind, but I believe this is so useful that I've downloaded a copy for permanent reference. Thank you very much for sharing your expertise in an easy and understandable fashion. One day I also hope to share any knowledge acquired with others.


Examiner 13 years ago

Thank you! These basic instructions were of great benefit to one who owns and operates several websites, but has no programming experience. Often these basic "how-to"s are overlooked by those who know terminal commands inside and out. Keeping in favorites!


Maximiliano 13 years ago

Very good, clear and understandable (and nice format). Thank you.


komodo169 13 years ago

Very easy to follow. Nicely done and thank you. :)


Homitsu 13 years ago

@ trollboy

I think there is no distro at all where you could install software without root password. It linux; not Win not Mac.

:-)


trollboy 13 years ago

It does ask for a password on LMDE when you just use apt. Frankly I didn't want to move and I am relieved not to have to.


trollboy 13 years ago

"Of course, for security reasons, system will still ask you the root password."

That's a good thing!

I wasn't sure if it would install:
a) To your home directory
b) System wide with a password
c) System wide with no password

I inferred c) from the comment lmade by @remoulder. I'm happy to be corrected.


Homitsu 13 years ago

@remoulder && @trollboy

I've add something about in "What you need to know" paragraph.

Thanks for help.


trollboy 13 years ago

I'm going to have to try that tonight. If your right and I can install system wide software without sudo and by inference no password, then Mint will never get out of the sand-boxed environment I have it in; if LMDE does it, I'll be off to a distro that enforces good security practices.


remoulder 13 years ago

In mint it is not necessary to use the -get version nor prefix it with sudo.


Homitsu 13 years ago

@trollboy You're right! Now it's fixed, thank you!


trollboy 13 years ago

Nice tutorial @Homitsu very easy to follow. I do have one query though.

Should sudo apt-get autoclean && autoremove be sudo apt-get autoclean && sudo apt-get autoremove