<?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>SoftLayer Blog &#187; bash</title>
	<atom:link href="http://blog.softlayer.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.softlayer.com</link>
	<description>A Behind the Scenes Look at the Best Hosting Provider in the World</description>
	<lastBuildDate>Fri, 24 May 2013 18:19:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>UNIX Sysadmin Boot Camp: bash &#8211; Keyboard Shortcuts</title>
		<link>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash-keyboard-shortcuts/</link>
		<comments>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash-keyboard-shortcuts/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 15:50:17 +0000</pubDate>
		<dc:creator>Ryan Robson</dc:creator>
				<category><![CDATA[Customer Service]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[boot camp]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[excute]]></category>
		<category><![CDATA[keyboard shortcut]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shortcut]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=6476</guid>
		<description><![CDATA[On the support team, we&#8217;re jumping in and out of shells constantly. At any time during my work day, I&#8217;ll see at least four instances of PuTTY in my task bar, so one thing I learned quickly was that efficiency and accuracy in accessing ultimately make life easier for our customers and for us as [...]]]></description>
			<content:encoded><![CDATA[<p>On the support team, we&#8217;re jumping in and out of shells constantly. At any time during my work day, I&#8217;ll see at least four instances of <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY</a> in my task bar, so one thing I learned quickly was that efficiency and accuracy in accessing ultimately make life easier for our customers and for us as well. Spending too much time rewriting paths, commands, VI navigation, and history cycling can really bring you to a crawl. So now that you have had some time to study <a href="http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash/">bash</a> and practice a little, I thought I&#8217;d share some of the keyboard shortcuts that help us work as effectively and as expediently as we do. I won&#8217;t be able to cover <em>all</em> of the shortcuts, but these are the ones I use most:</p>
<h3>Tab</h3>
<p style="margin-top:0; padding-top: 0;">[Tab] is one of the first keyboard shortcuts that most people learn, and it&#8217;s ever-so-convenient. Let&#8217;s say you just downloaded <code>pckg54andahalf-5.2.17-v54-2-x86-686-Debian.tar.gz</code>, but a quick listing of the directory shows you ALSO downloaded <code>5.1.11</code>, <code>4.8.6</code> and <code>1.2.3</code> at some point in the past. What was that file name again? Fret not. You know you downloaded 5.2.<em>something</em>, so you just start with, say, <code>pckg</code>, and hit [Tab]. This autocompletes everything that it can match to a unique file name, so if there are no other files that start with &#8220;<code>pckg</code>,&#8221; it will populate the whole file name (and this can occur at any point in a command).</p>
<p>In this case, we&#8217;ve got <em>four</em> different files that are similar:<br />
<code style="background-color:yellow;">pckg54andahalf-5.2.17-v54-2-x86-686-Debian.tar.gz</code> <-- we want this one<br />
<code style="background-color:gray;">pckg54andahalf-5.1.11-v54-2-x86-686-Debian.tar.gz</code><br />
<code style="background-color:gray;">pckg54andahalf-4.8.6-v54-2-x86-686-Debian.tar.gz</code><br />
<code style="background-color:gray;">pckg54andahalf-1.2.3-v54-2-x86-686-Debian.tar.gz</code></p>
<p>So typing "<code>pckg</code>" and hitting [Tab] brings up:<br />
<code>pckg54andahalf-</code></p>
<p><em>NOW</em>, what you could do, knowing what files are there already, is type "<code>5.2</code>" and hit [Tab] again to fill out the rest. However, if you <em>didn't</em> know what the potential matches were, you could <strong>double-tap [Tab]</strong>. This displays all matching file names with that string.</p>
<p>Another fun fact: This trick also works in Windows. <img src='http://blog.softlayer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>CTRL+R</h3>
<p style="margin-top:0; padding-top: 0;">[CTRL+R] is a very underrated shortcut in my humble opinion. When you've been working in the shell for untold hours parsing logs, moving files and editing configs, your bash history can get pretty immense. Often you'll come across a situation where you want to reproduce a command or series of commands that were run regarding a specific file or circumstance. You <em>could</em> type "<code>history</code>" and pore through the commands line by line, but I propose something more efficient: a reverse search.</p>
<p>Example: I've just hopped on my system and discovered that my SVN server isn't doing what it's supposed to. I want to take a look at any SVN related commands that were executed from bash, so I can make sure there were no errors. I'd simply hit [CTRL+R], which would pull up the following prompt:</p>
<p><code>(reverse-i-search)`':</code></p>
<p>Typing "<code>s</code>" at this point would immediately return the first command with the letter "<code>s</code>" in it in the history ... Keep in mind that's not just <em>starting</em> with s, it's <em>containing</em> an s. Finishing that out to "<code>svn</code>" brings up any command executed with those letters in that order. Pressing [CTRL+R] again at this point will cycle through the commands one by one.</p>
<p>In the search, I find the command that was run incorrectly ... There was a typo in it. I can edit the command <em>within</em> the search prompt before hitting enter and committing it to the command prompt. Pretty handy, right? This can quickly become one of your most used shortcuts.</p>
<h3>CTRL+W &#038; CTRL+Y</h3>
<p style="margin-top:0; padding-top: 0;">This pair of shortcuts is the one I find myself using the most. [CTRL+W] will basically take the word before your cursor and "cut" it, just like you would with [CTRL+X] in Windows if you highlighted a word. A "word" doesn't really describe what it cuts in bash, though ... It uses whitespace as a delimiter, so if you have an ultra long file path that you'll probably be using multiple times down the road, you can [CTRL+W] that sucker and keep it stowed away.</p>
<p>Example: I'm typing <code>nano /etc/httpd/conf/httpd.conf</code> (Related: The redundancy of this path always irked me just a little).<br />
Before hitting [ENTER] I tap [CTRL+W], which chops that path right back out and stores it to memory. Because I want to run that command right now as well, I hit [CTRL+Y] to <em>paste</em> it back into the line. When I'm done with that and I'm out referencing other logs or doing work on other files and need to come back to it, I can simply type "<code>nano </code>" and hit [CTRL+Y] to go right back into that file.</p>
<h3>CTRL+C</h3>
<p style="margin-top:0; padding-top: 0;">For the sake of covering most of my bases, I want to make sure that [CTRL+C] is covered. Not only is it useful, but it's absolutely essential for standard shell usage. This little shortcut performs the most invaluable act of killing whatever process you were running at that point. This can go for most anything, aside from the programs that have their own interfaces and kill commands (vi, nano, etc). If you start something, there's a pretty good chance you're going to want to stop it eventually.</p>
<p>I should be clear that this will terminate a process unless that process is otherwise instructed to trap [CTRL+C] and perform a different function. If you're compiling something or running a database command, generally you won't want to use this shortcut unless you know what you're doing. But, when it comes to everyday usage such as running a "<code>top</code>" and then quitting, it's essential.</p>
<h3>Repeating a Command</h3>
<p style="margin-top:0; padding-top: 0;">There are four simple ways you can easily repeat a command with a keyboard shortcut, so I thought I'd run through them here before wrapping up:</p>
<ol>
<li>The [UP] arrow will display the previously executed command.</li>
<li>[CTRL+P] will do the exact same thing as the [UP] arrow.</li>
<li>Typing "<code>!!</code>" and hitting [Enter] will execute the previous command. <em>Note that this actually runs it. The previous two options only display the command, giving you the option to hit [ENTER].</em></li>
<li>Typing "<code>!-1</code>" will do the same thing as "<code>!!</code>", though I want to point out how it does this: When you type "<code>history</code>", you see a numbered list of commands executed in the past <code>-1</code> being the most recent. What "<code>!-1</code>" does is instructs the shell to execute (<code>!</code>) the first item on the history (<code>-1</code>). This same concept can be applied for any command in the history at all ... This can be useful for scripting.</li>
</ol>
<h3>Start Practicing</h3>
<p style="margin-top:0; padding-top: 0;">What it really comes down to is finding what works for you and what suits your work style. There are a number of other shortcuts that are definitely worthwhile to take a look at. There are plenty of cheat sheets on the internet available to print out while you're learning, and I'd highly recommend checking them out. Trust me on this: You'll never regret honing your mastery of bash shortcuts, particularly once you've seen the lightning speed at which you start flying through the command line. The tedium goes away, and the shell becomes a much more friendly, dare I say <em>inviting</em>, place to be.</p>
<p style="margin-bottom:0; padding-bottom:0;"><strong>Quick reference for these shortcuts:</strong></p>
<ul style="margin-top:0; padding-top:0;">
<li><strong>[TAB]</strong> - Autocomplete to furthest point in a unique matching file name or path.</li>
<li><strong>[CTRL+R]</strong> - Reverse search through your bash history</li>
<li><strong>[CTRL+W]</strong> - Cut one "word" back, or until whitespace encountered.</li>
<li><strong>[CTRL+Y]</strong> - Paste a previously cut string</li>
<li><strong>[CTRL+P]</strong> - Display previously run command</li>
<li><strong>[UP]</strong> - Display previously run command</li>
</ul>
<p>-Ryan</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash-keyboard-shortcuts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>UNIX Sysadmin Boot Camp: bash</title>
		<link>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash/</link>
		<comments>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 18:00:49 +0000</pubDate>
		<dc:creator>Ryan Robson</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[boot camp]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[control panel]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=4508</guid>
		<description><![CDATA[Welcome back to UNIX Sysadmin Boot Camp. You&#8217;ve had a few days to get some reps in accessing your server via SSH, so it&#8217;s about time we add some weight to your exercise by teaching you some of the tools you will be using regularly to manage your server. As we mentioned earlier in this [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome back to UNIX Sysadmin Boot Camp. You&#8217;ve had a few days to get some reps in <a href="http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-an-intro-to-ssh/">accessing your server via SSH</a>, so it&#8217;s about time we add some weight to your exercise by teaching you some of the tools you will be using regularly to manage your server.</p>
<p>As we mentioned earlier in this series, customers with control panels from cPanel and Parallels might be tempted to rely solely on those graphical interfaces. They are much more user-friendly in terms of performing routine server administration tasks, but at some point, you might need to get down and dirty on the command line. It&#8217;s almost inevitable. This is where you&#8217;ll use <strong>bash</strong> commands.  </p>
<p>Here are some of the top 10 essential commands you should get to know and remember in bash. <em>Click any of the commands to go to its official &#8220;manual&#8221; page.</em></p>
<ol>
<li><a href="http://linuxmanpages.com/man1/man.1.php"><code>man</code></a> &ndash; This command provides a manual of other bash commands. Want more info on a command? Type <code>man commandname</code>, and you&#8217;ll get more information about &#8220;commandname&#8221; than you probably wanted to know. It&#8217;s extremely useful if you need a quick reference for a command, and it&#8217;s often much more detailed and readable than a simple <code>--help</code> or <code>--h</code> extension.</li>
<li><a href="http://www.computerhope.com/unix/uls.htm"><code>ls</code></a> &ndash; This command lets you list results. I showed you an example of this above, but the amount of options that are available to you with this command are worth looking into. Using the &#8220;manual&#8221; command above, run <code>man ls</code> and check out the possibilities. For example, if you&#8217;re in <code>/etc</code>, running <code>ls -l /etc</code> will get you a slightly more detailed list. My most commonly used list command is <code>ls -hal</code>. Pop quiz for you (where you can test your <code>man</code> skills): What does the <code>-hal</code> mean?</li>
<li><a href="http://www.computerhope.com/unix/ucd.htm"><code>cd</code></a> &ndash; This command lets you change directories. Want to go to <code>/etc/</code>? <code>cd /etc/</code> will take you there. Want to jump back a directory? <code>cd ..</code> does the trick.</li>
<li><a href="http://www.computerhope.com/unix/umv.htm"><code>mv</code></a> &ndash; This command enables you to move files and folders. The syntax is <code>mv originalpath/to/file newpath/to/file</code>. Simple! There are more options that you can check out with the <code>man</code> command.</li>
<li><a href="http://www.computerhope.com/unix/urm.htm"><code>rm</code></a> &ndash; This command enables you to remove a file or directory. In the same vein as the <code>mv</code> command, this is one of those basic commands that you just have to know. By running <code>rm filename</code>, you remove the &#8220;filename&#8221; file.</li>
<li><a href="http://www.computerhope.com/unix/ucp.htm"><code>cp</code></a> &ndash; This command enables you to copy files from one place to another. Want to make a backup of a file before editing it? Run <code>cp origfile.bla origfile.bak</code>, and you have a backup in case your edit of <code>origfile.bla</code> goes horrendously wrong and makes babies cry. The syntax is simply: <code>cp /source /destination</code>. As with the above commands, check out the manual by running <code>man cp</code> for more options.</li>
<li><a href="http://linuxmanpages.com/man1/tar.1.php"><code>tar</code></a> &ndash; On its own, <code>tar</code> is a command to group a bunch of files together, uncompressed. These files can then be compressed into .gzip format. The command can be used for creating or extracting, so it may be a good idea to familiarize yourself with the parameters, as you may find yourself using it quite often. For a GUI equivalent, think 7-zip or WinRAR for Windows.</li>
<li><a href="http://linuxmanpages.com/man1/wget.1.php"><code>wget</code></a> &ndash; I love the simplicity of this little command. It enables you to &#8220;get&#8221; or download a target file. Yes, there are options, but all you need is a direct link to a file, and you just pull one of these: <code>wget urlhere</code>. Bam! That file starts downloading. Doesn&#8217;t matter what kind of file it is, it&#8217;s downloaded.</li>
<li><a href="http://linuxmanpages.com/man1/top.1.php"><code>top</code></a> &ndash; This handy little binary will give you a live view of memory and CPU usage currently affecting your machine, and is useful for finding out where you need to optimize. It can also help you pinpoint what processes may be causing a slowdown or a load issue.</li>
<li><a href="http://linuxmanpages.com/man1/chmod.1.php"><code>chmod</code></a> &ndash; This little sucker is vital to make your server both secure and usable, particularly when you&#8217;re going to be serving for the public like you would with a web server. Combine good usage of permission and iptables, and you have a locked down server</li>
</ol>
<p>When you understand how to use these tools, you can start to monitor and track what&#8217;s actually happening on your server. The more you know about your server, the more effective and efficient you can make it. In our next installment, we&#8217;ll touch on some of the most common server logs and what you can do with the information they provide.</p>
<p>Did I miss any of your &#8220;essential&#8221; bash commands in my top 10 list? Leave a comment below with your favorites along with a quick explanation of what they do.</p>
<p>-Ryan</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
