apt get command in linux to update, install, remove and manage packages
![]() |
apt-get command in linux |
Hello guys, Today I'm going to show you how you can use the "apt" command in linux. To Install, Remove and Manage packages in Debian based operating system.
Most of the Debian based operating system you can use "apt" command to install, remove and update packages in your system.
What is "apt" command?
You need superuser privilege to use "apt" command so just use "sudo apt" because you are managing your packages in your system.
Update all Packages
![]() |
Update all Packages in your System |
$sudo apt update
These package files are saved in a file called "sources.list". Which is in the location of "etc/apt/sources.list".
Install software/package
![]() |
Install a Package in Linux |
$sudo apt install packageName
For example, I want to install a package called "git". So I just need to type "sudo apt install git" and press ENTER.
![]() |
Example |
It's going to make a list of dependencies and software and also going to show you the amount of disk space it takes from your computer.
For example, This "git" requires "50.5 MB" of memory on my system and it going to ask whether you want to install it or not.
Check Version
![]() |
Check Version |
$packageName --version
Remove software/package
![]() |
Remove Packages in linux |
$sudo apt remove packageName
I want to remove the "git" package. So I just write "sudo apt remove git" and press ENTER. It's going to remove the package from my system.
Note:
But it's not going to remove configuratios from your system. It just remove the package only.
--purge flag
![]() |
Remove configuration files |
$sudo apt remove --purge packageName
To remove the configurations you need to use "--purge" flag. So just write "sudo apt remove --purge git" press ENTER.
Remove unwanted libraries
$sudo apt autoremove
For this, you can use "sudo apt autoremove" command to remove all unwanted dependencies and libraries which are no longer needed.
It asks for confirmation to remove. Before removing just check the above libraries which are really necessary for you.
Conclusion
In this way you can use the "apt" command for Installing, Removing software and dependencies.
There are more flags you can use with this "apt" command. But these are the most frequently used commands in "apt".