 Some of the most frequently asked support questions regarding Linux involve package management. How can I update my software, install software, remove software? And regarding removing software, one of the most frequently asked questions is how can I completely remove a program from my system? And by completely remove, I'm not talking about just removing the executable binary, the actual program itself. I want to remove all its dependencies, the libraries, any kind of specific config files that were generated when I installed that program. I want everything associated with that program removed from my system. How can I do that? Well, let's discuss it. Now there are so many different package managers available on Linux. There's so many ways to install software on Linux. I can't possibly talk about every single package management system. So I'm just going to cover some of the most popular ones on this video. By far the most popular package manager on Linux is the apt package manager. The apt package manager is the package manager for Debian and Ubuntu and all distributions based on Debian and Ubuntu. The apt package manager is also used in PC Linux OS, which is a RPM distribution, oddly enough, but it uses the apt package manager. So let's go ahead and open a terminal here inside Ubuntu is what I'm demonstrating this on. Typically to remove software using the apt package manager, you would sudo apt remove and then the name of the program, whatever it happens to be if I was, you know, uninstalling Firefox, for example, sudo apt remove Firefox. Now the problem with the sudo apt remove Firefox command here is that it's just going to remove the program Firefox. It's not going to remove any configuration files that were placed on the system when you installed Firefox and this really is standard practice with most remove or uninstall commands with most Linux package managers. Typically when you uninstall a program, it doesn't remove all the associated config files and stuff like that. It doesn't remove dependencies most of the time. So how do you get rid of everything? Well here inside Debian or Ubuntu using the apt package manager, instead of sudo apt remove, you want to run the command sudo apt purge name of program and when you run this command, it should remove the program itself. It should also remove all system wide config files. And by system wide config files, I mean config files that live somewhere inside the root file system, not in your home directory. These are not user specific config files. These are system wide config files. You typically think of them as the default config files that are usually installed when you install a program. Now one thing sudo apt purge doesn't do is it doesn't automatically remove the dependencies that were needed. If Firefox had some dependencies and they're no longer needed, they don't get uninstalled right away. What you would need to do is somewhere along the way you want to run the sudo apt auto remove command and this will get rid of any unneeded dependencies, any orphan packages and things like that. And typically you don't necessarily have to run this command yourself. A lot of times when you just update your system with a sudo apt update and an sudo apt upgrade, a lot of times the apt package manager is smart enough to let you know when you have some unneeded stuff on your system and it will actually prompt you to run the apt auto remove command when you need to. Now that takes care of almost everything that was associated with that program. Once you run sudo apt purge name of program and then you also did the sudo apt auto remove just to make sure there's no unneeded dependencies still on the system. At that point everything associated with that program should be gone except any user config file. So these are config files that live inside your home directory. On Linux, typically let me open the graphical file manager. Typically on Linux you'll have a config folder. Let me show hidden files I believe control H shows hidden files and most file managers there it is and we have a folder here called .config. Let's go into the .config directory and then you see all of these various folders for example Nautilus which is the file manager I'm in has a config file right so it has a config directory where I could put some config information. There is nothing in this directory it's an empty directory. Let's see if gEdit has a config file that actually is here yeah there is a file associated with gEdit which is a plain text editor. So if I uninstalled gEdit right now I did a apt purge this directory is still going to be here. The reason is this is in my home directory it's one of my own config files it's a user config file that I could edit and manage myself and package managers on Linux typically can never touch your home directory. They are not allowed to touch your home directory or any files or directory in your home directory they're just they're not given that kind of permission and that's done for safety reasons let me go back to the terminal here and just to verify this is the case if I do a sudo apt purge gEdit let's go ahead and remove it and you can see gEdit is going to be removed these were some of the packages that are no longer necessary so we'll do an apt remove to remove those packages once we uninstall gEdit. So now let's do the sudo apt auto remove let's get rid of those unneeded dependencies because we removed gEdit so those are no longer necessary and now if I go back to the file manager you can see in our .config directory we still have this gEdit directory with a gEdit config file it can't remove that package managers again they're not allowed to touch your home directory so to remove this what you would have to do is you would just have to delete it yourself I hit and delete on the keyboard on that directory it's gone now the reason these package managers can't touch your home directory it's because obviously it would be dangerous because all of your user data of course lives in your home directory typically you save like all of your documents and home slash documents and all of your videos home slash videos yada yada yada package management systems could be dangerous if they were allowed for example to move files delete files you know it could it could cause you some data loss that's why package managers like abt and pacman and things like that they will never touch your home directory so your user config files you always are responsible for deleting those you have to go and manually delete those yourself now let's talk about how to do what we just did using the pacman package manager which of course is the package manager on Arch Linux and all distributions based on Arch Linux so let me open a terminal I'm gonna zoom in so typically to remove a package in pacman most people are probably gonna run pacman dash capital R and then the name of whatever program that you want to uninstall this removes just the program it does not remove those system wide config files it doesn't remove dependencies but we can take care of that if instead of just dash capital R I added NS to that now what this will do this will remove the program and it will also remove all dependencies associated with that program and that pretty much takes care of everything it's kind of like the sudo apt purge and the sudo apt auto remove command all in one command here so pacman dash capital R lowercase NS will take care of everything except any user config file so anything in your actual user's home directory you know home slash dot config slash name of program you'll have to go find that stuff yourself and delete it manually everything else though everything that's in the root file system associated with this program and all its dependencies they should be removed automatically with this command now let's talk about snap packages so if I do a snap list I'm not sure what snaps I have installed on the system I'm gonna get a few here typically well let's let me install a snap package that I know exists I'm gonna do a sudo snap install corny jokes corny jokes it's really just a weird little funny program that really serves no purpose it's just a nice small program that serves as a good example of how to install a program using snap so sudo snap install corny jokes now that I've done that let's see what all that installed on my file system so if I do a sudo find enroute which is searching in the root directory so search my entire file system using the find command dash I name and sensitive name search for the string corny jokes this may take a minute since it's searching the entire file system and it finished running that search using the find command so these are all the corny jokes files and directories on the system we do have one in our home directory at home slash DT slash snap because snap has a directory in the home directory and then corny jokes so this would be a user-specific corny jokes stuff living in the home directory right but then everything else is in the root file system you can see most of it is in slash var slash var slash lib slash snap D typically where all the snap stuff the system wide snap stuff exists so the typical command to remove a snap pack is sudo snap remove corny jokes so let's go ahead and remove corny jokes with snap remove now that I've done that if I run that sudo find command enroute again for the string corny jokes let's see if it actually removed everything and as you can see it removed everything in the root file system but it cannot go in the home directory it is not allowed to remove anything from your home directory and again that's typical with package management systems they're just not allowed to do that so once again if you want to go and delete that particular directory what you would need to do is just go into your file manager yourself go in your home directory slash snap slash corny jokes and just delete that yourself now let me clear the screen let's talk about flat packs let me do a flat pack list see what all I have installed as a flat pack currently now typically to uninstall something with a flat pack you would do a sudo flat pack uninstall I believe and then well I don't actually use ungoogled chromium let me actually remove that it's a you just copy that and then paste that and you can see it wants to remove ungoogled chromium or ungoogled chromium codex actually we want both of those removed one is a dependency of the other so that should remove everything associated with ungoogled chromium but let's actually do a sudo find enroute dash I name and let's just see do a search for the string ungoogled and yes there is no file or directory on the system anymore that has the string ungoogled so I do think it actually deleted everything but there is a flag I believe associated with flat pack so if I did a flat pack uninstall and then dash dash delete dash data I believe that is a another kind of command that will also make sure that all data associated with the program everything gets deleted obviously it won't go in your home directory and like go into dot config and remove any of your user config files once again you're gonna have to do that yourself probably the easiest package management system to manage as far as you know getting rid of everything associated with a program or app images so let me actually open my graphical file manager let me go in my home directory slash applications so this is your home directory slash applications with a capital A this is where all app images should live on your system and with app images there's not really a package manager necessarily and you don't go to the command line to to remove software with app images there these self contained binaries what they're the self-contained binaries but it's really a archive it includes the binary the program itself it includes all the dependencies so for example if I wanted to remove for example this LibreOffice app image and I just delete it and just hit the delete key right Libre Office that app image is gone everything associated with LibreOffice all the dependencies they were all in that app image so there's nothing else for me to do the only thing that could be left on the system is if I had a specific config file for LibreOffice wherever LibreOffice puts config files I don't even know if you have user config files associated with LibreOffice I'm sure you do they probably be in your home directory dot config slash LibreOffice if that exists I would have to go and manually delete that myself another thing we should talk about briefly is what happens if you build packages yourself you build a program from source how do you completely remove that stuff from your system what you have to manage that yourself because a package manager doesn't know about programs you build from source for example let me go into some of my source code stuff here so I maintain my own builds of st for example the suckless simple terminal right and this is the source code for it so if I want to actually remove st from my system what I would need to do is I would need to find out where when I actually make the package and build the package where does the binary get placed where do any extra libraries get placed I would have to go find those on the system and there's no easy way to figure this out other than possibly reading the make file so if I read the make file here and I'll open it in neofim that gives me some idea of what happens when you actually make the package so you can see directories it makes and things it moves around it copies certain files it it copies the st binary to slash bin for example it also tells me where the man page gets placed it also tells me where the read me information gets copied to so it tells me where a lot of the files associated with st gets placed on the system just by reading that make file and this is really one of the reasons why you typically don't want to build software from source unless you have to it's because some of these programs they'll put all kinds of stuff all over your file system they're placing files everywhere on the file system none of this stuff is managed by any package manager right because you built it from source you're managing all of that stuff yourself or you're supposed to and what happens if you build a lot of programs from source over time you're going to have all this extra cruft just hanging out on your file system so unfortunately that is something that you're just going to have to deal with yourself or what you would probably need to do what I typically do is I avoid building anything from source unless absolutely necessary unless I can't find it in any package manager available on Linux then I'll build it from source and of course I didn't cover every single package manager available on Linux but they're all very similar all of them have a way to uninstall a program with all its dependencies and all its system-wide config files none of them will let you delete user data so anything in your user's home directory they cannot touch so make sure you always go into dot config and look for any config files associated with that program and delete those also go into home slash dot cache and delete any old cache files associated with that deleted program and then you may also want to go and look in home directory slash dot local slash share name of program for some extra libraries that may be hanging out in that particular directory now before I go I need to thank a few special people I need to thank the producers of this episode Gabe James Matt Maxim mimic Mitchell Paul West why you bald homie Alex armored dragon Chuck commander angry die okay George Lee Mars drum Nate Erion Alexander Paul peace watch and fedora polytech realities for less red profit Roland Steven tools develer and willy these guys they're my highest tiered patrons over on patreon without these guys this episode would not have been possible the show's also brought to you by each and every one of these fine ladies and gentlemen all these names you're seeing on the screen right now these are all my supporters over on patreon because I don't have any corporate sponsors I'm sponsored by you guys the community if you like my work I want to see more videos about Linux and free and open source software subscribe to distro tube over on patreon these guys when it comes to removing a program app image for the win