snipt

Ctrl+h for KB shortcuts

Text only

Add simple user to sudoers in Debian

echo 'my_user ALL=(ALL:ALL) ALL' >> /etc/sudoers
https://snipt.net/embed/f83ecfd16dc620045692997d4420c372/
https://snipt.net/raw/f83ecfd16dc620045692997d4420c372/
f83ecfd16dc620045692997d4420c372
text
Text only
3
2016-09-26T11:25:58
True
False
False
/api/public/snipt/107957/
give-administrator-privileges-to-simple-user-in-debian
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>echo &#39;my_user ALL=(ALL:ALL) ALL&#39; &gt;&gt; /etc/sudoers </span></pre></div> </td></tr></table>
Debian, Linux, administrator, root, sudo, sudoers

Smarty

CMSMS | mettere in una variabile il path root del sito

//non prende il parametro assign quindi è necessario usare capture
{capture assign='root_url'}{root_url}{/capture}
https://snipt.net/embed/642f890bcd879d56a681dc9800d7d751/
https://snipt.net/raw/642f890bcd879d56a681dc9800d7d751/
642f890bcd879d56a681dc9800d7d751
smarty
Smarty
2
2016-09-28T09:23:47
True
False
False
/api/public/snipt/30913/
cmsms-vettere-in-una-variabile-il-path-root-del-sito
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="x">//non prende il parametro assign quindi è necessario usare capture</span> </span><span id="L-2"><a name="L-2"></a><span class="cp">{</span><span class="nf">capture</span> <span class="na">assign</span><span class="o">=</span><span class="s1">&#39;root_url&#39;</span><span class="cp">}{</span><span class="nf">root_url</span><span class="cp">}{</span><span class="nf">/capture</span><span class="cp">}</span><span class="x"></span> </span></pre></div> </td></tr></table>
cmsms, root, smarty

Bash

get a list of dns root servers

dnsip `dnsqr ns . | awk '/answer:/ { print $5 ; }' | sort`
https://snipt.net/embed/e2fb96c47417702fc1a36d2821d767d5/
https://snipt.net/raw/e2fb96c47417702fc1a36d2821d767d5/
e2fb96c47417702fc1a36d2821d767d5
bash
Bash
1
2016-09-26T23:49:27
True
False
False
/api/public/snipt/27981/
get-a-list-of-dns-root-servers
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>dnsip <span class="sb">`</span>dnsqr ns . <span class="p">|</span> awk <span class="s1">&#39;/answer:/ { print $5 ; }&#39;</span> <span class="p">|</span> sort<span class="sb">`</span> </span></pre></div> </td></tr></table>
djbdns, dns, root

Text only

How to write a read-only file in vi if you have sudo root

:w !sudo tee %
https://snipt.net/embed/cf4dcae6a97a0d5ea71ea7e97da96353/
https://snipt.net/raw/cf4dcae6a97a0d5ea71ea7e97da96353/
cf4dcae6a97a0d5ea71ea7e97da96353
text
Text only
1
2016-09-21T12:26:49
True
False
False
/api/public/snipt/20057/
how-to-write-a-read-only-file-in-vi-if-you-have-sudo-root
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>:w !sudo tee % </span></pre></div> </td></tr></table>
root, sudo, vi, vim

PHP

php get root dir

$docRoot = getenv("DOCUMENT_ROOT");
include $docRoot."/includes/config.php";
https://snipt.net/embed/caec6d75bc9a7c043a4949279ae769d7/
https://snipt.net/raw/caec6d75bc9a7c043a4949279ae769d7/
caec6d75bc9a7c043a4949279ae769d7
php
PHP
2
2016-09-27T08:09:55
True
False
False
/api/public/snipt/17431/
php-get-root-dir
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="x">$docRoot = getenv(&quot;DOCUMENT_ROOT&quot;);</span> </span><span id="L-2"><a name="L-2"></a><span class="x">include $docRoot.&quot;/includes/config.php&quot;;</span> </span></pre></div> </td></tr></table>
php, root, server

Bash

root password disabling

1
2
3
4
5
# in order to disable root without expiring the account
$ sudo passwd -l root
$ sudo chage -e -l root
# to re-enable root
$ sudo passwd -u root
https://snipt.net/embed/df322472ea1e24b141fef32484ebb79f/
https://snipt.net/raw/df322472ea1e24b141fef32484ebb79f/
df322472ea1e24b141fef32484ebb79f
bash
Bash
5
2016-09-22T13:16:53
True
False
False
/api/public/snipt/8579/
root-password-disabling
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># in order to disable root without expiring the account</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">$ </span>sudo passwd -l root </span><span id="L-3"><a name="L-3"></a><span class="nv">$ </span>sudo chage -e -l root </span><span id="L-4"><a name="L-4"></a><span class="c"># to re-enable root</span> </span><span id="L-5"><a name="L-5"></a><span class="nv">$ </span>sudo passwd -u root </span></pre></div> </td></tr></table>
root, security, sysadmin

Bash

Find all files in /etc owned by root that have been modified within the last day

find /etc -user root -mtime -1 
https://snipt.net/embed/e599976da5976840dabdeabac115a3ad/
https://snipt.net/raw/e599976da5976840dabdeabac115a3ad/
e599976da5976840dabdeabac115a3ad
bash
Bash
1
2016-09-28T13:10:23
True
False
False
/api/public/snipt/6654/
find-all-files-in-etc-owned-by-root-that-have-been-modified-within-the-last-day-1
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>find /etc -user root -mtime -1 </span></pre></div> </td></tr></table>
root
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.