You are here

Ultimate Guide to Removing Software with APT in Ubuntu


Ultimate Guide to Removing Software with APT in Ubuntu

Are you struggling to manage and remove software on your Ubuntu system? You're in the right place. Learn how to efficiently uninstall packages using the APT package manager with this comprehensive guide.

1. Mastering Basic Uninstall Commands:

  • Effortless Package & Dependency Removal:

Use the below command to quickly uninstall a software package and its redundant dependencies:

sudo apt-get autoremove program_name

·  Direct Package Removal:

Want to keep the dependencies but remove the main software? Here’s how:

sudo apt-get remove program_name

·  Wipe Out Configuration Files:

Leave no trace behind by purging associated configuration files:

sudo apt-get purge program_name

2. Unlocking the Power of the APT Log:

Ever felt apt-get autoremove missed something? Dive deep into the APT log to ensure a clean slate:

cat /var/log/apt/history.log | more

Example of the output:

Start-Date: 2016-08-03  07:46:19
Commandline: apt-get install samba
Install: python-tdb:amd64 (1.3.8-2, automatic), python-samba:amd64 (2:4.3.9+dfsg
-0ubuntu0.16.04.2, automatic), python-dnspython:amd64 (1.12.0-1, automatic), sam
ba:amd64 (2:4.3.9+dfsg-0ubuntu0.16.04.2), samba-dsdb-modules:amd64 (2:4.3.9+dfsg
-0ubuntu0.16.04.2, automatic), libaio1:amd64 (0.3.110-2, automatic), tdb-tools:a
md64 (1.3.8-2, automatic), attr:amd64 (1:2.4.47-2, automatic), samba-common:amd6
4 (2:4.3.9+dfsg-0ubuntu0.16.04.2, automatic), samba-vfs-modules:amd64 (2:4.3.9+d
fsg-0ubuntu0.16.04.2, automatic), samba-common-bin:amd64 (2:4.3.9+dfsg-0ubuntu0.
16.04.2, automatic), python-ldb:amd64 (2:1.1.24-1ubuntu3, automatic)
End-Date: 2016-08-03  07:47:23

3. Real-world Scenario: The Samba Package:

After installing samba, you'll notice related dependencies like python-tdb or python-samba. To remove them all in one swoop, execute:

sudo apt-get autoremove --purge python-tdb python-samba python-dnspython samba samba-dsdb-modules libaio1 tdb-tools attr samba-common samba-vfs-modules samba-common-bin python-ldb

4. Automate Like a Pro: Parse Logs Swiftly:

Skip the manual hassle! Use these commands for instant package details extraction:

sudo sed -n '/Commandline: apt-get install имя_пакета/,/End-Date:.*/p' /var/log/apt/history.log | sed -n '/Install.*/p' | sed -e s'/Install: //g' | sed -e s'/:amd64 //g' | sed -e s'/(.[^)]*),\{0,1\}//g' | tr '\n' ' '

Tip: Ensure accurate filtering to catch details from the latest installation.

sudo sed -n '/Commandline: apt-get install имя_пакета/,/End-Date:.*/p' /var/log/apt/history.log | sed -n '/Install.*/p' | sed -e s'/Install: //g' | sed -e s'/:amd64 //g' | sed -e s'/(.[^)]*),\{0,1\}//g' | tail -1

5. One-Command Clean Removal:

Become a master uninstaller with this ultimate removal command:

sudo sed -n '/Commandline: apt-get install имя_пакета/,/End-Date:.*/p' /var/log/apt/history.log | sed -n '/Install.*/p' | sed -e s'/Install: //g' | sed -e s'/:amd64 //g' | sed -e s'/(.[^)]*),\{0,1\}//g' | tr '\n' ' ' | sudo xargs apt-get autoremove --purge -y

Wrapping Up:

APT makes software management in Ubuntu a breeze when you've got the right commands at your fingertips. For more hands-on guidance, our video tutorial below is a must-watch.

0 0

Share the article with your friends in social networks, maybe it will be useful to them.


If the article helped you, you can >>thank the author<<