Apt-get source and Apt-get build-dep
When dealing with open source packages or source code, programmers usually want to study the source code and/or debug the source code. This is where Source comes in. Source is used to grab the source package.
For this to work, point the deb-src entry in /etc/apt/sources.list to unstable (it should also be uncommented). Perform an update once the sources.list file has changed.
Then uncomment the deb-src lines.
Then perform an update:
Download the source package:
sudo apt-get source image magic
The following is in the imagemagick_source folder:
The latter is used to install all of the dependencies for a given package that will allow it to be built. In other words, dependencies are libraries/programs required to compile the package. And the latter will get the dependencies for you.
sudo Install apt get <package>
This is the command that most people are forced to use and is therefore the most well known and used. It will download and install any package of your choice. So let’s see what it does:
In this case I decided to install a package that I already have on my system. However, what you need to pay attention to are the first two lines.
“Read package lists… Done” – went through the software repository and checked all available packages.
“Create dependency tree‘ – this is where apt-get builds the other packages needed to run the desired package.
APT will fetch all requests and install them as well. /etc/apt/sources.list is used to locate the packages. To install a specific version of a package, you can write:
On the other hand, if you just wanted to download the package but not install it, you can do that by adding the d switch. The latter downloads the file and places it in /var/cache/apt/archives.
You can also simulate an installation with the s switch (-s, -simulate, -just-print, -dry-run, -recon, -no-act)
The latter does not alter the system in any way, shape or form, but rather simulates an installation. When a non-root user simulates an installation, it may look garbled due to lack of access to certain configurations.
The next thing we’ll look at is the fix-broken (-f, -fix-broken):
In this case, an attempt is made to repair broken dependencies.
This command – clean – is used to clean the local repository of packages. It removes everything from /var/cache/apt/archives, which basically frees up some disk space on the system.
Autoclean, on the other hand, is used to remove useless files.
Suppose I download (and only download) VLC with the command. sudo apt-get -d install vlc. This is what /var/cache/apt/archives looks like:
Now let’s use Autoclean:
And now let’s clean up:
By now it is assumed that you have figured out what clean does and what doesn’t.
sudo apt-get –clean Extinguish <package>
To remove a package with APT you can either use purge or remove or both here. Remove is used to remove the package but NOT the configuration files. Purge also removes all configuration files.
sudo apt-get autoremove <package>
Whenever you install a specific package, all of its dependencies are also installed automatically. On the other hand, if you remove the package, the package is removed but the dependencies remain. This is where apt-get autoremove comes into play. Autoremove not only removes the installed package, but also the installed dependencies.
sudo apt get update
As the term suggests, this command is used to update. What is updated now and what does the command do? In this case, the /etc/apt/sources.list file is consulted and the database of packages available to the user is updated. If the sources.list file ever changes, be sure to run this command.
So here, in the previous image, I ran the update command and we can see that it ejects a few lines. These lines say “Hit”, “Get” or “Ign”.
Match: No changes in package version
Get: New version is available and APT will get it for you
Ign: Ignore the packet
The APT update will not download and install all newly available packages. However, you can type the following to see which ones have a newly available version:
As you can see, this shows the current version (on your system) you have and the new version available.
sudo apt-get upgrade
The next command that is similar to the update command is the upgrade command. The latter command (upgrade) is used to upgrade or install newer versions of all the various packages that are already installed on the system. It fetches the latest versions from the sources located in the etc/apt/sources.list file. Packages already installed on a system are NEVER removed and new packages not currently installed are never installed. However, the “upgrade” applies to ALL packages currently installed on the system. If a package cannot be upgraded without changing the status of another package, it remains UN-UPGRADED. Typically, the upgrade command is preceded by the update command. This is to ensure that APT knows that there are indeed new packages out there.
sudo apt-get dist-upgrade
This special command is used to update the system to a new version. In this case, some of the packages can be removed. The difference between the upgrade and dist-upgrade commands is that dist-upgrade removes specific packages. But there is no package removal for the upgrade.
sudo apt-get download <package>
This is similar to -d install. Apt-get -d install downloads the file to /var/cache/apt/archives while apt-get download downloads the deb file to the current working directory. Apt-get download downloads the deb file but not the dependencies. Also, apt-get download doesn’t install the package.
sudo apt get check <package>
Sudo apt-get check is used to update the package cache and check for broken dependencies.
For more information and more options please enter:
The APT GET commands are very powerful and yet very simple. In this tutorial, we learned how to use the APT GET commands: source, build-dep, install, clean, autoclean, purge, remove, autoremove, update, upgrade, dist-upgrade, download and check were covered in this tutorial .