Chapter 1
Unix introduction
I’ll begin these musings with the briefest of brief introductions to the operat- ing system called Unix. If you already know all about it, or if you’re using Windows, you can safely skip this chapter.
You execute unix commands through a shell. A shell is a program which lets the user input commands and then executes these commands. So, in order to start doing something, you need a shell. It could be an xterm. When you log into the DAIMI system, a shell probably starts automatically. You can usually scroll through the commands you have issued so far by using the up- and down- cursor keys. In the DAIMI system, your files and directories (folders) are organized in a tree structure. The root of this tree is your home directory: /users/
1 2 CHAPTER 1. UNIX INTRODUCTION
pwd Gives the absolute path to the current WD.
cd .. Changes the WD to the parent directory of the cur- rent WD (move up one level).
mkdir
rmdir
more
ls Lists the contents of the WD.
ls
ls -l Like ls but lists the directory contents in tabular form with file information.
mv
cp
rm
∼/ Shorthand for your root directory.
∼
chmod
• The letter a means all users, the letter u means user (you only)
• The code + means permission is granted, the code - means permission is denied
• The actions r, w, x mean read, write, execute, respectively
Thus, the mode a+rx means that all users are granted read and execute access. 3
. E.g., cat mylist.txt | cut -d ” ” -f2,4 lists the second and fourth fields of each line in the file mylist.txt after splitting it at each space.
You can guess the remainder of a file or directory name you have started typing with the Tab key: Type the first few letters of the name and the press Tab; then your shell auto-completes the name. If there are several options, it will beep and expect more characters to be typed in. You can use . for the current working directory. This is nice, e.g. when you wish to copy or move something “here”. If you want to learn more or need further explanation, an excellent series of Unix tutorials for beginners is available at http://www.ee.surrey.ac. uk/Teaching/Unix/index.html The first five tutorials cover the most ba- sic stuff.