snipt

Ctrl+h for KB shortcuts

Bash

Add/Remove Apache 2 from Startup

1
2
3
$ sudo update-rc.d apache2 defaults

$ sudo update-rc.d -f apache2 remove
https://snipt.net/embed/476a2fabde8dd72eae892a0975de0611/
/raw/476a2fabde8dd72eae892a0975de0611/
476a2fabde8dd72eae892a0975de0611
bash
Bash
3
2019-07-16T21:05:44
True
False
False
Jul 30, 2013 at 11:02 PM
/api/public/snipt/70703/
addremove-apache-2-from-startup
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ sudo update-rc.d apache2 defaults </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>$ sudo update-rc.d -f apache2 remove </span></pre></div> </td></tr></table>
apache2, bash, ubuntu

Bash

View the last <n> commands

history <n>
https://snipt.net/embed/3c2d069747d547f7ec731c09fd358cad/
/raw/3c2d069747d547f7ec731c09fd358cad/
3c2d069747d547f7ec731c09fd358cad
bash
Bash
1
2019-07-05T18:16:00
True
False
False
/api/public/snipt/50508/
view-the-last-n-commands
<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></span><span id="L-1"><a name="L-1"></a><span class="nb">history</span> &lt;n&gt; </span></pre></div> </td></tr></table>
bash, history

Bash

Execute a specific command from history

!<history_id>
https://snipt.net/embed/30ea22287d3ab67d114dafb00da5ae42/
/raw/30ea22287d3ab67d114dafb00da5ae42/
30ea22287d3ab67d114dafb00da5ae42
bash
Bash
1
2019-07-15T17:19:32
True
False
False
/api/public/snipt/50452/
execute-a-specific-command-from-history
<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></span><span id="L-1"><a name="L-1"></a>!&lt;history_id&gt; </span></pre></div> </td></tr></table>
bash, history

Bash

Change the owner of a symbolic link

$ chown -h <user>:<group> <symbolic_link>
https://snipt.net/embed/ffabb099faa6e102a803e2a42673c254/
/raw/ffabb099faa6e102a803e2a42673c254/
ffabb099faa6e102a803e2a42673c254
bash
Bash
1
2019-07-06T07:05:51
True
False
False
Sep 13, 2012 at 04:15 AM
/api/public/snipt/47120/
change-the-owner-of-a-symbolic-link
<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></span><span id="L-1"><a name="L-1"></a>$ chown -h &lt;user&gt;:&lt;group&gt; &lt;symbolic_link&gt; </span></pre></div> </td></tr></table>
bash

Bash

Kill a Process by Name

$ pkill <process_name>
https://snipt.net/embed/77f3076d49053195ef1a19620c0ff111/
/raw/77f3076d49053195ef1a19620c0ff111/
77f3076d49053195ef1a19620c0ff111
bash
Bash
1
2019-06-16T00:36:17
True
False
False
Jul 22, 2012 at 12:50 PM
/api/public/snipt/44291/
kill-a-process-by-name
<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></span><span id="L-1"><a name="L-1"></a>$ pkill &lt;process_name&gt; </span></pre></div> </td></tr></table>
bash, linux

Bash

Empty the content of a file

$ cat /dev/null > <file_name>
https://snipt.net/embed/cea489f186066b942837703409c069c9/
/raw/cea489f186066b942837703409c069c9/
cea489f186066b942837703409c069c9
bash
Bash
1
2019-07-03T18:39:46
True
False
False
/api/public/snipt/36665/
empty-the-content-of-a-file
<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></span><span id="L-1"><a name="L-1"></a>$ cat /dev/null &gt; &lt;file_name&gt; </span></pre></div> </td></tr></table>
bash

Bash

Search files by name

$ find . -iname <file_name>
https://snipt.net/embed/606510601c1d25459593d3cd8596c1dc/
/raw/606510601c1d25459593d3cd8596c1dc/
606510601c1d25459593d3cd8596c1dc
bash
Bash
1
2019-06-30T07:41:00
True
False
False
/api/public/snipt/35794/
search-files-by-name
<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></span><span id="L-1"><a name="L-1"></a>$ find . -iname &lt;file_name&gt; </span></pre></div> </td></tr></table>
bash, find

Bash

Create a dummy file

1
2
3
# Create a 1GB dummy file named 'test.bin'
# Reference: http://www.linuxforums.org/forum/suse-linux/58658-command-generate-large-dummy-files.html
$ time dd if=/dev/zero of=test.bin bs=1000000000 count=1
https://snipt.net/embed/a40f1cb9eca68b12e3a4c3327b1101f1/
/raw/a40f1cb9eca68b12e3a4c3327b1101f1/
a40f1cb9eca68b12e3a4c3327b1101f1
bash
Bash
3
2019-07-11T19:01:13
True
False
False
/api/public/snipt/29736/
create-a-dummy-file
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># Create a 1GB dummy file named &#39;test.bin&#39;</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># Reference: http://www.linuxforums.org/forum/suse-linux/58658-command-generate-large-dummy-files.html</span> </span><span id="L-3"><a name="L-3"></a>$ <span class="nb">time</span> dd <span class="k">if</span><span class="o">=</span>/dev/zero <span class="nv">of</span><span class="o">=</span>test.bin <span class="nv">bs</span><span class="o">=</span><span class="m">1000000000</span> <span class="nv">count</span><span class="o">=</span>1 </span></pre></div> </td></tr></table>
bash

Bash

Install from an RPM file

$ rpm -iv <rpm_file>
https://snipt.net/embed/a71a014acd1e993157c58213d0af02ba/
/raw/a71a014acd1e993157c58213d0af02ba/
a71a014acd1e993157c58213d0af02ba
bash
Bash
1
2019-07-07T15:28:57
True
False
False
/api/public/snipt/26663/
install-from-an-rpm-file
<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></span><span id="L-1"><a name="L-1"></a>$ rpm -iv &lt;rpm_file&gt; </span></pre></div> </td></tr></table>
bash, linux, rpm

Bash

Show the current Linux distro

$ cat /etc/issue
https://snipt.net/embed/a169ef1c8f6334003f7fcb5bbb15777a/
/raw/a169ef1c8f6334003f7fcb5bbb15777a/
a169ef1c8f6334003f7fcb5bbb15777a
bash
Bash
1
2019-07-02T21:41:34
True
False
False
/api/public/snipt/26662/
show-the-current-linux-distro
<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></span><span id="L-1"><a name="L-1"></a>$ cat /etc/issue </span></pre></div> </td></tr></table>
bash, linux