snipt

Ctrl+h for KB shortcuts
Notice: Snipt is moving away from free accounts on May 1st, 2014. Read more about the transition here.
#32159

Bash

Display system information

# Display CPU information
less /proc/cpuinfo
https://snipt.net/embed/e0711a2bd0d5ad44b89c3db42988f696/
https://snipt.net/raw/e0711a2bd0d5ad44b89c3db42988f696/
e0711a2bd0d5ad44b89c3db42988f696
bash
Bash
2
2014-04-16T16:26:35
True
False
/api/public/snipt/32159/
display-system-information
<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 id="L-1"><a name="L-1"></a><span class="c"># Display CPU information</span> </span><span id="L-2"><a name="L-2"></a>less /proc/cpuinfo </span></pre></div> </td></tr></table>
cpu, system
#28017

Python

Get platform information

1
2
3
4
5
6
7
8
# Get platform information
import platform
platform.uname()
platform.platform()
platform.release()
platform.version()   
platform.system()    
dir(platform)        
https://snipt.net/embed/052a322b93023f96e15542a287f04a67/
https://snipt.net/raw/052a322b93023f96e15542a287f04a67/
052a322b93023f96e15542a287f04a67
python
Python
8
2014-04-19T18:20:37
True
False
/api/public/snipt/28017/
get-platform-information
<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 id="L-1"><a name="L-1"></a><span class="c"># Get platform information</span> </span><span id="L-2"><a name="L-2"></a><span class="kn">import</span> <span class="nn">platform</span> </span><span id="L-3"><a name="L-3"></a><span class="n">platform</span><span class="o">.</span><span class="n">uname</span><span class="p">()</span> </span><span id="L-4"><a name="L-4"></a><span class="n">platform</span><span class="o">.</span><span class="n">platform</span><span class="p">()</span> </span><span id="L-5"><a name="L-5"></a><span class="n">platform</span><span class="o">.</span><span class="n">release</span><span class="p">()</span> </span><span id="L-6"><a name="L-6"></a><span class="n">platform</span><span class="o">.</span><span class="n">version</span><span class="p">()</span> </span><span id="L-7"><a name="L-7"></a><span class="n">platform</span><span class="o">.</span><span class="n">system</span><span class="p">()</span> </span><span id="L-8"><a name="L-8"></a><span class="nb">dir</span><span class="p">(</span><span class="n">platform</span><span class="p">)</span> </span></pre></div> </td></tr></table>
os, platform, python, system
#21868

Python

read stdout after system call

str = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE).communicate()[0]
https://snipt.net/embed/eb6050a55db29206e7fa679860cc22cb/
https://snipt.net/raw/eb6050a55db29206e7fa679860cc22cb/
eb6050a55db29206e7fa679860cc22cb
python
Python
1
2014-04-11T16:41:38
True
False
/api/public/snipt/21868/
read-stdout-after-system-call
<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 id="L-1"><a name="L-1"></a><span class="nb">str</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">([</span><span class="s">&#39;ls&#39;</span><span class="p">,</span> <span class="s">&#39;-l&#39;</span><span class="p">],</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span><span class="o">.</span><span class="n">communicate</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> </span></pre></div> </td></tr></table>
call, read, stdout, system
#16264

Bash

Log in into ubuntu installation from Live CD

1
2
3
4
requires: terminal from Live CD
sudo fdisk -l (get installation drive)
sudo mount <installation drive> /mnt
sudo chroot mount (now you are root in the hd installation)
https://snipt.net/embed/78e7b630a729295edfbd805b3f524605/
https://snipt.net/raw/78e7b630a729295edfbd805b3f524605/
78e7b630a729295edfbd805b3f524605
bash
Bash
4
2014-04-22T14:26:21
True
False
/api/public/snipt/16264/
log-in-into-ubuntu-installation-from-live-cd
<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 id="L-1"><a name="L-1"></a>requires: terminal from Live CD </span><span id="L-2"><a name="L-2"></a>sudo fdisk -l <span class="o">(</span>get installation drive<span class="o">)</span> </span><span id="L-3"><a name="L-3"></a>sudo mount &lt;installation drive&gt; /mnt </span><span id="L-4"><a name="L-4"></a>sudo chroot mount <span class="o">(</span>now you are root in the hd installation<span class="o">)</span> </span></pre></div> </td></tr></table>
chroot, recovery, system, ubuntu
#16226

Bash

Format disk using FAT 16

sudo mkdosfs -F 16 /path/to/disk/unit
https://snipt.net/embed/897bb05be63eb856468e3297e50aee80/
https://snipt.net/raw/897bb05be63eb856468e3297e50aee80/
897bb05be63eb856468e3297e50aee80
bash
Bash
1
2014-04-16T06:46:11
True
False
/api/public/snipt/16226/
format-disk-using-fat-16
<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 id="L-1"><a name="L-1"></a>sudo mkdosfs -F 16 /path/to/disk/unit </span></pre></div> </td></tr></table>
command, format, system
#16225

Bash

List mounted disks

sudo fdisk -l
https://snipt.net/embed/d363c5c9395804666b9c7010ed8725b6/
https://snipt.net/raw/d363c5c9395804666b9c7010ed8725b6/
d363c5c9395804666b9c7010ed8725b6
bash
Bash
1
2014-04-06T03:29:58
True
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 id="L-1"><a name="L-1"></a>sudo fdisk -l </span></pre></div> </td></tr></table>
coomand, disk, system