5 ms·
This is like that time, last week, when I was having issues with do-release-upgrade and someone helpfully suggested to run sudo apt-get purge python* && sudo a
by megiddo 6y ago
This is like that time, last week, when I was having issues with do-release-upgrade and someone helpfully suggested to run
sudo apt-get purge python* && sudo apt-get autoclean && sudo apt-get install python*
Which I did without paying attention to what I was doing and it turns out that this is one of the worst things you could do ever on a Debian-based distro.
Damn you, abu-ahmed al-khatiri.
- segfaultbuserr 6y agoAlso on Gentoo. Once you've done it, your package manager is gone... At least you'll be warned when you attempt to do it, and often there will be two or more Python installations (2.7, 3.x), and Portage will run on any of them, so incidents like these are actually rather rare.
- steffan 6y agoThis reminds me of fun times compiling and upgrading libc on a running system. It's challenging, but if you plan it out, it's not bad. But if you miss a step...better hope you have some statically compiled tools somewhere that can help you out.
- ciarannolan 6y agoWhat's wrong with that command?
- NikolaeVarius 6y agoOS requires python pkgs for much core functionality. Command gets rid of all of them
- dllthomas 6y ago... assuming you don't have any files starting with `python` in the current directory, in which case you might (or might not) be just fine.
- segfaultbuserr 6y agoMany programs, including system utilities, are written in or indirectly powered by Python. Removing Python effectively cripples half of your system.
- LinuxBender 6y agoThis used to be an issue in the Redhat flavors. You could uninstall python or bash and the system would eat itself (RHEL5 and before). Since then, they have added protections for specific packages and you can even add further protections for whatever you consider to be critical packages.
- yodelshady 6y agoI can't speak for all Debian, but I've done the same on a Ubuntu. Both the package manager and terminal emulator rely on python. It's not quite rm -rf /, but it was certainly "fun".
- txutxu 6y agoIf you install a minimal Debian server avoiding recommends, and remove a few non critical packages, you can remove python, and start building from there. No problem. Nothing is wrong. If you go with a default installation, and start building over there, for example a desktop system. This will remove everything else that depends on python (not only python). And that, is probably wrong, as you do not expect to remove half of the system (and don't reinstall it back), when you try to reinstall python, like megiddo said. Some packages that do not need python at all, depend on python because of the packaging choices, like post/pre install scripts written in python instead of shell. Other packages that do not use python in their core functionality (for example a program written in C) depend on python because of add-on scripts or contributed extensions, shipped in the same package. Unlike Debian, in the Ubuntu case this command is worse, because Canonical push hard for python. Historically, many Debian packages depending on python, have been introduced or modified by maintainers/developers working for Canonical. To install a minimal Ubuntu server without python, first you need to remove many packages (a lot), related to launchpad, or landscape, or a few other Ubuntu specific services, or stuff really intended for desktop users (not for a minimal server). Nothing against Python or Canonical... but as I have needed to deploy servers at work with the requirement of really really minimal base, I know well about removing Python in both Linux distributions.
- kbenson 6y agoThat's why dnf (the yum successor) has dns, sudo, systemd, systemd-udev and yum set as protected packages by default on Centos 8 (and you can't remove python withouth removing dnf/yum because of dependencies, so it should stop that as well). I imagine apt has something similar, and maybe it's not (or wasn't) set by default on the dist you're running? If not, I would raise that as a bug with the distro, as breaking it with a command like that should be much harder to do accidentally.
- JdeBP 6y agoPython isn't essential on Debian. * https://unix.stackexchange.com/a/491645/5132 https://unix.stackexchange.com/a/491645/5132
- nexuist 6y agoI can one up you: Coworker was trying to remove node so we could install a new version, so he ran: rm -rf /usr/bin node -rf was due to muscle memory, and unfortunately he forgot the space. That was a fun one to clean up. We were able to use nc because that was in /bin and not /usr/bin, so we used that to pipe curl over through a socket and then used curl to install dpkg + apt, then ran apt update to fix everything and that seemed to work. That server is still running today, but I'm sure something is still seriously wrong with it. Nothing that affects me though, so I don't care haha.
- lexicality 6y agoIt always scares me when people automatically add -rf after typing rm no matter what they're doing. How do you even get into that habit in the first place?
- kazinator 6y agoIf I were to guess, how one might get into that habit is being annoyed by error messages: "cannot remove 'foo': is a directory" Just remove the darned object you're given as an argument using the appropriate implementation for its type. "rm: remove write-protected regular file 'foo'?" The rules are that if the directory is writable, the object can be deleted. Though you called stat to figure out it's a regular file, you didn't notice the link count: I have two more hard links to the file in the same directory, and one elsewhere. But, yes, unlink it.
- NikolaeVarius 6y agoI have this bad habit. Because in linux everything is a file, so screw you rm stop telling me i can't delete that directory. Its just a file that points to another directory. Its messing up my flow.
- accelbred 6y agoIf git repositories didn't need a -f to rm I wouldn't, but its a habit from git repos giving errors.
- lovehashbrowns 6y ago
- srtjstjsj 6y ago> abu-ahmed al-khatiri. Who? The Osama bin Laden associate? Why?
- megiddo 6y agoJust the poster on stack overflow.