Shell https://tech.feedyourhead.at/tags/shell en Now is a good time to backup our github-repos https://tech.feedyourhead.at/content/now-is-a-good-time-to-backup-our-github-repos <span class="field field--name-title field--type-string field--label-hidden">Now is a good time to backup our github-repos</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Many people are scared because <a href="https://news.microsoft.com/2018/06/04/microsoft-to-acquire-github-for-7-5-billion/">Microsoft bought GitHub</a>. I wonder why people are so shocked now. Github is just another cloud-thingy and cloud means: "it's just the computer of someone else". If "someone else" will shutdown or wipe his computer, then we better have backups. Having this in our minds I would say that it's time to make (auto)backups. I wrote this little ruby-script that clones all public repositories of a user into a directory. If the repositories already exist locally, then this script will just make a "git-pull".</p> <div class="geshifilter"><pre class="ruby geshifilter-ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span> &nbsp; <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/http'</span> <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'json'</span> <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'fileutils'</span> &nbsp; directory = <span style="color:#996600;">&quot;./&quot;</span> &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> help warn <span style="color:#996600;">&quot;usage: #{$PROGRAM_NAME} &lt;github-user&gt; [ &lt;dst-directory&gt; ]&quot;</span> <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">1</span> <span style="color:#9966CC; font-weight:bold;">end</span> &nbsp; <span style="color:#008000; font-style:italic;"># got this function from stackoverflow.com: </span> <span style="color:#008000; font-style:italic;"># stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby</span> <span style="color:#9966CC; font-weight:bold;">def</span> which<span style="color:#006600; font-weight:bold;">&#40;</span>cmd<span style="color:#006600; font-weight:bold;">&#41;</span> exts = ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'PATHEXT'</span><span style="color:#006600; font-weight:bold;">&#93;</span> ? ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'PATHEXT'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">';'</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#93;</span> ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'PATH'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>::PATH_SEPARATOR<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>path<span style="color:#006600; font-weight:bold;">|</span> exts.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>ext<span style="color:#006600; font-weight:bold;">|</span> exe = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>path, <span style="color:#996600;">&quot;#{cmd}#{ext}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">return</span> exe <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">executable</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>exe<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> !<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">directory</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>exe<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">nil</span> <span style="color:#9966CC; font-weight:bold;">end</span> &nbsp; gitbin = which<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;git&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> gitbin.<span style="color:#0000FF; font-weight:bold;">nil</span>? warn <span style="color:#996600;">&quot;git-binary not found&quot;</span> <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">1</span> <span style="color:#9966CC; font-weight:bold;">end</span> &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> ARGV.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006666;">1</span> <span style="color:#006600; font-weight:bold;">||</span> ARGV.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">2</span> help <span style="color:#9966CC; font-weight:bold;">end</span> &nbsp; gituser = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> directory = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> ARGV.<span style="color:#9900CC;">length</span> == <span style="color:#006666;">2</span> &nbsp; <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">directory</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>directory<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>::mkdir_p directory <span style="color:#9966CC; font-weight:bold;">end</span> &nbsp; uri = <span style="color:#CC00FF; font-weight:bold;">URI</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;https://api.github.com/users/#{gituser}/repos&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &nbsp; resp = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">get</span><span style="color:#006600; font-weight:bold;">&#40;</span>uri<span style="color:#006600; font-weight:bold;">&#41;</span> parsed = JSON.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>resp<span style="color:#006600; font-weight:bold;">&#41;</span> &nbsp; parsed.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">p</span><span style="color:#006600; font-weight:bold;">|</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">directory</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{directory}/#{p['name']}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#CC0066; font-weight:bold;">system</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;cd #{directory}/#{p['name']} &amp;&amp; #{gitbin} pull&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#CC0066; font-weight:bold;">system</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{gitbin} clone https://github.com/#{p['full_name']} #{directory}/#{p['name']}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#9966CC; font-weight:bold;">end</span></pre></div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Jun 07 2018</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/ruby" hreflang="en">Ruby</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/git" hreflang="en">git</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/taxonomy/term/103" hreflang="en">Open-Source</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/backup" hreflang="en">Backup</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=267&amp;2=comment&amp;3=comment" token="oPcbvqzYUcugBxbk0j0w2JLHdMWOfeGFn5WU98XCfbI"></drupal-render-placeholder> </section> Thu, 07 Jun 2018 10:41:24 +0000 Hoti 267 at https://tech.feedyourhead.at Wipe a disk using nwipe https://tech.feedyourhead.at/content/wipe-a-disk-using-nwipe <span class="field field--name-title field--type-string field--label-hidden">Wipe a disk using nwipe</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p><a href="https://en.wikipedia.org/wiki/Darik's_Boot_and_Nuke">Darkik's Boot and Nuke(DBAN)</a> is an open-source programm for securely wipe hard drives but reached it's end of life. There is a fork called <a href="https://github.com/martijnvanbrummelen/nwipe/">nwipe</a>.  On Debian it can be easily installed by calling "apt-get install nwipe" and works almost the same like dban.</p></div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Apr 14 2018</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=261&amp;2=comment&amp;3=comment" token="BBVzI1_DdwGsOfVIFO4Ck_RgMSrlRGsNKFn9gAcASYc"></drupal-render-placeholder> </section> Sat, 14 Apr 2018 10:38:21 +0000 Hoti 261 at https://tech.feedyourhead.at Bash-Insulter: insults you after typing a wrong command https://tech.feedyourhead.at/content/bash-insulter-insults-you-after-typing-a-wrong-command <span class="field field--name-title field--type-string field--label-hidden">Bash-Insulter: insults you after typing a wrong command</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>If you type in a wrong command, <a href="https://github.com/hkbakke/bash-insulter">bash-insulter</a> will insult you badly.</p></div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Nov 17 2017</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Fun" hreflang="en">Fun</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=246&amp;2=comment&amp;3=comment" token="Y4b0V6sSlAiC0eMXerG6va5Rv7tpAJXDMmW6lcZvJP0"></drupal-render-placeholder> </section> Fri, 17 Nov 2017 21:59:35 +0000 Hoti 246 at https://tech.feedyourhead.at UTF8: removing BOM(Byte Order Mark) https://tech.feedyourhead.at/content/utf8-removing-bom <span class="field field--name-title field--type-string field--label-hidden">UTF8: removing BOM(Byte Order Mark)</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>I got the following error while compiling a Latex-File:</p> <pre> <code> compiling MyLatexfile.tex... tex/virtualbox.tex:1: Package inputenc Error: Unicode char \u8: not set up for use with LaTeX. </code></pre> <p>So I checked the encoding of the file and saw that it looked like this:</p> <pre> <code> file tex/virtualbox.tex tex/virtualbox.tex: LaTeX document, UTF-8 Unicode (with BOM) text, with very long lines </code></pre> <p>It seems that inputenc does not like utf-8 with Byte Order Mark. So I removed it using the following sed-command:</p> <pre> <code> sed -i '1 s/^\xef\xbb\xbf//' virtualbox.tex </code></pre> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Dec 18 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sed" hreflang="en">sed</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=219&amp;2=comment&amp;3=comment" token="xNCCgYgUoPSAkyh1IpnpVY4aLdtGJdaVcmB4gGQ_3Mg"></drupal-render-placeholder> </section> Sun, 18 Dec 2016 12:55:30 +0000 Hoti 219 at https://tech.feedyourhead.at Search all installed packages containing a searchstring and uninstall them https://tech.feedyourhead.at/node/216 <span class="field field--name-title field--type-string field--label-hidden">Search all installed packages containing a searchstring and uninstall them</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>This is a one-liner to search for installed packages containing a searchstring and then deinstall them using "apt-get remove":</p> <pre> <code> apt-get remove --purge $(dpkg --get-selections | cut -f 1 | grep DPKG-SEARCHSTRING | xargs echo " " | tr -d '\n') </searchstring></code></pre> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Nov 10 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/one-liner" hreflang="en">One-Liner</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=216&amp;2=comment&amp;3=comment" token="E_ZD3v12REHei49-gexAFiKigmXjUIpj9tmamejF9nU"></drupal-render-placeholder> </section> Thu, 10 Nov 2016 21:45:12 +0000 Hoti 216 at https://tech.feedyourhead.at How to migrate mysql-user/permissions https://tech.feedyourhead.at/content/how-to-migrate-mysql-user-permissions <span class="field field--name-title field--type-string field--label-hidden">How to migrate mysql-user/permissions</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Sometimes we have to migrate some tables from one host to another. And sometimes we want to migrate users as well. This is how I managed to do this..</p> <h3>First let's read out all users</h3> <pre> <code> mysql --batch --skip-column-names -e "SELECT user, host FROM user" mysql </code></pre> <p>Output:</p> <pre> <code> awesomeuser % root 127.0.0.1 root awesomeserver debian-sys-maint localhost root localhost </code></pre> <h3>And this is how I migrated the awesome-user</h3> <pre> <code> mysql --batch --skip-column-names -e"SHOW GRANTS FOR 'awesomeuser'@'%'" </code></pre> <p>I cut and pasted the following output into the mysql-shell of the other server:</p> <pre> <code> GRANT ALL PRIVILEGES ON *.* TO 'awesomeuser'@'%' IDENTIFIED BY PASSWORD '*766fd8db17e9dcb277aa74f3f1dee75e883b30e2' WITH GRANT OPTION GRANT ALL PRIVILEGES ON `awesomedb`.* TO 'awesomeuser'@'%' WITH GRANT OPTION </code></pre> <p>&nbsp;</p> <p><strong>Update for Percona-User</strong>: percona-toolkit ships with pt-show-grants</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Nov 02 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/database" hreflang="en">Database</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=213&amp;2=comment&amp;3=comment" token="mkICtYdpeOOTVZaBr1ncDdjSWUxkImTHkNE7N4BJUWg"></drupal-render-placeholder> </section> Wed, 02 Nov 2016 17:29:00 +0000 Hoti 213 at https://tech.feedyourhead.at How to find out the serial number of a specific disk https://tech.feedyourhead.at/content/how-to-find-out-the-serialnumber-of-a-specific-disk <span class="field field--name-title field--type-string field--label-hidden">How to find out the serial number of a specific disk</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>To find out the serial number of a disk I mostly use one of the following commands:</p> <pre> <code> /sbin/udevadm info --query=property --name=sdb | grep ID_SERIAL ## or hdparm -i /dev/sdb | grep SerialNo </code></pre> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Oct 11 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=210&amp;2=comment&amp;3=comment" token="0HQdQkVEnVheppCUg1c4U7pZW02UeIOYJL7M5jL8_Dw"></drupal-render-placeholder> </section> Tue, 11 Oct 2016 14:32:48 +0000 Hoti 210 at https://tech.feedyourhead.at Creating screenshots using imagemagick https://tech.feedyourhead.at/content/creating-screenshots-using-imagemagick <span class="field field--name-title field--type-string field--label-hidden">Creating screenshots using imagemagick</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Normally I don't use the "print"-key on my keyboard. I woud like to use it to quickly create screenshots. So I'll map the following command to my .fluxbox/keys-file:</p> <pre> <code> sleep 5s && import /home/dr/Screenshots/`date +%F-%T`.jpg </code></pre> <p>After 5 seconds of idle-time this command will activate a screenshot. After the cursor changed I can select a window or a region on my screen. The screenshot will be saved with it's date and time under /home/dr/Screenshots.</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sep 29 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=205&amp;2=comment&amp;3=comment" token="tFMXoK8exiR0h7YBDnPicFEZo7xfQyy2xk5zrjAp8C4"></drupal-render-placeholder> </section> Thu, 29 Sep 2016 19:33:13 +0000 Hoti 205 at https://tech.feedyourhead.at How to access a Virtualbox VDI-Disk https://tech.feedyourhead.at/content/how-to-access-a-vritualbox-vdi-disk <span class="field field--name-title field--type-string field--label-hidden">How to access a Virtualbox VDI-Disk</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Today I wanted to copy a disk-image to a Virtualbox-disk(VDI) using dd. In this article I am going to describe how I managed to access the disk from the Linux command-line, copied the image and mounted a VDI-disk-partition</p> <h2>Binding the disk</h2> <p>First of all I had to bind the disk as a block-device. I used a very handy module named "Network Block Device". Therefore I needed to load the kernel-module:</p> <pre> <code> modprobe nbd </code></pre> <p>If the nbd-module was loaded, I could connect the disk using qemu-nbd:</p> <pre> <code> qemu-nbd -c /dev/nbd0 myfancydisk.VDI </code></pre> <h2>Using the block-device</h2> <p>After binding the disk as a network-block-device, I had a disk-device to write on. So I just run dd to copy my image:</p> <pre> <code> dd if=superdisk.img of=/dev/nbd0 bs=4M </code></pre> <p>Of course it would be possible to partition the disk using cfdisk:</p> <pre> <code> cfdisk /dev/nbd0 </code></pre> <h2>Mounting a partition</h2> <p>I could also mount one of the partitions of my VDI-Disk:</p> <pre> <code> mount /dev/nbd0p1 /mnt/tmp </code></pre> <p>Or umount it again:</p> <pre> <code> umount /mnt/tmp </code></pre> <h2>Disconnecting the VDI-Disk</h2> <p>To disconnect the VDI-disk, I ran qemo-nbd with the following parameter:</p> <pre> <code> qemu-nbd -d /dev/nbd0 </code></pre> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sep 29 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/virtualization" hreflang="en">Virtualization</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=202&amp;2=comment&amp;3=comment" token="k2TOXVPv8Zz-eq-ZQQCumVuKmNZep3DfKnF9bxaSDMQ"></drupal-render-placeholder> </section> Thu, 29 Sep 2016 08:48:42 +0000 Hoti 202 at https://tech.feedyourhead.at Using pushd/popd https://tech.feedyourhead.at/content/using-pushd-popd <span class="field field--name-title field--type-string field--label-hidden">Using pushd/popd</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Most linux-users know $OLDPWD. It's an environment variable to get the recently used directory. Sometimes it would be nice to remember more visited directories. In such cases pushd and popd would be a good choice..</p> <p>Most common shells do have a directory stack. By looking in the man-page of bash I found the following description of the DIRSTACK:</p> <blockquote> <p>An array variable (see Arrays below) containing the current contents of the&nbsp; directory stack.&nbsp; Directories appear in the stack in the order they are displayed by the dirs builtin.&nbsp; Assigning to members of this array variable may be&nbsp; used&nbsp; to&nbsp; modify directories&nbsp; already&nbsp; in the stack, but the pushd and popd builtins must be used to add and remove directories.&nbsp; Assignment to this variable will not change&nbsp; the&nbsp; current&nbsp; directory.&nbsp; If DIRSTACK is unset, it loses its special properties, even if it is subsequently reset.</p> </blockquote> <p>If we call pushd we can change the directory and save the current directory to the directory stack:</p> <pre> <code> dr@tardis:~$ pushd /tmp /tmp ~ dr@tardis:/tmp$ echo $DIRSTACK /tmp dr@tardis:/tmp$ pushd /home /home /tmp ~ dr@tardis:/home$ pushd /opt /opt /home /tmp ~ </code></pre> <p>So now I am at /opt and have the following directories in my DIRSTACK: /opt /home /tmp ~ Now I will walk back all the way:</p> <pre> <code> dr@tardis:/opt$ popd /home /tmp ~ dr@tardis:/home$ popd /tmp ~ dr@tardis:/tmp$ popd ~ dr@tardis:~$ </code></pre> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Jul 23 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/shell" hreflang="en">Shell</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/bash" hreflang="en">Bash</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/zsh" hreflang="en">Zsh</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=192&amp;2=comment&amp;3=comment" token="ykJYQ6-O03TV9pSV4v9rIQvROaDf_0-bkuQNf1N3a8g"></drupal-render-placeholder> </section> Sat, 23 Jul 2016 07:34:07 +0000 Hoti 192 at https://tech.feedyourhead.at