7

I use this script

bash <(curl -s https://pterodactyl-installer.se)

from this website https://www.ghostcap.com/install-pterodactyl-panel/ and I want to just uninstall the entire script and every file it downloaded.

5
  • 8
    Umm ... looking at what Pterodactyl actually does, it could have installed a whole lot of things that other aspects of your server depend on. Docker, MariaDB, UFW configurations, React, Go, PHP libraries and the like ... these things are not easily reversed out unless you know exactly what you need to keep on your system. Depending on what state you want your server to be in afterwards, it may be easier to simply rebuild the web server from scratch and restoring from backup ...
    – matigo
    Apr 26, 2022 at 0:19
  • 26
    Moral of the story : Do not run any scripts from the Internet without understanding what it does and how to undo its actions.
    – user68186
    Apr 26, 2022 at 0:35
  • 10
    You can't unbake a cake, sorry.
    – MechMK1
    Apr 26, 2022 at 9:32
  • Reminds me of some bad joke saying: "As I'm unable to program a virus, please format your harddisk yourself". I you execute commands that come from some remote server, anything can happen, and most of all you won't be able to undo the effects in most cases. So don't do that!
    – U. Windl
    Apr 27, 2022 at 8:25
  • 2
    I have no idea if it would work for you, but look up checkinstall. It might have saved you here, but I'm not sure.
    – cocomac
    Apr 27, 2022 at 17:12

4 Answers 4

32

The instructions on the script tell you to start with an operating system that is freshly installed, so if you want to go back to the point before you ran this script, you should reinstall the operating system.

As others have mentioned in comments, you can't uninstall a bash script. A bash script is simply a list of instructions and commands that run in your terminal.

If this were a simple script that only performed one or two actions, you could break it down and possibly undo these actions.

But in this case, this script executed dozens (hundreds?) of operations.

As a side note, I feel the publisher of this script did you a huge disservice by claiming that this script is "secure" and "great for people who are new to Linux". I couldn't disagree more. Running scripts or commands without knowing what they do is horribly careless. Blindly executing code opens you up to possibly malicious actions. Also, if you don't even know what the script does, you have no idea what you just did to your computer-- which is the exact situation you find yourself in right now. Nobody should ever blindly run a script without being able to read and understand exactly what the script does-- this applies to veteran Linux users just as much as it applies to people who are using Linux for the first time.

5
  • 1
    +1. The same advice applies to installing untrusted packages. They are supposed to uninstall cleanly, but you still have no idea what they actually do without inspecting them.
    – gronostaj
    Apr 26, 2022 at 10:48
  • 6
    Maybe worth noting here that Mac and Window users also do this every time the run stuff on their computers, at least Linux gives you the option to read it first. Apr 26, 2022 at 13:28
  • 1
    @JaredSmith some packages provide some level of trust by being signed. A bash script isn't usually signed
    – qwr
    Apr 28, 2022 at 4:44
  • @qwr yeah, but how many users only use signed software? Apr 28, 2022 at 13:33
  • 3
    In real life 'trusting the source' is a lot more important than 'reading and understanding exactly what the script does'. Neither you nor me read the full source of the 'script' that is the browser we wrote these comments in, but instead we trusted the source. Telling people that they shouldn't run anything they don't understand is horrible advice, as hiding stuff in scripts is painfully easy. Apr 29, 2022 at 8:07
13

While I broadly agree with Nmath's answer, reading every single line of every single script or digging deep into every single package you apt install (don't forget the transitive deps!) isn't practical for most of us.

What you do need to do is understand what happens (or can happen) when you run a script or a program that modifies your system like apt:

Anything

Anything can happen. If you run it without sudo privs there are certain things it can't do, but it can still do a lot and if you run it with sudo all bets are off.

Files can be permanently deleted. Code from the internet can be downloaded and executed. Directories can be created, configuration files edited. You will likely never be able to reverse an action like that.

So don't try to.

Use virtual machines, clone from known good states before running potentially destructive commands, and be ready to rollback. If you are doing this on a bare-metal server, be prepared to reinstall from scratch.

Note as I said in a comment on the other answer this is not fundamentally different from proprietary OSes: all of the same caveats apply and it's much harder (by design) to just re-install the OS over and over. At least Linux gives you options.

There's also a sliding scale of trust: popular apt packages are installed all day every day by people all over the world and problems are usually quickly discovered. A shell script somebody has on their homepage? Not so much, you may want to check that one a lil more carefully.

3
  • 1
    There is a huge difference between the use of apt install to install packages from the official Ubuntu repositories, and downloading and running a script from some site. First, apt install can be easily reverted by apt remove. The same can't be said for any script. Second, packages installed from the official repositories go through some sort of review and the package integrity is verified by the PGP key. There is no such process for a script.
    – user68186
    Apr 26, 2022 at 16:39
  • 4
    @user68186 I totally agree with most of that, and if I came across as trying to conflate the two in terms of risk I apologize. But even then there's a gradient: how many users add a PPA without thinking twice? All I'm saying is that we all make some tradeoff between practicality and security, and expecting users, even professional IT users, to turn the dial all the way to the 'security' end is impractical. Apr 26, 2022 at 16:55
  • 3
    @user68186 Any post-installation commands executed by apt install might not be easily undone by apt remove. Once you start trusting untrustworthy sources then your system is compromised.
    – doneal24
    Apr 26, 2022 at 23:02
10

It appears that the github that the installer pulled install files from comes with an uninstaller. It appears that the uninstall script doesn't do everything yet (it will possibly still leave some things behind), but the plan seems to be that it will be fixed soon. You can keep an eye out for updates to the uninstall.sh script, and run it when it's ready.

Be aware that the uninstall script may break something else, especially if you have made other changes since installing the software originally. Just like the original script, it is code you may not understand, and you should be cautious when running it. It is a risk you have to decide if you are willing to take.

In general, you should not run software or scripts that you don't understand or trust, especially if you don't know how to uninstall it. Installing all the pieces yourself and keeping notes of what you did and how to undo it, being sure to understand each step, is of course ideal, but if you can't do that then at least be sure the software is one that you trust and can uninstall. Absent that, install it on a system that can easily be restored from a backup or reinstalled in case something goes wrong.

0

If the script follows the official installation guide from the pterodactyl.io website then you could follow the steps to uninstall on pterodox.

https://pterodox.com/guides/uninstall-pterodactyl.html#uninstall-panel

You could always scroll through the script with the 'vim' or 'less' command and compare it to official installation guide.

If you end up using the pterodox guide remember to perform the "optional" mysql part, dropping each user but root from mysql. If the script did not let you make a password or display a generated password for you to remember for mysql/mariadb. Then you might have to completely uninstall those in the same fashion the pterodox guide said to uninstall other dependencies ie. "apt purge"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .