<?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>#!SUITS &#187; unix</title>
	<atom:link href="http://suits.it.usyd.edu.au/wordpress/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://suits.it.usyd.edu.au/wordpress</link>
	<description>Sydney University IT Society</description>
	<lastBuildDate>Sun, 18 Oct 2009 14:50:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mounting SIT home drives on Linux</title>
		<link>http://suits.it.usyd.edu.au/wordpress/2009/03/30/mounting-sit-home-drives-on-linux/</link>
		<comments>http://suits.it.usyd.edu.au/wordpress/2009/03/30/mounting-sit-home-drives-on-linux/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 22:39:22 +0000</pubDate>
		<dc:creator>tim.dawborn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[SIT]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://suits.it.usyd.edu.au/wordpress/?p=560</guid>
		<description><![CDATA[
Assuming you are on the SIT network, you are able to mount your SIT home drive locally using SAMBA.

sudo mount -t cifs -o user=abcd9999,servern=ITCASESEC,uid=foo,gid=1001 //itcasesec/abcd9999 /mnt/abcd9999

where your SIT username is &#8220;abcd9999&#8243;, your local username is &#8220;foo&#8221;, and the GID of &#8220;foo&#8221; is &#8220;1001&#8243;. The folder /mnt/abcd999 should already exist (or change it to where ever [...]]]></description>
			<content:encoded><![CDATA[<p>
Assuming you are on the SIT network, you are able to mount your SIT home drive locally using SAMBA.
</p>
<p><code>sudo mount -t cifs -o user=abcd9999,servern=ITCASESEC,uid=foo,gid=1001 //itcasesec/abcd9999 /mnt/abcd9999</code></p>
<p>
where your SIT username is &#8220;abcd9999&#8243;, your local username is &#8220;foo&#8221;, and the GID of &#8220;foo&#8221; is &#8220;1001&#8243;. The folder <code>/mnt/abcd999</code> should already exist (or change it to where ever you would like to mount the folder).</p>
]]></content:encoded>
			<wfw:commentRss>http://suits.it.usyd.edu.au/wordpress/2009/03/30/mounting-sit-home-drives-on-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tutorial: Command Line Proxy</title>
		<link>http://suits.it.usyd.edu.au/wordpress/2008/04/14/tutorial-command-line-proxy/</link>
		<comments>http://suits.it.usyd.edu.au/wordpress/2008/04/14/tutorial-command-line-proxy/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 07:36:48 +0000</pubDate>
		<dc:creator>James Bunton</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[SIT]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://suits.it.usyd.edu.au/wordpress/?p=23</guid>
		<description><![CDATA[Want to have your command line applications use the correct proxy to connect to the internet? Instructions here are applicable to Linux, OSX and other Unix systems.

Unix Environment
To use the School of IT proxies you want to set the following environment variables:
export http_proxy="http://www-cache.it.usyd.edu.au:8000"
export no_proxy="127.0.0.1, localhost, .usyd.edu.au"
sudo environment vars
sudo clears all environment variables before executing the [...]]]></description>
			<content:encoded><![CDATA[<p>Want to have your command line applications use the correct proxy to connect to the internet? Instructions here are applicable to Linux, OSX and other Unix systems.</p>
<p><span id="more-23"></span></p>
<h3>Unix Environment</h3>
<p>To use the School of IT proxies you want to set the following environment variables:<br />
<code>export http_proxy="http://www-cache.it.usyd.edu.au:8000"<br />
export no_proxy="127.0.0.1, localhost, .usyd.edu.au"</code></p>
<h3>sudo environment vars</h3>
<p>sudo clears all environment variables before executing the command for security. This means if you run something like<br />
<code>$ sudo aptitude update</code><br />
it won&#8217;t work because http_proxy gets cleared. You can fix this by doing the following. Be careful!<br />
<code>$ sudo visudo</code><br />
Add this line:</p>
<pre>Defaults env_keep="http_proxy https_proxy ftp_proxy no_proxy"</pre>
<h3>Mac OS X Location Settings</h3>
<p>If you use Mac OS X and change locations frequently it&#8217;d be nice if your command line utilities picked up the proxy settings from System Preferences.</p>
<p>Have a look at <a href="http://delx.net.au/projects/proxyconf">http://delx.net.au/projects/proxyconf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://suits.it.usyd.edu.au/wordpress/2008/04/14/tutorial-command-line-proxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: SIT Personal Webspace</title>
		<link>http://suits.it.usyd.edu.au/wordpress/2008/03/05/tutorial-sit-personal-webspace/</link>
		<comments>http://suits.it.usyd.edu.au/wordpress/2008/03/05/tutorial-sit-personal-webspace/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 07:38:06 +0000</pubDate>
		<dc:creator>tim.dawborn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[SIT]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://suits.it.usyd.edu.au/wordpress/?p=25</guid>
		<description><![CDATA[Did you know that the Usyd School of IT servers provide personal webspace for any students studying IT?
You can have your own website at a URL like http://www.ug.it.usyd.edu.au/~userXYXY

To set up your personal webspace allowed on your School of IT (SIT) account, log into a congo machine either at uni or via SSH and type the [...]]]></description>
			<content:encoded><![CDATA[<p>Did you know that the Usyd School of IT servers provide personal webspace for any students studying IT?<br />
You can have your own website at a URL like http://www.ug.it.usyd.edu.au/~userXYXY</p>
<p><span id="more-25"></span></p>
<p>To set up your personal webspace allowed on your School of IT (SIT) account, log into a congo machine either at uni or via SSH and type the following commands:</p>
<pre>$ mkdir -p ~/lib/html
$ chmod 711 ~
$ chmod -R 711 ~/lib
$ cd ~/lib/html</pre>
<p>Create your webpage in this directory (~/lib/html), say it is called <em>index.html</em>. Now to make it publicly visible on the internet, type the following:</p>
<pre>$ chmod a+r index.html</pre>
<p>Then assuming your Usyd username is <em>abcd1234</em>, open your Internet browser and go to <em>http://www.ug.it.usyd.edu.au/~abcd1234/</em></p>
]]></content:encoded>
			<wfw:commentRss>http://suits.it.usyd.edu.au/wordpress/2008/03/05/tutorial-sit-personal-webspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: Unix Fundamentals</title>
		<link>http://suits.it.usyd.edu.au/wordpress/2007/07/31/tutorial-unix/</link>
		<comments>http://suits.it.usyd.edu.au/wordpress/2007/07/31/tutorial-unix/#comments</comments>
		<pubDate>Tue, 31 Jul 2007 07:36:11 +0000</pubDate>
		<dc:creator>James Bunton</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://suits.it.usyd.edu.au/wordpress/?p=22</guid>
		<description><![CDATA[Unix is a powerful system, well worth getting to know for the productivity benefits you can obtain, and also for the experience of learning to use a new operating system. This tutorial provides an introduction to get you from no knowledge of Unix to having a basic skillset good enough for day to day tasks, [...]]]></description>
			<content:encoded><![CDATA[<p>Unix is a powerful system, well worth getting to know for the productivity benefits you can obtain, and also for the experience of learning to use a new operating system. This tutorial provides an introduction to get you from no knowledge of Unix to having a basic skillset good enough for day to day tasks, in a position for you to learn more.</p>
<p><span id="more-22"></span></p>
<h3>The Fundamentals</h3>
<p>In Unix, there is the tools philosophy. That is, there are lots of little programs that do one job, and do it well. These programs have short, often cryptic names, such as ls =&gt; list files, cp =&gt; copy. This makes them easier to type, and you&#8217;ll be typing them a lot!</p>
<p>You type these commands at a shell. The one you&#8217;ll be using is called bash, however there are others, such as tcsh or zsh. The shell gives you a prompt that will look something like this:<br />
<code>user@host:~$<br />
-bash-2.05b$</code><br />
When you see this prompt, it means the shell is ready for you to type a command. Generally when a command finishes successfully, nothing will be displayed but another prompt. For the purposes of this tutorial, we will abbreviate the prompt to simply a dollar sign: $ You can exit a shell by typing exit, logout, or pressing CTRL-D.</p>
<p>For almost all of these commands, you can specify flags, or options to modify their behaviour. For example, the &#8216;ls&#8217; command will not show hidden files by default. Hidden files are files that start with a period, eg &#8216;.bashrc&#8217;. If you specify the &#8216;-a&#8217; option, then &#8216;ls&#8217; will show these files. Eg,<br />
<code>$ ls -a</code><br />
These flags are also known as parameters, or arguments, and these terms are used interchangeably.</p>
<p>For some commands it may make sense to combine flags. In this case, you can either list them one after the other&#8230;<br />
<code>$ ls -l -a</code><br />
&#8230; or you can specify them in the same argument.<br />
<code>$ ls -la</code><br />
Unix commands may also take file or directory names as parameters. The &#8216;cat&#8217; command will print the contents of a file to the screen, it needs to be told which file to print.<br />
<code>$ cat MyFile.txt</code><br />
You can pass flags along with other parameters. Eg, the &#8216;-n&#8217; option to cat tells it to precede each line with a line number.<br />
<code>$ cat -n MyFile.txt</code><br />
It is considered good style to put all flag parameters before any others. In fact, many older Unix systems require this.</p>
<p>If you&#8217;re running a command that is taking a while, or you want to stop it for any reason, you can press CTRL-C to kill it (quit the program).</p>
<p>On a Unix system, everybody has their own account. Each account is given a home folder for that person to place all of the files. You can only access the files in your own home folder. You can refer to your home folder by the shorthand ~, or somebody elses home by the shorthand ~myfriend</p>
<p>Everything in Unix is case sensitive. That is, file.txt and fiLe.txt are different files, and can contain completely different content. This also goes for command names, as well as all flags and other parameters.</p>
<p>As you know, directories can contain files, or other directories in a hierarchical manner. If we have a folder called &#8220;projects&#8221;, with a folder called &#8220;mygame&#8221; inside, we can refer to the &#8220;mygame&#8221; folder as follows:</p>
<pre>  projects/mygame</pre>
<p>The slash character must be a forward slash, and is referred to as the directory separator. This is the only character that cannot be present in a Unix filename. If there is a file called &#8220;game.java&#8221; inside the &#8220;mygame&#8221; folder, then we can refer to it as:</p>
<pre>  projects/mygame/game.java</pre>
<p>These two examples are called paths, to a directory and a file respectively.</p>
<p>For various reasons, it is also not a great idea to have spaces in Unix filenames. You can, but generally you shouldn&#8217;t.</p>
<p>A simple text editor you can use in these examples is nano. It is worth putting in the time to learn a more advanced editor such as vim at some point though. Nano is a very simple editor to use. The commands it supports are displayed at the bottom of the screen. CTRL-O to save (write out), and CTRL-X to exit.</p>
<h3>Basic Commands</h3>
<p>This section provides a brief synopsis of the most frequently used commands, as well as a few examples of how to use them and what their usage looks like. For more details, you should read the manual page. Like this:<br />
<code>$ man somecommand</code><br />
You should also try out all of these commands on some files you have. Don&#8217;t try these on Word documents or anything like that, these commands are designed to run on plain text files.</p>
<h4>Command &#8211; ls</h4>
<p>Lists the contents of a directory, optionally displaying detailed information about files or folders</p>
<p>List the files in the current directory<br />
<code>$ ls<br />
Project.java Project.class</code><br />
Display a detailed listing of these files<br />
<code>$ ls -l<br />
-rw-------  1 username    group        223 Jul 20 20:28 Project.java<br />
-rw-------  1 username    group        223 Jul 20 20:32 Project.class</code><br />
List the files in a directory, including hidden files<br />
<code>$ ls -a<br />
.hiddenFile Project.java Project.class</code><br />
Combine the above two options<br />
<code>$ ls -la<br />
-rw-------  1 username    group        100 Jul 20 20:28 .hiddenFile<br />
-rw-------  1 username    group        223 Jul 20 20:28 Project.java<br />
-rw-------  1 username    group       5723 Jul 20 20:32 Project.class<br />
</code><br />
Display the contents of the specified directory<br />
<code>$ ls documents<br />
Report.txt Letter.txt</code></p>
<h4>Command &#8211; cd</h4>
<p>Change directory. This command allows you to change the current directory that you&#8217;re working in.</p>
<p>Change into the documents directory<br />
<code>$ cd documents</code><br />
Change into the directory above the current, that is, change into the parent directory. Eg, say there is a folder &#8220;projects&#8221;, and inside that a folder &#8220;mygame&#8221;<br />
<code>$ cd projects/mygame<br />
$ cd ..</code><br />
Go up two directories at a time.<br />
<code>$ cd ../..</code></p>
<h4>Command &#8211; mv</h4>
<p>Move or rename a file or folder.</p>
<p>Rename file.txt into junk.txt<br />
<code>$ mv file.txt junk.txt</code><br />
Move file.txt into a folder called trash<br />
<code>$ mv file.txt trash</code><br />
Move documents/report.txt into a folder called trash<br />
<code>$ mv documents/report.txt trash<br />
$ cd documents<br />
$ mv report.txt ../trash</code><br />
Rename the documents directory to be called MyDocuments<br />
<code>$ mv documents MyDocuments</code></p>
<h4>Command &#8211; mkdir</h4>
<p>Make a new empty directory<br />
<code>$ mkdir nameofdir</code></p>
<h4>Command &#8211; cp</h4>
<p>Copy files or folders</p>
<p>Copy file.txt to backup.txt<br />
<code>$ cp file.txt backup.txt</code><br />
Copy file.txt into a new folder<br />
<code>$ mkdir mystuff<br />
$ cp file.txt mystuff</code><br />
Copy a directory<br />
<code>$ cp -a mydir newdir</code></p>
<h4>Command &#8211; rm</h4>
<p>Removes files and/or directories (BE CAREFUL!)</p>
<p>Remove a file<br />
<code>$ rm file.txt</code><br />
Remove a directory<br />
<code>$ rm -r dir</code><br />
Remove a directory without prompting for confirmation (!!! No way to recover the files once they&#8217;re gone !!!)<br />
<code>$ rm -rf dir</code></p>
<h4>Command &#8211; cat</h4>
<p>Displays the files listed on the command line on the screen (concatenate).</p>
<p>Display one file<br />
<code>$ cat file.txt<br />
contents of file here</code><br />
<code>$ cat file.txt otherfile.txt<br />
contents of file here<br />
contents of other file here</code></p>
<h4>Command &#8211; tail</h4>
<p>Displays the last lines in a file</p>
<p>Display the last 10 lines in a file<br />
<code>$ tail file.txt<br />
last 10 lines in the file go here</code><br />
Displays the last 1 line in a file<br />
<code>$ tail -n 15 file.txt<br />
last line of file</code></p>
<h4>Command &#8211; head</h4>
<p>Similar to tail, but displays the top of the file<br />
<code>$ head file.txt<br />
first 10 lines of file</code></p>
<h4>Command &#8211; wc</h4>
<p>Displays statistics about a file: line count, word count, character count.</p>
<p>Display file statistics<br />
<code>$ wc file.txt<br />
   8  22 262 file.txt<br />
</code><br />
Display just the line count<br />
<code>$ wc -l file.txt<br />
8</code><br />
<a name="grep"></a></p>
<h4>Command &#8211; grep</h4>
<p>Search for text in a file or files</p>
<p>Search for the word apple in file.txt<br />
<code>$ grep apple file.txt<br />
line containing apple is here</code><br />
Search for the word apple in all files in a directory<br />
<code>$ grep -R apple somedir<br />
file.txt: line containing apple is here<br />
otherfile.txt: also have apple in this line</code><br />
Searching for the word apple in a file that doesn&#8217;t contain it prints nothing<br />
<code>$ grep apple file2.txt</code></p>
<h4>Command &#8211; echo</h4>
<p>Prints whatever arguments you pass to it on the screen</p>
<p>Display some text on the screen<br />
<code>$ echo Hello World<br />
Hello World</code><br />
Display text with special formatting characters<br />
<code>$ echo -e 'Hello\nWorld'<br />
Hello<br />
World</code></p>
<h4>Command &#8211; diff</h4>
<p>Displays the difference between two files</p>
<p>If we have file1.txt looking like this:<br />
<code>apple<br />
banana<br />
orange<br />
grape</code><br />
and file2.txt looking like this:<br />
<code>apple<br />
orange<br />
grape</code><br />
We then run diff to compare them:<br />
<code>$ diff -u file1.txt file2.txt<br />
--- file1.txt   2007-07-23 23:01:39.000000000 +1000<br />
+++ file2.txt   2007-07-23 23:02:59.000000000 +1000<br />
@@ -1,4 +1,3 @@<br />
apple<br />
-banana<br />
orange<br />
grape</code><br />
If two files that are the same are compared, nothing is printed<br />
<code>$ diff -u file1.txt file1.txt</code></p>
<h4>Command &#8211; scp</h4>
<p>You can use SSH to copy files from one location to another. The syntax is very simple to the cp command, except one of the source or destination can be on a remote machine.</p>
<p>Copy the file thesis.txt to a directory projects on the server congo4.<br />
<code>$ scp thesis.txt userXYXY@congo4:projects/</code></p>
<p>Copy the entire projects directory on congo4 to the current directory locally.<br />
<code>$ scp -r userXYXY@congo4:projects/ .</code></p>
<h3>Pipes and Redirection</h3>
<p>Everything in Unix is a file. From the perspective of a program, this includes the keyboard and the screen.</p>
<p>All commands that you run from the shell have three special files available to them. Standard input (stdin), standard output (stdout) and standard error (stderr). stdin in is what you type on the keyboard, stdout and stderr you see displayed on the screen.</p>
<p>That is, when you type a command like<br />
<code>$ ls -l</code><br />
and see the file listing displayed on the screen, that is because the program &#8216;ls&#8217; is writing it to the file stdout. Perhaps you instead wish it to be written to a file called listing.txt You could redirect stdout from the program to a file, like this:<br />
<code>$ ls -l &gt; listing.txt</code><br />
Try out the program &#8216;bc&#8217; on the command line. It is a calculator. You can type simple equations with integers and it will print the results. It reads questions as input from stdin (one per line), and writes outputs to stdout. Edit a file and put a few questions, like &#8216;2+2&#8242; on it, then run this command.<br />
<code>$ bc &lt; questions.txt</code><br />
You should see your answers printed. You can even do this to have your answers written to a file.<br />
<code>$ bc &lt; questions.txt &gt; answers.txt</code><br />
What if we want to check if any of the answers in the file were &#8216;4&#8242;? We could use the grep command to find out like this:<br />
<code>$ grep 4 answers.txt</code><br />
If there is a line in the answers file that contains the character 4, then it will be printed.</p>
<p>We can make this more exact by using a regular expression (which is a separate topic that you should look up) like this:<br />
<code>$ grep '^4$' answers.txt</code><br />
That will only match a 4 on a line by itself. Now this will print out all the lines that contain a 4.</p>
<p>Say we wanted to count how many of these answers were 4?<br />
<code>$ grep '^4$' answers.txt &gt; count.txt<br />
$ wc -l count.txt</code><br />
You may be starting to see the kind of uses that you can put this to now. However it might seem a little messy to have to create all these temporary files just to get the result we want. There is a better way, we use what&#8217;s known as a pipe. If we pipe two programs together, then the shell will connect the stdout of one to the stdin of the other.  We can do all of the above in one command like so:<br />
<code>$ bc &lt; questions.txt | grep '^4$' | wc -l</code><br />
Notice that both &#8216;grep&#8217; and &#8216;wc&#8217; will read from stdin if you don&#8217;t specify a file as a parameter. This form is much shorter, and more in the Unix spirit.</p>
<h3>Useful Tips</h3>
<p>You can scroll through the history of commands by pressing up and down. That is, press up to see the last command you ran, up again to see the next last and so on.</p>
<p>CTRL-R searches through previously typed commands. Eg, if you know you typed a really long ssh command and want to find it again, press CTRL-R, type ssh and you will see the most recently typed ssh command. Press CTRL-R to see the one before that, and so on.</p>
<p>All your history is stored in the file ~/.bash_history</p>
<p>If you use vi/vim then you can make the bash command line use those keybindings by running this command:<br />
<code>$ cp ~suits/pub/dotfiles/.inputrc ~/.inputrc</code></p>
<h3>Printing</h3>
<p>Print a file to printer (SIT printers are named in the form &#8220;pr1-&lt;room number&gt;&#8221; in general):<br />
<code>$ lpr -P&lt;printer&gt; &lt;filename&gt;</code><br />
eg.<br />
<code>$ lpr -Ppr1-117 MyClass.java</code><br />
Note that does not wrap or format the given file in any way to make it fit on the page. If you wish to print out code, with syntax highlighting and wrapping, use the following command:<br />
<code>$ a2ps -E -s2 -t4 -P&lt;printer&gt; &lt;filename&gt;</code><br />
To check the print queue for a given printer, the command is<br />
<code>$ lpq -P&lt;printer&gt;</code><br />
Each person with an SIT account has a print quota allocated to them for the duration of a semester. To check your current print quota<br />
<code>$ prquota</code></p>
]]></content:encoded>
			<wfw:commentRss>http://suits.it.usyd.edu.au/wordpress/2007/07/31/tutorial-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: SSH</title>
		<link>http://suits.it.usyd.edu.au/wordpress/2007/04/17/tutorial-ssh/</link>
		<comments>http://suits.it.usyd.edu.au/wordpress/2007/04/17/tutorial-ssh/#comments</comments>
		<pubDate>Tue, 17 Apr 2007 07:33:34 +0000</pubDate>
		<dc:creator>James Bunton</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://suits.it.usyd.edu.au/wordpress/?p=19</guid>
		<description><![CDATA[SSH is a program used to connect to remote machines securely. One of its main uses to you will be to login to the School of IT computers from home to access files. You can set up private/public keypairs to allow logins without a password. It also is able to forward TCP tunnels between remote [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://openssh.org/">SSH</a> is a program used to connect to remote machines securely. One of its main uses to you will be to login to the School of IT computers from home to access files. You can set up private/public keypairs to allow logins without a password. It also is able to forward TCP tunnels between remote machines for port forwarding. All data is transmitted securely through the encrypted connection.</p>
<p><span id="more-19"></span></p>
<p>This page documents the <a href="http://www.openssh.org/">OpenSSH</a> software installed by default on almost all Unix operating systems. Including Linux and Mac OS X. Please see <a title="SSH PuTTY" href="/wordpress/2008/03/02/tutorial-ssh-using-putty">SSH PuTTY</a> for information on using SSH on Windows.</p>
<h3>Connecting to a remote host</h3>
<p>To connect to a host, say congo1.ug.it.usyd.edu.au on the SIT network, you can type a command like this:<br />
<code>$ ssh user1111@congo1.ug.it.usyd.edu.au</code></p>
<p>Since the server is in the School of IT, locally the command:</p>
<p>$ ssh user1111@congo1 also works</p>
<p>It is also possible to implicitly specify the username. Eg, if the account you&#8217;re logged in to at the moment has the username userXYXY, then typing these two commands are equivalent:<br />
<code><br />
$ ssh userXYXY@host<br />
$ ssh host</code></p>
<p>You can type exit to end this effect.</p>
<h3>SSH Public/Private Keys</h3>
<h4>Basic Principles</h4>
<p>You generate a public/private keypair. The private key, as its name suggests, should remain on your computer, and not be shared with anybody. Your public key can be given to other people. Anybody who has your public key can encrypt a message such that it can only be decrypted using the matching private key. You can trust that this works.</p>
<p>For a more thorough explanation, see the Wikipedia article: <a href="http://en.wikipedia.org/wiki/Public-key_cryptography">Public-Key Cryptography</a></p>
<h4>Generating a public/private key pair</h4>
<p>What does this have to do with SSH? Well, for each computer account you have, you create a public/private key pair. Do that with this command:<br />
<code>$ ssh-keygen -t rsa -b 4096</code><br />
That means create a 4096 bit RSA key. Answer yes to all the prompts. I generally don&#8217;t bother setting a passphrase. This will then mean you end up with these two files:<br />
<code><br />
~/.ssh/id_rsa       # Private key<br />
~/.ssh/id_rsa.pub   # Public key<br />
</code></p>
<h4>Using the key pair</h4>
<p>You now need to create a file called ~/.ssh/authorized_keys. In this file you put a list of the public keys that are authorised to connect to this account without a password.</p>
<p>Example: On your home machine, create a public/private keypair. Log in to your account on the SIT machines and create a file called<br />
<code>~/.ssh/authorized_keys</code><br />
You may need to create the directory ~/.ssh first. Note that ~ (tilde) means your home directory. Put the contents of the public key you created on your home machine into the authorized_keys file on the SIT machines.</p>
<p>Now you can connect to the school computers without a password.</p>
<h3>SSH Config File</h3>
<p>There&#8217;s a wonderful file that few people use: ~/.ssh/config</p>
<p>You can look up documentation for it in the manpage ssh_config. Here are some examples of things that can go in there:<br />
<code><br />
# This is a useful rule that lets you log in to congo1 by just typing<br />
# $ ssh congo1<br />
# instead of<br />
# $ ssh userXXXX@congo1.ug.it.usyd.edu.au<br />
Host congo1<br />
&nbsp;&nbsp;&nbsp;&nbsp;User userXXXX<br />
&nbsp;&nbsp;&nbsp;&nbsp;HostName congo1.ug.it.usyd.edu.au</p>
<p># Another useful rule for setting up X11 forwarding<br />
Host ugrad<br />
&nbsp;&nbsp;&nbsp;&nbsp;HostName congo1.ug.it.usyd.edu.au<br />
&nbsp;&nbsp;&nbsp;&nbsp;User userXXXX<br />
&nbsp;&nbsp;&nbsp;&nbsp;ForwardX11 yes<br />
</code></p>
<p>Once you have an alias like <em>congo1</em>setup, this alias can be used in <em>scp</em> too. For example, to copy a file called <em>foo</em> from userXXXX&#8217;s home directory into the local <em>/tmp</em> directory:<br />
<code><br />
$ scp congo1:~/foo /tmp/<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://suits.it.usyd.edu.au/wordpress/2007/04/17/tutorial-ssh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Vim</title>
		<link>http://suits.it.usyd.edu.au/wordpress/2007/04/05/tutorial-vim/</link>
		<comments>http://suits.it.usyd.edu.au/wordpress/2007/04/05/tutorial-vim/#comments</comments>
		<pubDate>Thu, 05 Apr 2007 07:27:08 +0000</pubDate>
		<dc:creator>James Bunton</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://suits.it.usyd.edu.au/wordpress/?p=18</guid>
		<description><![CDATA[Vim is a highly configurable, advanced text editor built to enable efficient text editing. It features syntax highlighting, tabs, splits, find as you type, regexps, integration with compilers and much much more. Available for any OS you can think of, even in GUI form if you wish.

More details will be forthcoming, but you should really [...]]]></description>
			<content:encoded><![CDATA[<p>Vim is a highly configurable, advanced text editor built to enable efficient text editing. It features syntax highlighting, tabs, splits, find as you type, regexps, integration with compilers and much much more. Available for any OS you can think of, even in GUI form if you wish.</p>
<p><span id="more-18"></span></p>
<p>More details will be forthcoming, but you should really check out Vim. Used properly, it&#8217;ll speed up your coding dramatically.</p>
<p>To get started, run<br />
<code>$ vimtutor</code><br />
from any Unix machine and work your way through to the end.</p>
<p>For an idea of the general philosophy of using Vim, have a look at this <a href="http://www.moolenaar.net/habits.html">article</a>.</p>
<p>Here&#8217;s a <a href="http://www.tuxfiles.org/linuxhelp/vimcheat.html">cheatsheet</a> with some commonly used essential commands.</p>
]]></content:encoded>
			<wfw:commentRss>http://suits.it.usyd.edu.au/wordpress/2007/04/05/tutorial-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
