Command line generally looks like a complicated thing but if you get to know few Terminal commands in Ubuntu, it will make your life easier as a Linux user. By using terminal you can easily manage installed applications, install new applications, update installed applications or remove applications from Ubuntu. This is a guide on managing applications in Ubuntu by using terminal commands.
Press Ctrl+Alt+T to bring up ‘Terminal’ in Ubuntu. We will be using these commands in Terminal. Roughly speaking, Terminal is like the ‘DOS’ program in Microsoft Windows.
Tip: We start a command with sudo in Terminal, where we need to run command as a super user.
Installing, Updating, Upgrading and Removing Apps
These commands are probably most important as we will be using these more often. The apt-get command is a powerful command-line tool, which works with Ubuntu’s Advanced Packaging Tool (APT) that performs such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.
For example, to install the Testdisk tool, type the following in Terminal and Hit Enter.
sudo apt-get install testdisk
To install multiple packages at the same time use apps names separated by spaces. Use command like below:
sudo apt-get install synaptic vlc gimp gimp-data gimp-plugin-registry gimp-data-extras y-ppa-manager bleachbit openjdk-7-jre oracle-java8-installer flashplugin-installer unace unrar zip unzip p7zip-full p7zip-rar sharutils rar uudeview mpack arj cabextract file-roller libxine1-ffmpeg mencoder flac faac faad sox ffmpeg2theora libmpeg2-4 uudeview libmpeg3-1 mpeg3-utils mpegdemux liba52-dev mpeg2dec vorbis-tools id3v2 mpg321 mpg123 libflac++6 totem-mozilla icedax lame libmad0 libjpeg-progs libdvdcss2 libdvdread4 libdvdnav4 libswscale-extra-2 ubuntu-restricted-extras ubuntu-wallpapers*
Above are essential packages that you may want to install after Ubuntu install.
To remove the package installed in the previous example (testdisk), use the following command:
sudo apt-get remove testdisk
Completely Remove Package
To remove the package in the previous example (testdisk) completely from Ubuntu, use the following command:
sudo apt-get purge testdisk
sudo apt-get remove --purge testdisk
Use purge with caution because it will remove apps configuration files also, that may not be desired effect on system.
Following command removes packages that were installed by other packages and are no longer needed.
sudo apt-get autoremove
Following command removes an installed package and dependencies.
sudo apt-get autoremove <package_name>
Tip: You may specify multiple packages to be installed or removed, separated by spaces.
Update the Package Index
The APT package index is essentially a database of available packages from the repositories defined in the /etc/apt/sources.list file and in the /etc/apt/sources.list.d directory. To update the ‘local package index’ with the latest changes made in the repositories, use the following command in Terminal:
sudo apt-get update
Tip: Run update command periodically to make sure your source list is up-to-date.
This command upgrades all installed packages. Over time, updated versions of packages currently installed on your computer may become available from the package repositories (for example security updates). To upgrade your system, first ‘update package index’ as mentioned above, and then use following command:
sudo apt-get upgrade
Upgrade Only Important Packages
Following command tells ‘APT’ to use “smart” conflict resolution system, which will attempt to upgrade the most important packages.
sudo apt-get dist-upgrade
Check Broken Dependencies
Following command does an update of the package lists and checks for broken dependencies.
sudo apt-get check
Fix Broken Packages
Use this command if you get complaints about packages with “unmet dependencies”.
sudo apt-get -f install
Clean Disk and Regain Space
Following command removes .deb files for packages that are no longer installed on your system.
sudo apt-get autoclean
You can also remove these useless files from /var/cache/apt/archives that may regain a significant amount of disk space.
Removes all packages from the package cache by using following command.
sudo apt-get clean
If you want to know how much space cached packages are consuming use the following command:
du -sh /var/cache/apt/archives
And here are few more useful commands related to packages management.
List All Available Packages
sudo apt-cache pkgnames
Find Out Package Name and Description
sudo apt-cache search <package name>
Check Package Information
sudo apt-cache show <package name>
Check Dependencies for Specific Packages
sudo apt-cache showpkg <package name>
Check Cache Statistics
sudo apt-cache stats
Upgrade Only Specific Packages
sudo apt-get install <package name> --only-upgrade
Download Only Source Code of Package
sudo apt-get --download-only source <package name>
Download a Package Without Installing
sudo apt-get download <package name>
Check Change Log of Package
sudo apt-get changelog <package name>