Post on rm -rf rickrolling
This commit is contained in:
parent
41a3f34377
commit
da5308a3aa
7 changed files with 598 additions and 2 deletions
|
@ -0,0 +1,77 @@
|
||||||
|
---
|
||||||
|
layout: post
|
||||||
|
title: "How to rickroll people that try to run \"rm -rf\" on your system"
|
||||||
|
date: 2016-07-28 16:00:00 +0200
|
||||||
|
categories: linux
|
||||||
|
---
|
||||||
|
|
||||||
|
**WARNING: The method showed here could not prevent the actual execution of "rm -rf" if the "UNIX vandal" is clever enough. Proceed at your own risk, and make backups!**
|
||||||
|
|
||||||
|
I like Rick Astley late 80's songs, and you can see them here in my Spotify:
|
||||||
|
|
||||||
|
![dQw4w9WgXcQ](https://dl.dropboxusercontent.com/s/t9vywa4yjotxv0o/Screenshot_20160728_154506.png?dl=0)
|
||||||
|
|
||||||
|
I like rickrolling people myself too, especially if they're trying to delete my entire `/home` directory or, even worse, `/`. Since I learned how to use the `alias` built-in, I wanted a way to prevent that random people tinkering with my laptop (that I may forgot to lock) could delete potentially important stuff, just for fun or boredom.
|
||||||
|
|
||||||
|
The method that I'll show will lock any `rm` command runned in both recursive and force mode, so `rm -rf`, `rm -f -r` and `rm -r --force` are all blocked, even if they are launched by `sudo`. I'm going to alias the rm command in `/etc/profile` `/etc/bash.bashrc` and in `/etc/zsh/zshrc` (I'm a zsh user) so that the rickroll will be possible from all users, even root and the ones with a brand new `bashrc` or `zshrc`. Here is the code I appended to those files:
|
||||||
|
|
||||||
|
{% highlight bash %}
|
||||||
|
alias rm=/bin/rmAlias
|
||||||
|
alias sudo='sudo ' # this enables aliases in sudo, see http://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo
|
||||||
|
{% endhighlight %}
|
||||||
|
|
||||||
|
Since `alias` is not able to control the flags of the aliases (see [here](http://apple.stackexchange.com/questions/50963/how-do-i-add-a-flag-to-an-alias)), we're going to redirect each call of `rm` to `/bin/rmAlias`, that would run the command if it's safe. I didn't use a function because it's a bit tricky to make that work with `sudo`. So, let's see the code I put in `rmAlias`:
|
||||||
|
|
||||||
|
{% highlight bash %}
|
||||||
|
#! /bin/bash
|
||||||
|
# Rickroll whoever tries to desert this system, even root.
|
||||||
|
# To achieve this, set the appropriate aliases even in /etc/profile and similars.
|
||||||
|
|
||||||
|
# Video played when rickrolling
|
||||||
|
ROLLVIDEO=/opt/anti-rm/serious-video.mkv # it's just Never Gonna Give You Up on my system, but be free to customize this!
|
||||||
|
|
||||||
|
rickroll(){
|
||||||
|
echo "Never gonna desert this system..."
|
||||||
|
xdg-open $ROLLVIDEO 2>&1 &
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts ":rf-" opt; do
|
||||||
|
# Prevent '--force' to be detected as -r and -f
|
||||||
|
if [ "$opt" = "-" ]; then
|
||||||
|
OPTIND=$OPTIND+1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "$opt" = "r" ] || [ "$opt" = "f" ]; then
|
||||||
|
if [ "$tmp" = "" ]; then
|
||||||
|
tmp=$opt
|
||||||
|
continue
|
||||||
|
elif [ "$tmp" != "$opt" ]; then
|
||||||
|
rickroll
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for var in "$@"
|
||||||
|
do
|
||||||
|
if [[ "$var" = "--force" && "$tmp" = "r" ]]; then
|
||||||
|
rickroll
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If it's safe, just run rm
|
||||||
|
/bin/rm "$@"
|
||||||
|
exit $?
|
||||||
|
{% endhighlight %}
|
||||||
|
|
||||||
|
It may look messy to a UNIX guy more experienced than me, but it works. The `getopts` built-in sees if both the `-r` and the `-f` flags are used and, if so, it starts `rickroll()`, which opens with `xdg-open` that amazing clip from RickAstleyVEVO. From line 30 and below, the script checks if the `--force` flag is used instead of `-f`.
|
||||||
|
|
||||||
|
Give execute permissions to the script we've just created:
|
||||||
|
|
||||||
|
{% highlight bash %}
|
||||||
|
# chmod +x /bin/rmAlias
|
||||||
|
{% endhighlight %}
|
||||||
|
|
||||||
|
Restart your shell, and enjoy. If you want to test safely, I suggest trying to run `rm -rf` with no folders or one nonexistant, since this script stop even these commands.
|
||||||
|
|
||||||
|
If you want even more security, you can rename this script to `/bin/rm` and move the original one in some other place, getting rid of all the aliases. I prefer the solution above because it's tidier: you haven't to move anything. In fact, this could be just an AUR package...
|
|
@ -0,0 +1 @@
|
||||||
|
<p>WARNING: this</p>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<hr />
|
||||||
|
<p>layout: post
|
||||||
|
title: “How to rickroll people that run “rm -rf” on your system”
|
||||||
|
date: 2016-07-28 18:00:00 +0200
|
||||||
|
categories: linux
|
||||||
|
—-</p>
|
||||||
|
|
||||||
|
<p>WARNING: this</p>
|
|
@ -6,10 +6,86 @@
|
||||||
</description>
|
</description>
|
||||||
<link>http://praticamentetilde.github.io/</link>
|
<link>http://praticamentetilde.github.io/</link>
|
||||||
<atom:link href="http://praticamentetilde.github.io/feed.xml" rel="self" type="application/rss+xml"/>
|
<atom:link href="http://praticamentetilde.github.io/feed.xml" rel="self" type="application/rss+xml"/>
|
||||||
<pubDate>Tue, 12 Jul 2016 20:21:14 +0200</pubDate>
|
<pubDate>Thu, 28 Jul 2016 15:51:30 +0200</pubDate>
|
||||||
<lastBuildDate>Tue, 12 Jul 2016 20:21:14 +0200</lastBuildDate>
|
<lastBuildDate>Thu, 28 Jul 2016 15:51:30 +0200</lastBuildDate>
|
||||||
<generator>Jekyll v3.1.6</generator>
|
<generator>Jekyll v3.1.6</generator>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>How to rickroll people that try to run "rm -rf" on your system</title>
|
||||||
|
<description><p><strong>WARNING: The method showed here could not prevent the actual execution of “rm -rf” if the “UNIX vandal” is clever enough. Proceed at your own risk, and make backups!</strong></p>
|
||||||
|
|
||||||
|
<p>I like Rick Astley late 80’s songs, and you can see them here in my Spotify:</p>
|
||||||
|
|
||||||
|
<p><img src="https://dl.dropboxusercontent.com/s/t9vywa4yjotxv0o/Screenshot_20160728_154506.png?dl=0" alt="dQw4w9WgXcQ" /></p>
|
||||||
|
|
||||||
|
<p>I like rickrolling people myself too, especially if they’re trying to delete my entire <code class="highlighter-rouge">/home</code> directory or, even worse, <code class="highlighter-rouge">/</code>. Since I learned how to use the <code class="highlighter-rouge">alias</code> built-in, I wanted a way to prevent that random people tinkering with my laptop (that I may forgot to lock) could delete potentially important stuff, just for fun or boredom.</p>
|
||||||
|
|
||||||
|
<p>The method that I’ll show will lock any <code class="highlighter-rouge">rm</code> command runned in both recursive and force mode, so <code class="highlighter-rouge">rm -rf</code>, <code class="highlighter-rouge">rm -f -r</code> and <code class="highlighter-rouge">rm -r --force</code> are all blocked, even if they are launched by <code class="highlighter-rouge">sudo</code>. I’m going to alias the rm command in <code class="highlighter-rouge">/etc/profile</code> <code class="highlighter-rouge">/etc/bash.bashrc</code> and in <code class="highlighter-rouge">/etc/zsh/zshrc</code> (I’m a zsh user) so that the rickroll will be possible from all users, even root and the ones with a brand new <code class="highlighter-rouge">bashrc</code> or <code class="highlighter-rouge">zshrc</code>. Here is the code I appended to those files:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">alias </span><span class="nv">rm</span><span class="o">=</span>/bin/rmAlias
|
||||||
|
<span class="nb">alias </span><span class="nv">sudo</span><span class="o">=</span><span class="s1">'sudo '</span> <span class="c"># this enables aliases in sudo, see http://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>Since <code class="highlighter-rouge">alias</code> is not able to control flags of the aliases (see <a href="http://apple.stackexchange.com/questions/50963/how-do-i-add-a-flag-to-an-alias">here</a>), we’re going to redirect each call of <code class="highlighter-rouge">rm</code> to <code class="highlighter-rouge">/bin/rmAlias</code>, that would run the command if it’s safe. I didn’t use a function because it’s a bit tricky to make that work with <code class="highlighter-rouge">sudo</code>. So, let’s see the code I put in <code class="highlighter-rouge">rmAlias</code>:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c">#! /bin/bash</span>
|
||||||
|
<span class="c"># Rickroll whoever tries to desert this system, even root.</span>
|
||||||
|
<span class="c"># To achieve this, set the appropriate aliases even in /etc/profile and similars.</span>
|
||||||
|
|
||||||
|
<span class="c"># Video played when rickrolling</span>
|
||||||
|
<span class="nv">ROLLVIDEO</span><span class="o">=</span>/opt/anti-rm/serious-video.mkv <span class="c"># it's just Never Gonna Give You Up on my system, but be free to customize this!</span>
|
||||||
|
|
||||||
|
rickroll<span class="o">(){</span>
|
||||||
|
<span class="nb">echo</span> <span class="s2">"Never gonna desert this system..."</span>
|
||||||
|
xdg-open <span class="nv">$ROLLVIDEO</span> 2&gt;&amp;1 &amp;
|
||||||
|
<span class="nb">exit </span>0
|
||||||
|
<span class="o">}</span>
|
||||||
|
|
||||||
|
<span class="k">while </span><span class="nb">getopts</span> <span class="s2">":rf-"</span> opt; <span class="k">do</span>
|
||||||
|
<span class="c"># Prevent '--force' to be detected as -r and -f</span>
|
||||||
|
<span class="k">if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"-"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span><span class="nv">OPTIND</span><span class="o">=</span><span class="nv">$OPTIND</span>+1
|
||||||
|
<span class="k">continue
|
||||||
|
fi
|
||||||
|
if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"r"</span> <span class="o">]</span> <span class="o">||</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"f"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">""</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span><span class="nv">tmp</span><span class="o">=</span><span class="nv">$opt</span>
|
||||||
|
<span class="k">continue
|
||||||
|
elif</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> !<span class="o">=</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span>rickroll
|
||||||
|
<span class="k">fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for </span>var <span class="k">in</span> <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
|
||||||
|
<span class="k">do
|
||||||
|
if</span> <span class="o">[[</span> <span class="s2">"</span><span class="nv">$var</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"--force"</span> <span class="o">&amp;&amp;</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"r"</span> <span class="o">]]</span>; <span class="k">then
|
||||||
|
</span>rickroll
|
||||||
|
<span class="k">fi
|
||||||
|
done</span>
|
||||||
|
|
||||||
|
<span class="c"># If it's safe, just run rm</span>
|
||||||
|
/bin/rm <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
|
||||||
|
<span class="nb">exit</span> <span class="nv">$?</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>It may look messy to a UNIX guy more experienced than me, but it works. The <code class="highlighter-rouge">getopts</code> built-in sees if both the <code class="highlighter-rouge">-r</code> and the <code class="highlighter-rouge">-f</code> flags are used and, if so, it starts <code class="highlighter-rouge">rickroll()</code>, which opens with <code class="highlighter-rouge">xdg-open</code> that amazing clip from RickAstleyVEVO. From line 30 and below, the script checks if the <code class="highlighter-rouge">--force</code> flag is used instead of <code class="highlighter-rouge">-f</code>.</p>
|
||||||
|
|
||||||
|
<p>Give execute permissions to the script we’ve just created:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># chmod +x /bin/rmAlias</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>Restart your shell, and enjoy. If you want to test safely, I suggest trying to run <code class="highlighter-rouge">rm -rf</code> with no folders or one nonexistant, since this script stop even these commands.</p>
|
||||||
|
|
||||||
|
<p>If you want even more security, you can rename this script to <code class="highlighter-rouge">/bin/rm</code> and move the original one in some other place, getting rid of all the aliases. I prefer the solution above because it’s tidier: you haven’t to move anything. In fact, this could be just an AUR package…</p>
|
||||||
|
</description>
|
||||||
|
<pubDate>Thu, 28 Jul 2016 16:00:00 +0200</pubDate>
|
||||||
|
<link>http://praticamentetilde.github.io/linux/2016/07/28/how-to-rickroll-people-launching-rm-rf-on-your-system.html</link>
|
||||||
|
<guid isPermaLink="true">http://praticamentetilde.github.io/linux/2016/07/28/how-to-rickroll-people-launching-rm-rf-on-your-system.html</guid>
|
||||||
|
|
||||||
|
|
||||||
|
<category>linux</category>
|
||||||
|
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Installing Gentoo on a Lenovo ThinkPad X60s</title>
|
<title>Installing Gentoo on a Lenovo ThinkPad X60s</title>
|
||||||
<description><p>My only laptop is a <a href="http://www.thinkwiki.org/wiki/Category:X60s">IBM/Lenovo ThinkPad X60s</a>, a top line “ultrabook” from 2006 that features:</p>
|
<description><p>My only laptop is a <a href="http://www.thinkwiki.org/wiki/Category:X60s">IBM/Lenovo ThinkPad X60s</a>, a top line “ultrabook” from 2006 that features:</p>
|
||||||
|
|
|
@ -124,6 +124,14 @@
|
||||||
|
|
||||||
<ul class="post-list">
|
<ul class="post-list">
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<span class="post-meta">Jul 28, 2016</span>
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
<a class="post-link" href="/linux/2016/07/28/how-to-rickroll-people-launching-rm-rf-on-your-system.html">How to rickroll people that try to run "rm -rf" on your system</a>
|
||||||
|
</h2>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<span class="post-meta">Jul 12, 2016</span>
|
<span class="post-meta">Jul 12, 2016</span>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,213 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<title>How to rickroll people that try to run "rm -rf" on your system</title>
|
||||||
|
<meta name="description" content="WARNING: The method showed here could not prevent the actual execution of “rm -rf” if the “UNIX vandal” is clever enough. Proceed at your own risk, and make ...">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/css/main.css">
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Hammersmith+One' rel='stylesheet' type='text/css'>
|
||||||
|
<link rel="canonical" href="http://praticamentetilde.github.io/linux/2016/07/12/how-to-rickroll-people-launching-rm-rf-on-your-system.html">
|
||||||
|
<link rel="alternate" type="application/rss+xml" title="Ramblings of an archer archer" href="http://praticamentetilde.github.io/feed.xml">
|
||||||
|
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
|
||||||
|
<script src="https://rawgit.com/snaptortoise/konami-js/master/konami.js"></script>
|
||||||
|
<!-- Favicon -->
|
||||||
|
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||||
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
<meta name="msapplication-TileColor" content="#ffffff">
|
||||||
|
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
|
||||||
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header class="site-header">
|
||||||
|
|
||||||
|
<div class="wrapper header">
|
||||||
|
|
||||||
|
<img class="site-logo" src="/android-icon-192x192.png" alt="MALUSA"/>
|
||||||
|
<a class="site-title" href="/">Ramblings of an archer archer</a>
|
||||||
|
|
||||||
|
<nav class="site-nav">
|
||||||
|
<a href="#" class="menu-icon">
|
||||||
|
<svg viewBox="0 0 18 15">
|
||||||
|
<path fill="#424242" d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.031C17.335,0,18,0.665,18,1.484L18,1.484z"/>
|
||||||
|
<path fill="#424242" d="M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0c0-0.82,0.665-1.484,1.484-1.484 h15.031C17.335,6.031,18,6.696,18,7.516L18,7.516z"/>
|
||||||
|
<path fill="#424242" d="M18,13.516C18,14.335,17.335,15,16.516,15H1.484C0.665,15,0,14.335,0,13.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.031C17.335,12.031,18,12.696,18,13.516L18,13.516z"/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="trigger">
|
||||||
|
|
||||||
|
|
||||||
|
<a class="page-link" href="/about/">About</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="page-content">
|
||||||
|
<div class="wrapper">
|
||||||
|
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
|
||||||
|
|
||||||
|
<header class="post-header">
|
||||||
|
<h1 class="post-title" itemprop="name headline">How to rickroll people that try to run "rm -rf" on your system</h1>
|
||||||
|
<p class="post-meta"><time datetime="2016-07-12T13:00:00+02:00" itemprop="datePublished">Jul 12, 2016</time></p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="post-content" itemprop="articleBody">
|
||||||
|
<p><strong>WARNING: The method showed here could not prevent the actual execution of “rm -rf” if the “UNIX vandal” is clever enough. Proceed at your own risk, and make backups!</strong></p>
|
||||||
|
|
||||||
|
<p>I like Rick Astley late 80’s songs, and you can see them here in my Spotify:</p>
|
||||||
|
|
||||||
|
<p><img src="https://dl.dropboxusercontent.com/s/t9vywa4yjotxv0o/Screenshot_20160728_154506.png?dl=0" alt="dQw4w9WgXcQ" /></p>
|
||||||
|
|
||||||
|
<p>I like rickrolling people myself too, especially if they’re trying to delete my entire <code class="highlighter-rouge">/home</code> directory or, even worse, <code class="highlighter-rouge">/</code>. Since I learned how to use the <code class="highlighter-rouge">alias</code> built-in, I wanted a way to prevent that random people tinkering with my laptop (that I may forgot to lock) could delete potentially important stuff, just for fun or boredom.</p>
|
||||||
|
|
||||||
|
<p>The method that I’ll show will lock any <code class="highlighter-rouge">rm</code> command runned in both recursive and force mode, so <code class="highlighter-rouge">rm -rf</code>, <code class="highlighter-rouge">rm -f -r</code> and <code class="highlighter-rouge">rm -r --force</code> are all blocked, even if they are launched by <code class="highlighter-rouge">sudo</code>. I’m going to alias the rm command in <code class="highlighter-rouge">/etc/profile</code> <code class="highlighter-rouge">/etc/bash.bashrc</code> and in <code class="highlighter-rouge">/etc/zsh/zshrc</code> (I’m a zsh user) so that the rickroll will be possible from all users, even root and the ones with a brand new <code class="highlighter-rouge">bashrc</code> or <code class="highlighter-rouge">zshrc</code>. Here is the code I appended to those files:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">alias </span><span class="nv">rm</span><span class="o">=</span>/bin/rmAlias
|
||||||
|
<span class="nb">alias </span><span class="nv">sudo</span><span class="o">=</span><span class="s1">'sudo '</span> <span class="c"># this enables aliases in sudo, see http://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>Since <code class="highlighter-rouge">alias</code> is not able to control flags of the aliases (see <a href="http://apple.stackexchange.com/questions/50963/how-do-i-add-a-flag-to-an-alias">here</a>), we’re going to redirect each call of <code class="highlighter-rouge">rm</code> to <code class="highlighter-rouge">/bin/rmAlias</code>, that would run the command if it’s safe. I didn’t use a function because it’s a bit tricky to make that work with <code class="highlighter-rouge">sudo</code>. So, let’s see the code I put in <code class="highlighter-rouge">rmAlias</code>:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c">#! /bin/bash</span>
|
||||||
|
<span class="c"># Rickroll whoever tries to desert this system, even root.</span>
|
||||||
|
<span class="c"># To achieve this, set the appropriate aliases even in /etc/profile and similars.</span>
|
||||||
|
|
||||||
|
<span class="c"># Video played when rickrolling</span>
|
||||||
|
<span class="nv">ROLLVIDEO</span><span class="o">=</span>/opt/anti-rm/serious-video.mkv <span class="c"># it's just Never Gonna Give You Up on my system, but be free to customize this!</span>
|
||||||
|
|
||||||
|
rickroll<span class="o">(){</span>
|
||||||
|
<span class="nb">echo</span> <span class="s2">"Never gonna desert this system..."</span>
|
||||||
|
xdg-open <span class="nv">$ROLLVIDEO</span> 2>&1 &
|
||||||
|
<span class="nb">exit </span>0
|
||||||
|
<span class="o">}</span>
|
||||||
|
|
||||||
|
<span class="k">while </span><span class="nb">getopts</span> <span class="s2">":rf-"</span> opt; <span class="k">do</span>
|
||||||
|
<span class="c"># Prevent '--force' to be detected as -r and -f</span>
|
||||||
|
<span class="k">if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"-"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span><span class="nv">OPTIND</span><span class="o">=</span><span class="nv">$OPTIND</span>+1
|
||||||
|
<span class="k">continue
|
||||||
|
fi
|
||||||
|
if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"r"</span> <span class="o">]</span> <span class="o">||</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"f"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">""</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span><span class="nv">tmp</span><span class="o">=</span><span class="nv">$opt</span>
|
||||||
|
<span class="k">continue
|
||||||
|
elif</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> !<span class="o">=</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span>rickroll
|
||||||
|
<span class="k">fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for </span>var <span class="k">in</span> <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
|
||||||
|
<span class="k">do
|
||||||
|
if</span> <span class="o">[[</span> <span class="s2">"</span><span class="nv">$var</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"--force"</span> <span class="o">&&</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"r"</span> <span class="o">]]</span>; <span class="k">then
|
||||||
|
</span>rickroll
|
||||||
|
<span class="k">fi
|
||||||
|
done</span>
|
||||||
|
|
||||||
|
<span class="c"># If it's safe, just run rm</span>
|
||||||
|
/bin/rm <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
|
||||||
|
<span class="nb">exit</span> <span class="nv">$?</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>It may look messy to a UNIX guy more experienced than me, but it works. The <code class="highlighter-rouge">getopts</code> built-in sees if both the <code class="highlighter-rouge">-r</code> and the <code class="highlighter-rouge">-f</code> flags are used and, if so, it starts <code class="highlighter-rouge">rickroll()</code>, which opens with <code class="highlighter-rouge">xdg-open</code> that amazing clip from RickAstleyVEVO. From line 30 and below, the script checks if the <code class="highlighter-rouge">--force</code> flag is used instead of <code class="highlighter-rouge">-f</code>.</p>
|
||||||
|
|
||||||
|
<p>Give execute permissions to the script we’ve just created:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># chmod +x /bin/rmAlias</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>Restart your shell, and enjoy. If you want to test safely, I suggest trying to run <code class="highlighter-rouge">rm -rf</code> with no folders or one nonexistant, since this script stop even these commands.</p>
|
||||||
|
|
||||||
|
<p>If you want even more security, you can rename this script to <code class="highlighter-rouge">/bin/rm</code> and move the original one in some other place, getting rid of all the aliases. I prefer the solution above because it’s tidier: you haven’t to move anything. In fact, this could be just an AUR package…</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
<div id="disqus_thread" style="background: #212121"></div>
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
|
||||||
|
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
var disqus_config = function () {
|
||||||
|
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
|
||||||
|
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
(function() { // DON'T EDIT BELOW THIS LINE
|
||||||
|
var d = document, s = d.createElement('script');
|
||||||
|
|
||||||
|
s.src = '//ramblingsofanarcherarcher.disqus.com/embed.js';
|
||||||
|
|
||||||
|
s.setAttribute('data-timestamp', +new Date());
|
||||||
|
(d.head || d.body).appendChild(s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer class="site-footer">
|
||||||
|
|
||||||
|
<div class="wrapper">
|
||||||
|
|
||||||
|
<h2 class="footer-heading">Ramblings of an archer archer</h2>
|
||||||
|
|
||||||
|
<div class="footer-col-wrapper">
|
||||||
|
<div class="footer-col footer-col-1">
|
||||||
|
<ul class="contact-list">
|
||||||
|
My <a href="http://www.burarco.it/">Archery club</a>.
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer-col footer-col-2">
|
||||||
|
<ul class="social-media-list">
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/praticamentetilde"><span class="icon icon--github"><svg viewBox="0 0 16 16"><path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/></svg>
|
||||||
|
</span><span class="username">praticamentetilde</span></a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer-col footer-col-3">
|
||||||
|
<p>Things which an Arch Linux user that also owns an recurve bow can write.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,213 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<title>How to rickroll people that try to run "rm -rf" on your system</title>
|
||||||
|
<meta name="description" content="WARNING: The method showed here could not prevent the actual execution of “rm -rf” if the “UNIX vandal” is clever enough. Proceed at your own risk, and make ...">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/css/main.css">
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Hammersmith+One' rel='stylesheet' type='text/css'>
|
||||||
|
<link rel="canonical" href="http://praticamentetilde.github.io/linux/2016/07/28/how-to-rickroll-people-launching-rm-rf-on-your-system.html">
|
||||||
|
<link rel="alternate" type="application/rss+xml" title="Ramblings of an archer archer" href="http://praticamentetilde.github.io/feed.xml">
|
||||||
|
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
|
||||||
|
<script src="https://rawgit.com/snaptortoise/konami-js/master/konami.js"></script>
|
||||||
|
<!-- Favicon -->
|
||||||
|
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||||
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
<meta name="msapplication-TileColor" content="#ffffff">
|
||||||
|
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
|
||||||
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header class="site-header">
|
||||||
|
|
||||||
|
<div class="wrapper header">
|
||||||
|
|
||||||
|
<img class="site-logo" src="/android-icon-192x192.png" alt="MALUSA"/>
|
||||||
|
<a class="site-title" href="/">Ramblings of an archer archer</a>
|
||||||
|
|
||||||
|
<nav class="site-nav">
|
||||||
|
<a href="#" class="menu-icon">
|
||||||
|
<svg viewBox="0 0 18 15">
|
||||||
|
<path fill="#424242" d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.031C17.335,0,18,0.665,18,1.484L18,1.484z"/>
|
||||||
|
<path fill="#424242" d="M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0c0-0.82,0.665-1.484,1.484-1.484 h15.031C17.335,6.031,18,6.696,18,7.516L18,7.516z"/>
|
||||||
|
<path fill="#424242" d="M18,13.516C18,14.335,17.335,15,16.516,15H1.484C0.665,15,0,14.335,0,13.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.031C17.335,12.031,18,12.696,18,13.516L18,13.516z"/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="trigger">
|
||||||
|
|
||||||
|
|
||||||
|
<a class="page-link" href="/about/">About</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="page-content">
|
||||||
|
<div class="wrapper">
|
||||||
|
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
|
||||||
|
|
||||||
|
<header class="post-header">
|
||||||
|
<h1 class="post-title" itemprop="name headline">How to rickroll people that try to run "rm -rf" on your system</h1>
|
||||||
|
<p class="post-meta"><time datetime="2016-07-28T16:00:00+02:00" itemprop="datePublished">Jul 28, 2016</time></p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="post-content" itemprop="articleBody">
|
||||||
|
<p><strong>WARNING: The method showed here could not prevent the actual execution of “rm -rf” if the “UNIX vandal” is clever enough. Proceed at your own risk, and make backups!</strong></p>
|
||||||
|
|
||||||
|
<p>I like Rick Astley late 80’s songs, and you can see them here in my Spotify:</p>
|
||||||
|
|
||||||
|
<p><img src="https://dl.dropboxusercontent.com/s/t9vywa4yjotxv0o/Screenshot_20160728_154506.png?dl=0" alt="dQw4w9WgXcQ" /></p>
|
||||||
|
|
||||||
|
<p>I like rickrolling people myself too, especially if they’re trying to delete my entire <code class="highlighter-rouge">/home</code> directory or, even worse, <code class="highlighter-rouge">/</code>. Since I learned how to use the <code class="highlighter-rouge">alias</code> built-in, I wanted a way to prevent that random people tinkering with my laptop (that I may forgot to lock) could delete potentially important stuff, just for fun or boredom.</p>
|
||||||
|
|
||||||
|
<p>The method that I’ll show will lock any <code class="highlighter-rouge">rm</code> command runned in both recursive and force mode, so <code class="highlighter-rouge">rm -rf</code>, <code class="highlighter-rouge">rm -f -r</code> and <code class="highlighter-rouge">rm -r --force</code> are all blocked, even if they are launched by <code class="highlighter-rouge">sudo</code>. I’m going to alias the rm command in <code class="highlighter-rouge">/etc/profile</code> <code class="highlighter-rouge">/etc/bash.bashrc</code> and in <code class="highlighter-rouge">/etc/zsh/zshrc</code> (I’m a zsh user) so that the rickroll will be possible from all users, even root and the ones with a brand new <code class="highlighter-rouge">bashrc</code> or <code class="highlighter-rouge">zshrc</code>. Here is the code I appended to those files:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">alias </span><span class="nv">rm</span><span class="o">=</span>/bin/rmAlias
|
||||||
|
<span class="nb">alias </span><span class="nv">sudo</span><span class="o">=</span><span class="s1">'sudo '</span> <span class="c"># this enables aliases in sudo, see http://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>Since <code class="highlighter-rouge">alias</code> is not able to control flags of the aliases (see <a href="http://apple.stackexchange.com/questions/50963/how-do-i-add-a-flag-to-an-alias">here</a>), we’re going to redirect each call of <code class="highlighter-rouge">rm</code> to <code class="highlighter-rouge">/bin/rmAlias</code>, that would run the command if it’s safe. I didn’t use a function because it’s a bit tricky to make that work with <code class="highlighter-rouge">sudo</code>. So, let’s see the code I put in <code class="highlighter-rouge">rmAlias</code>:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c">#! /bin/bash</span>
|
||||||
|
<span class="c"># Rickroll whoever tries to desert this system, even root.</span>
|
||||||
|
<span class="c"># To achieve this, set the appropriate aliases even in /etc/profile and similars.</span>
|
||||||
|
|
||||||
|
<span class="c"># Video played when rickrolling</span>
|
||||||
|
<span class="nv">ROLLVIDEO</span><span class="o">=</span>/opt/anti-rm/serious-video.mkv <span class="c"># it's just Never Gonna Give You Up on my system, but be free to customize this!</span>
|
||||||
|
|
||||||
|
rickroll<span class="o">(){</span>
|
||||||
|
<span class="nb">echo</span> <span class="s2">"Never gonna desert this system..."</span>
|
||||||
|
xdg-open <span class="nv">$ROLLVIDEO</span> 2>&1 &
|
||||||
|
<span class="nb">exit </span>0
|
||||||
|
<span class="o">}</span>
|
||||||
|
|
||||||
|
<span class="k">while </span><span class="nb">getopts</span> <span class="s2">":rf-"</span> opt; <span class="k">do</span>
|
||||||
|
<span class="c"># Prevent '--force' to be detected as -r and -f</span>
|
||||||
|
<span class="k">if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"-"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span><span class="nv">OPTIND</span><span class="o">=</span><span class="nv">$OPTIND</span>+1
|
||||||
|
<span class="k">continue
|
||||||
|
fi
|
||||||
|
if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"r"</span> <span class="o">]</span> <span class="o">||</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"f"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">""</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span><span class="nv">tmp</span><span class="o">=</span><span class="nv">$opt</span>
|
||||||
|
<span class="k">continue
|
||||||
|
elif</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> !<span class="o">=</span> <span class="s2">"</span><span class="nv">$opt</span><span class="s2">"</span> <span class="o">]</span>; <span class="k">then
|
||||||
|
</span>rickroll
|
||||||
|
<span class="k">fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for </span>var <span class="k">in</span> <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
|
||||||
|
<span class="k">do
|
||||||
|
if</span> <span class="o">[[</span> <span class="s2">"</span><span class="nv">$var</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"--force"</span> <span class="o">&&</span> <span class="s2">"</span><span class="nv">$tmp</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"r"</span> <span class="o">]]</span>; <span class="k">then
|
||||||
|
</span>rickroll
|
||||||
|
<span class="k">fi
|
||||||
|
done</span>
|
||||||
|
|
||||||
|
<span class="c"># If it's safe, just run rm</span>
|
||||||
|
/bin/rm <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
|
||||||
|
<span class="nb">exit</span> <span class="nv">$?</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>It may look messy to a UNIX guy more experienced than me, but it works. The <code class="highlighter-rouge">getopts</code> built-in sees if both the <code class="highlighter-rouge">-r</code> and the <code class="highlighter-rouge">-f</code> flags are used and, if so, it starts <code class="highlighter-rouge">rickroll()</code>, which opens with <code class="highlighter-rouge">xdg-open</code> that amazing clip from RickAstleyVEVO. From line 30 and below, the script checks if the <code class="highlighter-rouge">--force</code> flag is used instead of <code class="highlighter-rouge">-f</code>.</p>
|
||||||
|
|
||||||
|
<p>Give execute permissions to the script we’ve just created:</p>
|
||||||
|
|
||||||
|
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c"># chmod +x /bin/rmAlias</span></code></pre></figure>
|
||||||
|
|
||||||
|
<p>Restart your shell, and enjoy. If you want to test safely, I suggest trying to run <code class="highlighter-rouge">rm -rf</code> with no folders or one nonexistant, since this script stop even these commands.</p>
|
||||||
|
|
||||||
|
<p>If you want even more security, you can rename this script to <code class="highlighter-rouge">/bin/rm</code> and move the original one in some other place, getting rid of all the aliases. I prefer the solution above because it’s tidier: you haven’t to move anything. In fact, this could be just an AUR package…</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
<div id="disqus_thread" style="background: #212121"></div>
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
|
||||||
|
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
var disqus_config = function () {
|
||||||
|
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
|
||||||
|
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
(function() { // DON'T EDIT BELOW THIS LINE
|
||||||
|
var d = document, s = d.createElement('script');
|
||||||
|
|
||||||
|
s.src = '//ramblingsofanarcherarcher.disqus.com/embed.js';
|
||||||
|
|
||||||
|
s.setAttribute('data-timestamp', +new Date());
|
||||||
|
(d.head || d.body).appendChild(s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer class="site-footer">
|
||||||
|
|
||||||
|
<div class="wrapper">
|
||||||
|
|
||||||
|
<h2 class="footer-heading">Ramblings of an archer archer</h2>
|
||||||
|
|
||||||
|
<div class="footer-col-wrapper">
|
||||||
|
<div class="footer-col footer-col-1">
|
||||||
|
<ul class="contact-list">
|
||||||
|
My <a href="http://www.burarco.it/">Archery club</a>.
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer-col footer-col-2">
|
||||||
|
<ul class="social-media-list">
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/praticamentetilde"><span class="icon icon--github"><svg viewBox="0 0 16 16"><path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/></svg>
|
||||||
|
</span><span class="username">praticamentetilde</span></a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer-col footer-col-3">
|
||||||
|
<p>Things which an Arch Linux user that also owns an recurve bow can write.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue