<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>zInformatik &#187; commandlinefu</title>
	<atom:link href="http://zinformatik.de/tag/commandlinefu/feed/" rel="self" type="application/rss+xml" />
	<link>http://zinformatik.de</link>
	<description>Computer, Informatik und Mikrocontroller Blog</description>
	<lastBuildDate>Sat, 22 Oct 2011 09:51:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>commandlinefu &#8211; die besten Einzeiler auf der Konsole</title>
		<link>http://zinformatik.de/linux/commandlinefu-die-besten-einzeiler-auf-der-konsole/</link>
		<comments>http://zinformatik.de/linux/commandlinefu-die-besten-einzeiler-auf-der-konsole/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 21:05:14 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Webseiten]]></category>
		<category><![CDATA[commandlinefu]]></category>
		<category><![CDATA[Konsole]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=988</guid>
		<description><![CDATA[<p>Auf der Seite <a href="http://commandlinefu.com" title="commandlinefu" target="_blank" class="liexternal">http://commandlinefu.com</a> (englisch) werden einzeilige Kommandos (bzw. Kommandoketten) für die Shell und häufige Programme (vim, mysql, screen,&#8230;) gesammelt.</p>
<p>Dort gibt es so ziemlich Alles vom kurzen</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> -</pre></div></div>

<p>mit dem man zum letzten Verzeichnis wechselt bis zu recht langen und komplizierten Kommandos wie</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'/sshd/ &#38;&#38; /Failed/ {gsub(/invalid user/,&#34;&#34;); printf</span></pre></div></div><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Auf der Seite <a href="http://commandlinefu.com" title="commandlinefu" target="_blank" class="liexternal">http://commandlinefu.com</a> (englisch) werden einzeilige Kommandos (bzw. Kommandoketten) für die Shell und häufige Programme (vim, mysql, screen,&#8230;) gesammelt.</p>
<p>Dort gibt es so ziemlich Alles vom kurzen</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> -</pre></div></div>

<p>mit dem man zum letzten Verzeichnis wechselt bis zu recht langen und komplizierten Kommandos wie</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'/sshd/ &amp;&amp; /Failed/ {gsub(/invalid user/,&quot;&quot;); printf &quot;%-12s %-16s %s-%s-%s\n&quot;, $9, $11, $1, $2, $3}'</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>auth.log</pre></div></div>

<p>mit dem man sich die Usernamen, IP-Adressen und Zeiten von fehlgeschlagenen SSH-Zugriffen anzeigen lassen kann.</p>
<p>Bei solch komplexen Befehlen ist es praktisch, sie sich als Script zu speichern:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;!!&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>my<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>script.sh</pre></div></div>

<p>speichert den letzten ausgeführten Befehl in die Datei script.sh im Verzeichnis /path/to/my/bin<br />
Mit &lt;Alt&gt;+.  lässt sich das letzte Argument in den nächsten Befehl einfügen, so dass</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">&lt;</span>Alt<span style="color: #000000; font-weight: bold;">&gt;</span>+.</pre></div></div>

<p>zu</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>my<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>script.sh</pre></div></div>

<p>wird und man so das erstellte Script auch direkt ausführbar machen kann. Ich habe mir ein eigenes bin Verzeichnis in meinem Homeverzeichnis erstellt und es in der .bashrc zu $PATH hinzugefügt. Also einfach folgende Zeile hinzufügen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

<p>Weitere praktische Kommandos sind</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> filename<span style="color: #7a0874; font-weight: bold;">&#123;</span>,.bak<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>um ein Backup einer Datei anzulegen oder</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">!!</span></pre></div></div>

<p>was das letzte Kommando mit sudo ausführt, falls man dies beim ersten mal vergessen hat. (Wie man sieht steht !! für das letzte Kommando)</p>
<p>Mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-nrk</span> <span style="color: #000000;">4</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span></pre></div></div>

<p>kann man sich die laufenden Prozesse sortiert nach ihrem Speicherverbrauch anzeigen lassen.</p>
<p>Ziemlich praktisch ist auch</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> - <span style="color: #ff0000;">&quot;http://www.tarball.com/tarball.gz&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf -</pre></div></div>

<p>mit dem man eine .tar.gz Datei herunterladen und gleichzeitig entpacken kann ohne die Datei speichern zu müssen.</p>
<p>Auf der Seite gibt es noch haufenweise andere solch praktische Einzeiler. Natürlich sind auch einige dabei die nicht so sehr viel Sinn ergeben, aber dafür kann jeder ein Kommando bewerten und kommentieren. Man kann auch suchen sowie Tags nutzen. Zusätzlich werden automatisch alle verwendeten Funktionen in einer extra Tagcloud aufbereitet, so dass man auch Kommandos findet die nicht oder schlecht getagt sind.<br />
Somit ist die Seite wunderbar zum Stöbern, aber auch zum gezielten Suchen von Befehlen geeignet.</p>
<p>Also los, trainiere Dein Commandline-Fu <img src='http://zinformatik.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/linux/commandlinefu-die-besten-einzeiler-auf-der-konsole/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

