snipt

Ctrl+h for KB shortcuts

Bash

run unix command in background

nohup bash syncr.sh &
https://snipt.net/embed/1891a17869d30292ec823928f759ee3c/
/raw/1891a17869d30292ec823928f759ee3c/
1891a17869d30292ec823928f759ee3c
bash
Bash
1
2019-08-16T14:40:26
True
False
False
/api/public/snipt/6524/
run-unix-command-in-background
<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>nohup bash syncr.sh <span class="p">&amp;</span> </span></pre></div> </td></tr></table>
shell, unix

Bash

generate unix dsa keys

ssh-keygen -t dsa
https://snipt.net/embed/76b2963e53d67fd9b6a9398a338115d5/
/raw/76b2963e53d67fd9b6a9398a338115d5/
76b2963e53d67fd9b6a9398a338115d5
bash
Bash
1
2019-07-29T06:48:47
True
False
False
/api/public/snipt/4104/
generate-unix-dsa-keys
<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>ssh-keygen -t dsa </span></pre></div> </td></tr></table>
dsa, unix

Bash

set timezone on ubuntu intrepid

sudo dpkg-reconfigure tzdata
https://snipt.net/embed/169ee19a7a9924b1dd7c14c27d7b4e3c/
/raw/169ee19a7a9924b1dd7c14c27d7b4e3c/
169ee19a7a9924b1dd7c14c27d7b4e3c
bash
Bash
1
2019-08-21T08:01:00
True
False
False
/api/public/snipt/3702/
set-timezone-on-ubuntu-intrepid
<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>sudo dpkg-reconfigure tzdata </span></pre></div> </td></tr></table>
timezone, ubuntu, unix

Bash

create multiple directories in unix

mkdir -p domain.com/{public,private,log,cgi-bin,backup}
https://snipt.net/embed/91f18b0263eb25343da69bbb9c22f1ef/
/raw/91f18b0263eb25343da69bbb9c22f1ef/
91f18b0263eb25343da69bbb9c22f1ef
bash
Bash
1
2019-08-20T09:27:08
True
False
False
/api/public/snipt/3476/
create-multiple-directories-in-unix
<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>mkdir -p domain.com/<span class="o">{</span>public,private,log,cgi-bin,backup<span class="o">}</span> </span></pre></div> </td></tr></table>
apache, bash, nginx, unix

Bash

simple unix backup script with rsync, sync only changes

rsync -vare ssh [email protected]:/path/to/files/* /path/to/local/
https://snipt.net/embed/cd36a739ebc4820e8bfd6289be84ba9a/
/raw/cd36a739ebc4820e8bfd6289be84ba9a/
cd36a739ebc4820e8bfd6289be84ba9a
bash
Bash
1
2019-08-12T21:16:55
True
False
False
/api/public/snipt/3471/
simple-unix-backup-script-with-rsync-sync-only-changes
<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>rsync -vare ssh [email protected]:/path/to/files/* /path/to/local/ </span></pre></div> </td></tr></table>
bash, unix

Bash

unix / linux directory tree

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/' 
https://snipt.net/embed/1e6cc974ab23c7be46253a69cb87b908/
/raw/1e6cc974ab23c7be46253a69cb87b908/
1e6cc974ab23c7be46253a69cb87b908
bash
Bash
1
2019-08-19T05:29:28
True
False
False
/api/public/snipt/3319/
unix-linux-directory-tree
<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>ls -R <span class="p">|</span> grep <span class="s2">&quot;:</span>$<span class="s2">&quot;</span> <span class="p">|</span> sed -e <span class="s1">&#39;s/:$//&#39;</span> -e <span class="s1">&#39;s/[^-][^\/]*\//--/g&#39;</span> -e <span class="s1">&#39;s/^/ /&#39;</span> -e <span class="s1">&#39;s/-/|/&#39;</span> </span></pre></div> </td></tr></table>
bash, mac, osx, unix

Bash

set user mask to auto-assign perms of 775 to newly created directories in unix

# in /etc/profile or /etc/bashrc
umask 002
https://snipt.net/embed/2b39c6ac07090bfa68f90e484b96beaa/
/raw/2b39c6ac07090bfa68f90e484b96beaa/
2b39c6ac07090bfa68f90e484b96beaa
bash
Bash
2
2019-08-18T10:22:53
True
False
False
/api/public/snipt/2559/
set-user-mask-to-auto-assign-perms-of-775-to-newly-created-directories-in-unix
<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></span><span id="L-1"><a name="L-1"></a><span class="c1"># in /etc/profile or /etc/bashrc</span> </span><span id="L-2"><a name="L-2"></a><span class="nb">umask</span> 002 </span></pre></div> </td></tr></table>
bash, unix

Bash

create a directory from within the command prompt on unix or mac os x

mkdir django-projects
https://snipt.net/embed/3408dabaac8ebd89ca0064301601443b/
/raw/3408dabaac8ebd89ca0064301601443b/
3408dabaac8ebd89ca0064301601443b
bash
Bash
1
2019-08-21T03:19:20
True
False
False
/api/public/snipt/2307/
create-a-directory-from-within-the-command-prompt-on-unix-or-mac-os-x
<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>mkdir django-projects </span></pre></div> </td></tr></table>
bash, mac, osx, unix

Bash

switch to root user in linux

su -
https://snipt.net/embed/17e9b9c4bf7c0273d2e1aabfc971e28b/
/raw/17e9b9c4bf7c0273d2e1aabfc971e28b/
17e9b9c4bf7c0273d2e1aabfc971e28b
bash
Bash
1
2019-08-12T03:58:00
True
False
False
/api/public/snipt/2296/
switch-to-root-user-in-linux
<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>su - </span></pre></div> </td></tr></table>
bash, root, unix