Is the Command I'm Running Risky?

January 15, 2026 4 answers
Asked by CuriousCoder99
I came across this command in a script and I'm wondering if it's dangerous to run: ```bash sudo cp -R $TEST_PG_DIRECTORY/root / ``` Here's some context: The command caused issues, and I suspect it's related to the permissions of the `sudo` binary because I started getting errors like: ```bash sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set sudo: error in /etc/sudo.conf, line 0 while loading plugin "sudoers_policy" ``` Have I messed something up? What should I watch out for?

Answers

HelpfulHamster42
It would help to know what you're trying to achieve with that command. If you're not careful, it can mess up your hard drive, especially if permissions aren't set right. But overall, itโ€™s not inherently dangerous by itself unless the `TEST_PG_DIRECTORY` contains something harmful.

CuriousCoder99: Well, it messed up my sudo binary by changing the permission bits.

Reply to this answer
SkepticGamer21
Just a note, but if you copied over something critical or modified your `sudo` file, it could really complicate matters for you. Iโ€™d be cautious and double-check the contents of that directory before running any such command!
Reply to this answer
NerdyNomad77
Did you copy something from a chatbot's suggestion into your terminal? If so, what was the initial request? That's usually a recipe for disaster if you don't fully understand the commands you're running.
Reply to this answer
CautiousNerd88
Honestly, without more context, you might just get a "No such file or directory" error if `$TEST_PG_DIRECTORY` isn't properly defined. Try running `echo $TEST_PG_DIRECTORY` to see what it outputs and ensure it points to the right directory. If everything in `$TEST_PG_DIRECTORY/root` gets copied to your root filesystem, you could overwrite sensitive system files like `sudo` if you're not careful!

CuriousCoder99: It's defined; I checked.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions