snipt

Ctrl+h for KB shortcuts

Text only

Regular expressions examples

1
2
3
4
5
6
7
8
* Match all character until "}" string example: "{qwerty_190}"

/^{([^}]+)}$/


/^ -> start of line
/$ -> end of line
([^}]+) -> match all character until "}"
https://snipt.net/embed/ae2d90656b55d7f3f9765c1b75c03cfe/
/raw/ae2d90656b55d7f3f9765c1b75c03cfe/
ae2d90656b55d7f3f9765c1b75c03cfe
text
Text only
8
2019-08-23T05:40:31
True
False
False
Apr 28, 2014 at 06:22 AM
/api/public/snipt/133427/
regular-expressions-examples-54fd5fc3
<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> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>* Match all character until &quot;}&quot; string example: &quot;{qwerty_190}&quot; </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>/^{([^}]+)}$/ </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a>/^ -&gt; start of line </span><span id="L-7"><a name="L-7"></a>/$ -&gt; end of line </span><span id="L-8"><a name="L-8"></a>([^}]+) -&gt; match all character until &quot;}&quot; </span></pre></div> </td></tr></table>

Text only

get public ip

curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
https://snipt.net/embed/3fce86f25328667e2eaf8f9ce70346d8/
/raw/3fce86f25328667e2eaf8f9ce70346d8/
3fce86f25328667e2eaf8f9ce70346d8
text
Text only
1
2019-08-23T05:40:43
True
False
False
Apr 23, 2014 at 02:50 AM
/api/public/snipt/132116/
get-public-ip
<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>curl -s checkip.dyndns.org|sed -e &#39;s/.*Current IP Address: //&#39; -e &#39;s/&lt;.*$//&#39; </span></pre></div> </td></tr></table>

Text only

Capture SYN connections with tcpdump

tcpdump -i eth0 'tcp[13] = 2' -v
https://snipt.net/embed/a97999a090e2dc215f51cd056276d4ec/
/raw/a97999a090e2dc215f51cd056276d4ec/
a97999a090e2dc215f51cd056276d4ec
text
Text only
1
2019-08-23T05:41:12
True
False
False
Oct 25, 2013 at 03:31 AM
/api/public/snipt/90026/
capture-syn-connections-with-tcpdump
<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>tcpdump -i eth0 &#39;tcp[13] = 2&#39; -v </span></pre></div> </td></tr></table>

Bash

Creacion usuario mysql

GRANT ALL PRIVILEGES ON test.* TO 'user'@'localhost' IDENTIFIED BY 'pass_user';
https://snipt.net/embed/d4caaa72a0717d613bc94ec317685736/
/raw/d4caaa72a0717d613bc94ec317685736/
d4caaa72a0717d613bc94ec317685736
bash
Bash
6
2019-08-24T10:44:08
True
False
False
/api/public/snipt/38168/
creacion-usuario-mysql
<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>GRANT ALL PRIVILEGES ON test.* TO <span class="s1">&#39;user&#39;</span>@<span class="s1">&#39;localhost&#39;</span> IDENTIFIED BY <span class="s1">&#39;pass_user&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
create, grant, mysql, user

Bash

backup mysql

1
2
3
4
5
#hacer copia de seguridad de base de datos en mysql
mysqldump --opt --password=miclave --user=miuser mibasededatos > archivo.sql

#resturar la copia de seguridad
mysql --password=miclave --user=miuser mibase < archivo.sql
https://snipt.net/embed/00751c547d341c6d8f47bfc5b21d68d2/
/raw/00751c547d341c6d8f47bfc5b21d68d2/
00751c547d341c6d8f47bfc5b21d68d2
bash
Bash
5
2019-08-23T05:41:31
True
False
False
/api/public/snipt/27942/
backup-mysql
<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">#hacer copia de seguridad de base de datos en mysql</span> </span><span id="L-2"><a name="L-2"></a>mysqldump --opt --password<span class="o">=</span>miclave --user<span class="o">=</span>miuser mibasededatos &gt; archivo.sql </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">#resturar la copia de seguridad</span> </span><span id="L-5"><a name="L-5"></a>mysql --password<span class="o">=</span>miclave --user<span class="o">=</span>miuser mibase &lt; archivo.sql </span></pre></div> </td></tr></table>
backup, dump, mysql, mysqldump, restore

Text only

"Too many open files" solution

1
2
3
4
5
6
7
1. In /etc/security/limits.conf 
* soft nofile 10000
* hard nofile 65535
2. Increase ulimit by "ulimit -n 65535"
3. echo 65535 > /proc/sys/fs/file-max
4. In /etc/sysctl.conf 
fs.file-max=65535
https://snipt.net/embed/75876659ef79e4cc8a4e6e38cd108264/
/raw/75876659ef79e4cc8a4e6e38cd108264/
75876659ef79e4cc8a4e6e38cd108264
text
Text only
7
2019-08-23T18:16:24
True
False
False
/api/public/snipt/27936/
too-many-open-files-solution
<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> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>1. In /etc/security/limits.conf </span><span id="L-2"><a name="L-2"></a>* soft nofile 10000 </span><span id="L-3"><a name="L-3"></a>* hard nofile 65535 </span><span id="L-4"><a name="L-4"></a>2. Increase ulimit by &quot;ulimit -n 65535&quot; </span><span id="L-5"><a name="L-5"></a>3. echo 65535 &gt; /proc/sys/fs/file-max </span><span id="L-6"><a name="L-6"></a>4. In /etc/sysctl.conf </span><span id="L-7"><a name="L-7"></a>fs.file-max=65535 </span></pre></div> </td></tr></table>
bash, debian, files, linux, many, too, ubuntu

Bash

Cambia el delimitador de campos solo a retorno de carro

IFS=$'\x0A'$'\x0D'; 
https://snipt.net/embed/a34834b58b77e97022800777795531c6/
/raw/a34834b58b77e97022800777795531c6/
a34834b58b77e97022800777795531c6
bash
Bash
1
2019-08-23T05:41:59
True
False
False
/api/public/snipt/27670/
cambia-el-delimitador-de-campos-solo-a-retorno-de-carro
<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="nv">IFS</span><span class="o">=</span><span class="s1">$&#39;\x0A&#39;$&#39;\x0D&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
delimitador, fichero
https://snipt.net/embed/84c8f1b51eb51da6b91288647d87e35a/
/raw/84c8f1b51eb51da6b91288647d87e35a/
84c8f1b51eb51da6b91288647d87e35a
bash
Bash
1
2019-08-23T05:42:32
True
False
False
/api/public/snipt/27664/
convertir-todo-el-texto-en-minusculas-con-vim
<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>ggGVu </span></pre></div> </td></tr></table>
minusculas, vim