snipt

Ctrl+h for KB shortcuts

Bash

Change SSH port on OS X

1
2
3
4
5
# Add a service on an unused port in:
sudo vim /etc/services

# Change the string "ssh" below "SockServiceName" to whatever name used in the above file
sudo vim /System/Library/LaunchDaemons/ssh.plist
https://snipt.net/embed/7d7273436601ba72fdfd858fa8e2c103/
/raw/7d7273436601ba72fdfd858fa8e2c103/
7d7273436601ba72fdfd858fa8e2c103
bash
Bash
5
2019-06-20T08:10:30
True
False
False
/api/public/snipt/7733/
change-ssh-port-on-os-x
<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></span><span id="L-1"><a name="L-1"></a><span class="c1"># Add a service on an unused port in:</span> </span><span id="L-2"><a name="L-2"></a>sudo vim /etc/services </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># Change the string &quot;ssh&quot; below &quot;SockServiceName&quot; to whatever name used in the above file</span> </span><span id="L-5"><a name="L-5"></a>sudo vim /System/Library/LaunchDaemons/ssh.plist </span></pre></div> </td></tr></table>
osx, security, ssh

Bash

Disassembler for Python bytecode

1
2
3
4
5
6
$ python -m dis test.py 
  1           0 LOAD_CONST               0 ('Hello world')
              3 PRINT_ITEM          
              4 PRINT_NEWLINE       
              5 LOAD_CONST               1 (None)
              8 RETURN_VALUE        
https://snipt.net/embed/df6e3b37133eb022c48e421227a19f7e/
/raw/df6e3b37133eb022c48e421227a19f7e/
df6e3b37133eb022c48e421227a19f7e
bash
Bash
7
2019-06-25T13:09:05
True
False
False
/api/public/snipt/6881/
disassembler-for-python-bytecode
<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> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ python -m dis test.py </span><span id="L-2"><a name="L-2"></a> <span class="m">1</span> <span class="m">0</span> LOAD_CONST <span class="m">0</span> <span class="o">(</span><span class="s1">&#39;Hello world&#39;</span><span class="o">)</span> </span><span id="L-3"><a name="L-3"></a> <span class="m">3</span> PRINT_ITEM </span><span id="L-4"><a name="L-4"></a> <span class="m">4</span> PRINT_NEWLINE </span><span id="L-5"><a name="L-5"></a> <span class="m">5</span> LOAD_CONST <span class="m">1</span> <span class="o">(</span>None<span class="o">)</span> </span><span id="L-6"><a name="L-6"></a> <span class="m">8</span> RETURN_VALUE </span></pre></div> </td></tr></table>
bytecode, disassembler, profiling, python

Bash

Bash—please save my history for ever and eternity (or, at least a really long time)

1
2
3
4
5
6
# In .bashrc or .bash_profile
export HISTCONTROL=ignoredups:ignorespace
export HISTSIZE=10000
export HISTFILESIZE=1000000
export HISTTIMEFORMAT="%F %T "
export PROMPT_COMMAND='history -a'
https://snipt.net/embed/66a35c6d935778d767cbf849bd50c74f/
/raw/66a35c6d935778d767cbf849bd50c74f/
66a35c6d935778d767cbf849bd50c74f
bash
Bash
7
2019-06-20T14:57:32
True
False
False
/api/public/snipt/6723/
bashsave-my-history-for-ever-and-eternity-well-almost
<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> <a href="#L-6">6</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 .bashrc or .bash_profile</span> </span><span id="L-2"><a name="L-2"></a><span class="nb">export</span> <span class="nv">HISTCONTROL</span><span class="o">=</span>ignoredups:ignorespace </span><span id="L-3"><a name="L-3"></a><span class="nb">export</span> <span class="nv">HISTSIZE</span><span class="o">=</span>10000 </span><span id="L-4"><a name="L-4"></a><span class="nb">export</span> <span class="nv">HISTFILESIZE</span><span class="o">=</span>1000000 </span><span id="L-5"><a name="L-5"></a><span class="nb">export</span> <span class="nv">HISTTIMEFORMAT</span><span class="o">=</span><span class="s2">&quot;%F %T &quot;</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">export</span> <span class="nv">PROMPT_COMMAND</span><span class="o">=</span><span class="s1">&#39;history -a&#39;</span> </span></pre></div> </td></tr></table>
bash, history

Python

Simple generation of random string in Python

1
2
3
4
import string
import random

print "".join(random.sample(string.letters+string.digits, 8))
https://snipt.net/embed/ac145bb5129e46f730fa7009e98abfb5/
/raw/ac145bb5129e46f730fa7009e98abfb5/
ac145bb5129e46f730fa7009e98abfb5
python
Python
4
2019-06-23T22:01:57
True
False
False
/api/public/snipt/6463/
simple-generation-of-random-string-in-python
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kn">import</span> <span class="nn">string</span> </span><span id="L-2"><a name="L-2"></a><span class="kn">import</span> <span class="nn">random</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="k">print</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="n">sample</span><span class="p">(</span><span class="n">string</span><span class="o">.</span><span class="n">letters</span><span class="o">+</span><span class="n">string</span><span class="o">.</span><span class="n">digits</span><span class="p">,</span> <span class="mi">8</span><span class="p">))</span> </span></pre></div> </td></tr></table>
python, random, strings

Bash

Install VMWare Tools on Debian

1
2
3
4
5
# Make sure you have contrib and non-free in /etc/apt/sources.list
# Then:

apt-get install module-assistant
m-a a-i open-vm
https://snipt.net/embed/116fd929cfe58fdab62909700bc896ef/
/raw/116fd929cfe58fdab62909700bc896ef/
116fd929cfe58fdab62909700bc896ef
bash
Bash
5
2019-06-22T13:18:06
True
False
False
/api/public/snipt/6408/
install-vmware-tools-on-debian
<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></span><span id="L-1"><a name="L-1"></a><span class="c1"># Make sure you have contrib and non-free in /etc/apt/sources.list</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># Then:</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>apt-get install module-assistant </span><span id="L-5"><a name="L-5"></a>m-a a-i open-vm </span></pre></div> </td></tr></table>
admin, debian, linux, server, vmware

Bash

Change Linux hostname without reboot

1
2
3
vim /etc/hostname
vim /etc/hosts
hostname new-hostname
https://snipt.net/embed/88ab7887b6637d9446fd791c21d5e134/
/raw/88ab7887b6637d9446fd791c21d5e134/
88ab7887b6637d9446fd791c21d5e134
bash
Bash
3
2019-05-22T09:59:25
True
False
False
/api/public/snipt/6407/
change-linux-hostname-without-reboot
<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>vim /etc/hostname </span><span id="L-2"><a name="L-2"></a>vim /etc/hosts </span><span id="L-3"><a name="L-3"></a>hostname new-hostname </span></pre></div> </td></tr></table>
admin, bash, linux