snipt

Ctrl+h for KB shortcuts

Text only

Improved "Find Large Files" Command

du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1f\t%s\t%25s | %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'
https://snipt.net/embed/99e2854c2ed77ac7c161a0ecf3e56713/
/raw/99e2854c2ed77ac7c161a0ecf3e56713/
99e2854c2ed77ac7c161a0ecf3e56713
text
Text only
1
2019-06-17T02:24:18
True
False
False
/api/public/snipt/27619/
improved-find-large-files-command
<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>du -k | sort -n | perl -ne &#39;if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf (&quot;%6.1f\t%s\t%25s | %s\n&quot;,($1/(2**(10*$m))),((&quot;K&quot;,&quot;M&quot;,&quot;G&quot;,&quot;T&quot;,&quot;P&quot;)[$m]),&quot;*&quot;x (1.5*$l),$2);}&#39; </span></pre></div> </td></tr></table>
"disk space", "disk usage", (dv), disk

Bash

List mounted disks

sudo fdisk -l
https://snipt.net/embed/d363c5c9395804666b9c7010ed8725b6/
/raw/d363c5c9395804666b9c7010ed8725b6/
d363c5c9395804666b9c7010ed8725b6
bash
Bash
1
2019-06-16T18:23:38
True
False
False
/api/public/snipt/16225/
list-mounted-disks
<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 fdisk -l </span></pre></div> </td></tr></table>
coomand, disk, system

Bash

sparse disk dd mkfs.ext3

1
2
3
4
5
# sparse disk dd
# seek * 300 = 1024 * 300 = 300G

dd if=/dev/zero of=/xen/dom1.img bs=1024k seek=1024 count=0
mkfs.ext3 -F dom1.img
https://snipt.net/embed/129ff03ff5751f4c3c4fbb93bfa06e24/
/raw/129ff03ff5751f4c3c4fbb93bfa06e24/
129ff03ff5751f4c3c4fbb93bfa06e24
bash
Bash
6
2019-06-19T15:45:20
True
False
False
/api/public/snipt/10015/
sparse-disk-dd-mkfsext3
<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"># sparse disk dd</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># seek * 300 = 1024 * 300 = 300G</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>dd <span class="k">if</span><span class="o">=</span>/dev/zero <span class="nv">of</span><span class="o">=</span>/xen/dom1.img <span class="nv">bs</span><span class="o">=</span>1024k <span class="nv">seek</span><span class="o">=</span><span class="m">1024</span> <span class="nv">count</span><span class="o">=</span>0 </span><span id="L-5"><a name="L-5"></a>mkfs.ext3 -F dom1.img </span></pre></div> </td></tr></table>
dd, disk, mkfs.ext3, sparse

Bash

monitor space usage in real time - by partition and with total

watch 'df -P / /var /mnt/* | tail -n +2 | ( total=0; while read dev blocks used rest; do total=$(($total+$used)) ; echo $used $dev; done; echo -----; echo $total )'
https://snipt.net/embed/92caf508218f539ff6f88c9340ce1e0f/
/raw/92caf508218f539ff6f88c9340ce1e0f/
92caf508218f539ff6f88c9340ce1e0f
bash
Bash
1
2019-06-18T10:00:15
True
False
False
/api/public/snipt/5160/
monitor-space-usage-in-real-time-by-partition-and-with-total
<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>watch <span class="s1">&#39;df -P / /var /mnt/* | tail -n +2 | ( total=0; while read dev blocks used rest; do total=$(($total+$used)) ; echo $used $dev; done; echo -----; echo $total )&#39;</span> </span></pre></div> </td></tr></table>
bash, df, disk, monitor, partition, space

Bash

Email list of files over 10MB

cd / ; find . -size '+10000k' -exec ls -Shl {} \; | mail -s"disk usage over 10MB" [email protected]
https://snipt.net/embed/f5e758e33cad95594e521bb1abd62c2c/
/raw/f5e758e33cad95594e521bb1abd62c2c/
f5e758e33cad95594e521bb1abd62c2c
bash
Bash
1
2019-06-01T06:07:39
True
False
False
/api/public/snipt/4354/
email-list-of-files-over-10mb
<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">cd</span> / <span class="p">;</span> find . -size <span class="s1">&#39;+10000k&#39;</span> -exec ls -Shl <span class="o">{}</span> <span class="se">\;</span> <span class="p">|</span> mail -s<span class="s2">&quot;disk usage over 10MB&quot;</span> [email protected] </span></pre></div> </td></tr></table>
disk, usage