Bash https://tech.feedyourhead.at/tags/bash en GNU parallel https://tech.feedyourhead.at/content/gnu-parallel <span class="field field--name-title field--type-string field--label-hidden">GNU parallel</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>GNU parallel is an amazing command line tool for executing jobs in parallel using one or more machines. It has a lot of features and therefore a lot of options. Fortunately the manual page is full of examples.</p> <p><iframe allowfullscreen="" frameborder="0" height="480" src="https://www.youtube.com/embed/P40akGWJ_gY?list=PL284C9FF2488BC6D1" width="854"></iframe></p> <h1>Simulty revisited</h1> <p>Once I wrote an <a href="https://tech.feedyourhead.at/content/simulty">article about a very simple http-stress-tool simulty.</a> It reads random urls from a file and executes multiple get-requests simultaneously to them. I wrote this script in ruby. Now I try to do the same with parallel:</p> <pre> <code> while true; do awk "NR==$(($RANDOM % `wc -l urls.txt | cut -f 1 -d ' '` +1)){print}" urls.txt; done | parallel -j 100 curl -4 </code></pre> <p>Just one line on the command-line.</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">Aug 20 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/bash" hreflang="en">Bash</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Programming" hreflang="en">Programming</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/one-liner" hreflang="en">One-Liner</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=197&amp;2=comment&amp;3=comment" token="wvEhlJxpFNg1EAc4RWq4TP5iwHGWQNC6dbVIB3GRh6w"></drupal-render-placeholder> </section> Sat, 20 Aug 2016 08:03:40 +0000 Hoti 197 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 Bash: echo to stderr https://tech.feedyourhead.at/node/166 <span class="field field--name-title field--type-string field--label-hidden">Bash: echo to stderr</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><pre> <code> echo error &gt;&amp;2 </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">Mar 09 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/bash" hreflang="en">Bash</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=166&amp;2=comment&amp;3=comment" token="N3gUbsdJsFt91wsJ6tk_E1tXtM_1JNU1gSNCWWL3eTk"></drupal-render-placeholder> </section> Wed, 09 Mar 2016 13:56:53 +0000 Hoti 166 at https://tech.feedyourhead.at reptyr - A tool for "re-ptying" programs https://tech.feedyourhead.at/content/repty <span class="field field--name-title field--type-string field--label-hidden">reptyr - A tool for &quot;re-ptying&quot; programs</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>It happens so often that when I start a copy-job remotely, I just realize that I forgot to start it in <a href="http://gnuscreen.org/">GNU screen</a>. Sometimes I can just stop the job and start it again in screen, but very often stopping the job might be problematically. There is a nice tool called reptyr which can <a href="https://github.com/nelhage/reptyr">re-ptying</a> your jobs.</p> <h3>Downloading</h3> <p>We can just use git to download the sources:</p> <pre> <code>git clone https://github.com/nelhage/reptyr </code></pre> <h3>Compiling:</h3> <pre> <code> make cc -Wall -Werror -D_GNU_SOURCE -g -c -o reptyr.o reptyr.c cc -Wall -Werror -D_GNU_SOURCE -g -c -o reallocarray.o reallocarray.c cc -Wall -Werror -D_GNU_SOURCE -g -c -o attach.o attach.c cc -Wall -Werror -D_GNU_SOURCE -g -c -o platform/linux/linux_ptrace.o platform/linux/linux_ptrace.c cc -Wall -Werror -D_GNU_SOURCE -g -c -o platform/linux/linux.o platform/linux/linux.c cc reptyr.o reallocarray.o attach.o platform/linux/linux_ptrace.o platform/linux/linux.o -o reptyr </code></pre> <h3>Preparing the system</h3> <pre> <code> echo 0 &gt; /proc/sys/kernel/yama/ptrace_scope </code></pre> <p>Or make it permanently by using the /etc/sysctl.conf:</p> <pre> <code> echo "kernel.yama.ptrace_scope = 0" &gt;&gt; /etc/sysctl.conf sysctl -p </code></pre> <h3>Using repty</h3> <pre> <code> reptyr PID </code></pre> <h3>Some problems</h3> <p>I did some tests with shell-scrips(using sleeep) and I wasn't able to repty them. But even though, this programm is super useful!</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">Feb 03 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/bash" hreflang="en">Bash</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 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=155&amp;2=comment&amp;3=comment" token="KzRQ7gEfbvxzoAevRDnxUE2TQF-Dc6UchirxVQFEXco"></drupal-render-placeholder> </section> Wed, 03 Feb 2016 20:39:16 +0000 Hoti 155 at https://tech.feedyourhead.at the fuck: Magnificent app which corrects your previous console command https://tech.feedyourhead.at/content/the-fuck <span class="field field--name-title field--type-string field--label-hidden">the fuck: Magnificent app which corrects your previous console command</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p><img alt="the fuck programm" data-entity-type="file" data-entity-uuid="db5d31d7-a41d-43dd-911b-276cd8ce9515" src="/sites/default/files/inline-images/thefuck_prog_0.gif" /></p> <blockquote> <p><a href="https://github.com/nvbn/thefuck">Magnificent app</a> which corrects your previous console command, inspired by a <a href="https://twitter.com/liamosaur/">@liamosaur</a> <a href="https://twitter.com/liamosaur/status/506975850596536320">tweet</a>.</p> </blockquote> </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">Jan 25 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/bash" hreflang="en">Bash</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/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=151&amp;2=comment&amp;3=comment" token="6scgbwkmUNbnaHe4ylv3Lx1dPFN5sdnJ3Jo-DPrg0dk"></drupal-render-placeholder> </section> Mon, 25 Jan 2016 18:35:57 +0000 Hoti 151 at https://tech.feedyourhead.at The Rule Of Three (Part2) https://tech.feedyourhead.at/content/rule-three-part2 <span class="field field--name-title field--type-string field--label-hidden">The Rule Of Three (Part2)</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>A sysadmin needs his tools.&nbsp; I really need at least 3 tools to be productive:</p> <ol> <li> <div>Terminal-Emulator (or screen/tmux if I am working without X)</div> </li> <li> <div>Shell</div> </li> <li> <div>Editor</div> </li> </ol> <p>This is my <a href="https://en.wikipedia.org/wiki/Rule_of_three_%28writing%29">Rule Of Three.</a> Those 3 tools can make my life much easier. Therefore I have to choose those tools wisely. And of course I have to know them very well, so I can get all the benefits of them. The last time I wrote about <a href="http://tech.feedyourhead.at/content/rule-three-part-1">rxvt(Terminal-Emulator)</a>. In&nbsp; this article I want to introduce one of my "favourite" shells: <a href="http://www.zsh.org/"><em>zsh</em></a></p> <p>I have to say that I like the <a href="https://www.gnu.org/software/bash/">bash</a> too. It is my rootshell and I am very used to the <a href="https://www.gnu.org/software/bash/">bash</a> because I am using it for many years. Zsh on the other side is very customizable and has cool scripting-features, that's why it became my standard usershell.</p> <h2>Customization</h2> <p>What's really great about zsh is that it is highly customizable. The problem with "highly customizable" is mostly that things start to get complex. Luckily, there are frameworks to make this task more easy. One of them is <a href="http://ohmyz.sh/">oh-my-zsh</a>. It's loaded via your .zshrc and comes with lot's of plugins for autocompletion and themes. Just try it, it's great!</p> <h2>Autoload long commands in you editor</h2> <p>If you just typed in a very long command in your shell and you want this command copied in your favourite editor($EDITOR) then just type <strong>&lt;CTRL&gt;+X &lt;CTRL&gt;+E</strong></p> <h2>Builtin Pager</h2> <p>zsh has a builtin pager. If you want to read a (text)file just type:</p> <pre> <code> &lt; sometextfile.txt </code></pre> <h2>History search</h2> <p>Most bash-user know "<strong>&lt;STRG&gt;+&lt;r&gt;</strong>" for recursively search the history.&nbsp; If you want to search the history for a command you can use the <strong>&lt;UP&gt;</strong> key.&nbsp; Let's assume we are looking for one of our last ssh commands, then we can simply type<code> <em>ssh &lt;UP&gt;</em> </code></p> <h2 id="tab-completion-on-cd">Tab completion</h2> <h3>Autocomplete cd</h3> <p>One of the cool things in zsh is tab completion. If you type "cd <strong>&lt;TAB&gt;</strong>" it looks like this:</p> <p><img alt="" src="/sites/tech.feedyourhead.at/files/pictures/zsh_tab_complete.png" style="width: 871px; height: 130px;" /></p> <p>You can navigate using <strong>&lt;TAB&gt;</strong> or any <strong>&lt;ARROW-KEY&gt;</strong> through this menu, or just type the first letter of one directory and press <strong>&lt;TAB&gt;</strong> again...</p> <h3>Smart completion of a path</h3> <p>You can also shortcut a path. Let's assume you have a path like this:</p> <pre> <code> arch/openrisc/kernel </code></pre> <p>Then you can just type:</p> <pre> <code> a/o/k<tab> </tab></code></pre> <p>..hit <strong>&lt;TAB&gt;</strong> and zsh will autocomplete your command, or ask you if there are more than one directories with the same letter.</p> <h3>Autocomplete commands</h3> <p>Zsh can even autocomplete commands and command-line-arguments. Autocompletion is highly configurable but also quite complex. I would recommend to use <a href="http://ohmyz.sh/">oh-my-zsh</a> for this.</p> <p>Some Command-completes I really like are:</p> <ul> <li>This comes with oh-my-zsh: <em>git &lt;TAB&gt;</em>&nbsp; or <em>git co&lt;TAB&gt;</em></li> <li>Get a list of your /etc/hosts: <em>ssh root@&lt;TAB&gt;</em></li> <li>Get a list of arguments of vim: <em>vim -&lt;TAB&gt;</em></li> <li>Get a list of processes to kill: <em>kill &lt;TAB&gt;</em></li> </ul> <h2>Sophisticated Globbing</h2> <p>Globbing means searching files in your filesystem by using wildcards. This will search in your working directory and execute ls with all files(and directories) beginning with z :</p> <pre> <code> ➜ Documentation ls z* zorro.txt zh_CN: arm filesystems magic-number.txt stable_kernel_rules.txt arm64 gpio.txt oops-tracing.txt SubmittingDrivers basic_profiling.txt HOWTO SecurityBugs SubmittingPatches CodingStyle io_ordering.txt sparse.txt video4linux email-clients.txt IRQ.txt stable_api_nonsense.txt volatile-considered-harmful.txt </code></pre> <p>With zsh you can also glob recursively</p> <pre> <code> ➜ linux-4.2.4 ls **/*.pl arch/arm/crypto/bsaes-armv7.pl arch/arm/crypto/sha256-armv4.pl arch/arm/crypto/sha512-armv4.pl Documentation/filesystems/cifs/winucase_convert.pl Documentation/trace/postprocess/trace-pagealloc-postprocess.pl Documentation/trace/postprocess/trace-vmscan-postprocess.pl Documentation/video4linux/extract_xc3028.pl drivers/crypto/vmx/aesp8-ppc.pl drivers/crypto/vmx/ghashp8-ppc.pl drivers/crypto/vmx/ppc-xlate.pl drivers/scsi/script_asm.pl drivers/usb/serial/ezusb_convert.pl scripts/bootgraph.pl scripts/checkincludes.pl scripts/checkpatch.pl scripts/checkstack.pl scripts/checkversion.pl scripts/export_report.pl scripts/get_maintainer.pl scripts/headerdep.pl scripts/headers_check.pl scripts/kconfig/streamline_config.pl scripts/markup_oops.pl scripts/namespace.pl scripts/profile2linkerlist.pl scripts/recordmcount.pl tools/perf/scripts/perl/check-perf-trace.pl tools/perf/scripts/perl/failed-syscalls.pl tools/perf/scripts/perl/rw-by-file.pl tools/perf/scripts/perl/rw-by-pid.pl tools/perf/scripts/perl/rwtop.pl tools/perf/scripts/perl/wakeup-latency.pl tools/testing/ktest/compare-ktest-sample.pl tools/testing/ktest/ktest.pl </code></pre> <h3>Replace find</h3> <p>Sometimes we need to find some files and execute commands using the search-results as arguments. For example find all files with permissions 444 and move them to /tmp:</p> <pre> <code> find . -perm -444 -exec mv {} /tmp \; </code></pre> <p>We can do this in zsh using the following command:</p> <pre> <code> mv **/*(rAR) /tmp </code></pre> <p>r means "u+r", A means "g+r" and R means "o+r".</p> <p>Finding files owned by root:</p> <pre> <code> ls **/*(u:root:) </code></pre> <p>Finding files owned by root and with user-executable set:</p> <pre> <code>ls -l **/*(u:root:x) </code></pre> <p>A complete list of available expansion-commands can be found in the manual page:</p> <pre> <code> man zshexpn </code></pre> <h2>Scripting</h2> <p>Zsh has lots of modules which can be loaded, it supports arrays and has lots of nice builtin features. A good point to get some overview are <a href="http://grml.org/zsh/zsh-lovers.html">zsh-lovers</a>.</p> <h2>Make&nbsp; zsh bash-compatible</h2> <p>By default zsh is not compatible with bash. if you need it bash-compatible just type:</p> <pre> <code> emulate sh </code></pre> <h2>Builtin Tetris</h2> <p>Last but not least: zsh has it's builtin tetris!!! Type the following commands:</p> <pre> <code> autoload -U tetris zle -N tetris bindkey ^h tetris </code></pre> <p>.. and hit <ctrl>&lt;CTRL&gt;+h</ctrl></p> <h2>Conclusion</h2> <p>Zsh is fully customizable and very handy. Whenever I open its manual pages, i'll find new cool features. Zsh improves my workflows, that's why I love using it.&nbsp;</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">Oct 25 2015</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/ruleofthree" hreflang="en">RuleOfThree</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/urxvt" hreflang="en">urxvt</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/terminalemulator" hreflang="en">TerminalEmulator</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/zsh" hreflang="en">Zsh</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/bash" hreflang="en">Bash</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=124&amp;2=comment&amp;3=comment" token="nJC6mOX0qsDV806ohRO6NLteDJ1Aoc5Dvj1HDKy6_Gc"></drupal-render-placeholder> </section> Sun, 25 Oct 2015 11:48:27 +0000 Hoti 124 at https://tech.feedyourhead.at 10 Amazing and Mysterious Uses of (!) Symbol or Operator in Linux Commands https://tech.feedyourhead.at/content/10-amazing-and-mysterious-uses-symbol-or-operator-linux-commands <span class="field field--name-title field--type-string field--label-hidden">10 Amazing and Mysterious Uses of (!) Symbol or Operator in Linux Commands</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p><a href="http://www.tecmint.com/mysterious-uses-of-symbol-or-operator-in-linux-commands/">http://www.tecmint.com/mysterious-uses-of-symbol-or-operator-in-linux-commands/</a></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">May 16 2015</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/sysadmin" hreflang="en">Sysadmin</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/bash" hreflang="en">Bash</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=84&amp;2=comment&amp;3=comment" token="TY48bZaXHfK9b3vGwT4RfY_d7CDV_gVnCluZkMvLzN4"></drupal-render-placeholder> </section> Sat, 16 May 2015 08:46:34 +0000 Hoti 84 at https://tech.feedyourhead.at Find out the differences between to directories https://tech.feedyourhead.at/content/find-out-differences-between-directories <span class="field field--name-title field--type-string field--label-hidden">Find out the differences between to directories</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Sometimes it is useful to compare to directories and display the differences. diff can do the trick for you</p> <pre> <code> diff -r dir1/ dir2/ </code></pre> <p>If you just want a overview about the differences then just use "brief":</p> <pre> <code> diff --brief -r dir1/ dir2/ </code></pre> <p>git can show you the differences too, and it can do it colorful if you want</p> <pre> <code> git diff dir1/ dir2/ </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">Jan 04 2015</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/one-liner" hreflang="en">One-Liner</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/sysadmin" hreflang="en">Sysadmin</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/git" hreflang="en">git</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=32&amp;2=comment&amp;3=comment" token="cBy-k65ZpSZzYuUeFvRtIUCCtXu8GaU6qLNQDMe_kRI"></drupal-render-placeholder> </section> Sun, 04 Jan 2015 10:15:45 +0000 Hoti 32 at https://tech.feedyourhead.at List disk-usage of files and directories https://tech.feedyourhead.at/content/list-disk-usage-files-and-directories <span class="field field--name-title field--type-string field--label-hidden">List disk-usage of files and directories</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><pre><code> dr@tardis> for i in `ls -d *`; do du -hs $i; done 4,0K cron-job.txt 48K etc 4,0K install.sh 4,0K README.Debian.TXT 4,0K README.TXT 16K usr </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 24 2014</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="/tags/bash" hreflang="en">Bash</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/one-liner" hreflang="en">One-Liner</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=19&amp;2=comment&amp;3=comment" token="qxWv4qHZP5DVri8yNHVDOGyFO3855_xVgGs6v6Fkg1I"></drupal-render-placeholder> </section> Mon, 24 Nov 2014 13:26:59 +0000 Hoti 19 at https://tech.feedyourhead.at Converting UNIX-Timestamp into a readable time-format https://tech.feedyourhead.at/content/converting-unix-timestamp-readable-time-format <span class="field field--name-title field--type-string field--label-hidden">Converting UNIX-Timestamp into a readable time-format</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Assume we have a nagios-logfile(nagios.log) like this:</p> <pre> <code> [1416415259] PASSIVE HOST CHECK: server1;0;PING OK - Packet loss = 0%, RTA = 0.04 ms [1416415259] PASSIVE HOST CHECK: server2;0;PING OK - Packet loss = 0%, RTA = 0.04 ms [1416415259] EXTERNAL COMMAND: PROCESS_HOST_CHECK_RESULT;server3;0;PING OK - Packet loss = 0%, RTA = 0.15 ms </code></pre> <p>Then we can convert the UNIX-Timestamp using the following command:</p> <pre> <code> perl -n -e 'if ($_ =~ m/^\[(\d+)\] (.*)$/g){ print scalar localtime($1) . " $2" ."\n"; }' nagios.log </code></pre> <p>This would be our output then:</p> <pre> <code> Wed Nov 19 17:40:59 2014 PASSIVE HOST CHECK: server1;0;PING OK - Packet loss = 0%, RTA = 0.04 ms Wed Nov 19 17:40:59 2014 PASSIVE HOST CHECK: server2;0;PING OK - Packet loss = 0%, RTA = 0.04 ms Wed Nov 19 17:40:59 2014 EXTERNAL COMMAND: PROCESS_HOST_CHECK_RESULT;server3;0;PING OK - Packet loss = 0%, RTA = 0.15 ms </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 19 2014</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="/Nagios" hreflang="en">Nagios</a></div> <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/bash" hreflang="en">Bash</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/perl" hreflang="en">Perl</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=16&amp;2=comment&amp;3=comment" token="EB6QcaYCufqwNDXs6N9Q8dAWj4FsozjpCPYWAbAx0pc"></drupal-render-placeholder> </section> Wed, 19 Nov 2014 16:45:34 +0000 Hoti 16 at https://tech.feedyourhead.at