<?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; alias</title>
	<atom:link href="http://zinformatik.de/tag/alias/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>Praktische alias-Kommandos für die Bash</title>
		<link>http://zinformatik.de/linux/praktische-alias-kommandos-fur-die-bash/</link>
		<comments>http://zinformatik.de/linux/praktische-alias-kommandos-fur-die-bash/#comments</comments>
		<pubDate>Sun, 17 May 2009 17:14:12 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntuusers-Planet]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Konsole]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=1235</guid>
		<description><![CDATA[<p>Sehr praktisch bei der Bash ist die Möglichkeit sich alias-Befehle zu konfigurieren. Damit kann man bestehende Befehle überschreiben oder Abkürzungen hinzufügen. Ich habe mal einige praktische alias-Kommandos zusammen gestellt. Es wären natürlich noch viel mehr denkbar, aber vielleicht regen die hier genannten ja beim einen oder anderen die Phantasie an.</p>
<p>Übrigens kann man die &#8220;Ursprungsversion&#8221; eines Kommandos, welches durch einen&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Sehr praktisch bei der Bash ist die Möglichkeit sich alias-Befehle zu konfigurieren. Damit kann man bestehende Befehle überschreiben oder Abkürzungen hinzufügen. Ich habe mal einige praktische alias-Kommandos zusammen gestellt. Es wären natürlich noch viel mehr denkbar, aber vielleicht regen die hier genannten ja beim einen oder anderen die Phantasie an.</p>
<p>Übrigens kann man die &#8220;Ursprungsversion&#8221; eines Kommandos, welches durch einen Alias überschrieben wurde durch ein Vorrangestelltes <em>\</em> aufrufen. Also wenn es z.B. folgenden alias gibt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ls</span>=<span style="color: #ff0000;">&quot;ls --color=auto&quot;</span></pre></div></div>

<p>so kann man durch die Eingabe von</p>

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

<p>den Befehl <em>ls</em> ohne <em>&#8211;color=auto</em> aufrufen.</p>
<p><strong>Grundlegende Kommandos im Dateisystem</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Macht die Ausgabe von ls farbig:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ls</span>=<span style="color: #ff0000;">'ls --color=auto'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Gibt zu jeder Datei weitere Informationen aus. Größenangaben immer &quot;menschenlich lesbar&quot;:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ll</span>=<span style="color: #ff0000;">'ls -lh'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Wie ll, aber es werden auch versteckte Dateien aufgelistet:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">la</span>=<span style="color: #ff0000;">'ls -lha'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Für Vertipper recht praktisch:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> cd..=<span style="color: #ff0000;">'cd ..'</span> 
<span style="color: #7a0874; font-weight: bold;">alias</span> cd-=<span style="color: #ff0000;">'cd -'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Abkürzung für cd .. :</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> ..=<span style="color: #ff0000;">'cd ..'</span> 
<span style="color: #7a0874; font-weight: bold;">alias</span> ...=<span style="color: #ff0000;">'cd ../..'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Alle nicht existierenden Verzeichnisse automatisch erstellen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mkdir</span>=<span style="color: #ff0000;">'mkdir -p'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Für Anfänger zu empfehlen (es wird bei jeder Datei nachgefragt)</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">rm</span>=<span style="color: #ff0000;">'rm -i'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">cp</span>=<span style="color: #ff0000;">'cp -i'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mv</span>=<span style="color: #ff0000;">'mv -i'</span></pre></div></div>

<p><strong>Befehle die immer mit bestimmten Optionen ausgeführt werden sollen sowie Abkürzungen</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Bei df die Größen immer &quot;menschlich lesbar&quot; anzeigen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">df</span>=<span style="color: #ff0000;">'df -h'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Bei du die Größen immer &quot;menschlich lesbar&quot; anzeigen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">du</span>=<span style="color: #ff0000;">'du -h'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Suche in less case-insensitive:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">l</span>=<span style="color: #ff0000;">'less -i'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Zeigt Änderungen einer Datei an (wie tail -f):</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lf</span>=<span style="color: #ff0000;">'less -i +F'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Beispielhafte Abkürzung für ssh</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">meinserver</span>=<span style="color: #ff0000;">'ssh user@meinserver.tld'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># lässt grep case-insensitive arbeiten und markiert die Treffer farbig:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">grep</span>=<span style="color: #ff0000;">'grep -i --color=auto'</span></pre></div></div>

<p>Die Follow-Option von <em>less</em> (<em>less +F</em>) ist recht praktisch, da sie einfach mit Strg+c unterbrochen und mit F weitergeführt werden kann. So kann man leicht nochmal zurück scrollen.</p>
<p><strong>Befehle zum Suchen, Installieren und Updaten</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Da apt-get ja meist mit sudo aufgerufen wird:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> apt-get=<span style="color: #ff0000;">'sudo apt-get'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">#Statt dessen kann man auch die folgenden Befehle nutzen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">agi</span>=<span style="color: #ff0000;">'sudo apt-get install'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">acs</span>=<span style="color: #ff0000;">'apt-cache search'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Das ganze System updaten:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">update</span>=<span style="color: #ff0000;">'sudo apt-get update &amp;&amp; sudo apt-get upgrade'</span></pre></div></div>

<p><strong>Komplexere Befehle</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Starte Kommando in neuem Screen-Fenster:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">s</span>=<span style="color: #ff0000;">'screen -X screen'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Dateinamen im aktuellen Verzeichnis nach Ausdruck durchsuchen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lg</span>=<span style="color: #ff0000;">'ls --color=always | grep --color=always -i'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Timestamp generieren:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">timestamp</span>=<span style="color: #ff0000;">'date &quot;+%Y%m%d%H%M%S&quot;'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Verzeichnis mit aktuellem Timestamp erstellen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">tsdir</span>=<span style="color: #ff0000;">'timestamp | xargs mkdir'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Änderungen bei allen angegebenen Logdateien live anzeigen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mylogs</span>=<span style="color: #ff0000;">'sudo tail -f /var/log/{syslog,messages}'</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Einen Prozess (nach Namen) suchen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">psg</span>=<span style="color: #ff0000;">'ps ax | grep -v grep | grep '</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Die öffentliche IP ausgeben:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">myip</span>=<span style="color: #ff0000;">&quot;wget -qO - http://checkip.dyndns.org | sed 's/[a-zA-Z&lt;&gt;/ :]//g'&quot;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Zuletzt bearbeitete Datei in vim öffnen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">lvim</span>=<span style="color: #ff0000;">&quot;vim -c <span style="color: #000099; font-weight: bold;">\&quot;</span>normal '0<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Die 10 Prozesse anzeigen, die den meisten RAM verbrauchen:</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">psram</span>=<span style="color: #ff0000;">'ps aux | sort -rnk 4 | head'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Zeige alle Prozesse bei ps (außer ps selbst) mit langer Ausgabe</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ps</span>=<span style="color: #ff0000;">'ps ax | grep -v &quot;ps ax&quot;'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/linux/praktische-alias-kommandos-fur-die-bash/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

