This is a primer for those of you who have no previous experience of a UNIX system (which is most of us :o) ) and will teach you the basics of changing your shell and using programs such as mail and news.
Ok, when you first start using Redbrick and you log on, you'll be looking at a screen which looks fairly plain with some basic instructions for reading mail, news, chat, etc. This is great when you're starting off, but after a while, you'll find that just staring at the screen can hurt your eyes, so you'll want to do other stuff. You'll then see why a lot of people type stuff when using computers. The way that most people prefer when they get used to it, is typing in commands in a 'shell'. This sounds really difficult, but you'll soon get into the hang of it and be heying your friends and going into chat and mailing your ma and so on :o)
The default shell that you start with is zsh, if (for whatever reason) you wish to change your shell here's how to do it.
At the prompt type chsh, like so:
You'll be asked for your password, enter it. Now you'll be looking at this:
This shows your current shell and is where you select your new one.
Now you'll need to give it the location of the shell you want to use. If you don't know where they are, don't worry here's a list by typing "help chsh":
Now all you do is select the one you want, type it in and away you go.
As it says, this can take effect immediately or in several minutes time.
Every file on Redbrick has what's known as a path. Basically, it's the location of the file on the system. The format in Unix is a little different to Windows, for example, on a Windows/DOS machine, an example would be:
while on a Unix system like Redbrick this could be:
The difference here is that you don't actually specify drive letters. Everything begins at the root folder, which is denoted by a forwardslash (/). Everything then goes from that, with each subfolder being separated by another /, but don't get confused by the two. One last thing on this topic, you can change to the root folder by typing:
Your home directory is where you store all your files. On Redbrick, your home directory is:
where 'u' is the first lettter of the username. Committee members would find their home directory in:
That folder, and everything in it is yours, and you have control over it. You can add files, create subfolders and change permissions on your files. Your mail is stored there, as is everything else. To change into your directory, you use the cd command. One way of changing into your home directory is by typing
but there is a special character to represent your home directory, namely tilde (~). So a shorter version is:
However, cd on its own should do the same thing.
There are lots of special characters in unix. You've seen two already, / for the root directory, and ~ for your home directory. Another one is simply '.'. What a fullstop represents is your current directory. You might not think this is useful, but it is, especially in commands like cp and mv for example, where you are copying or moving stuff into your current directory. It can also be expressed as ./, but they both mean the same thing.
Then there's what's known as your parent directory, the one just before your own. In the example, if you were in the folder:
then your parent folder would be:
Your parent folder is denoted by '../' So, if you wanted to change into it, you simply use the command:
These are arguably the two most useful UNIX commands.
The 'man' command brings up a manual on a command. There is a man page for pretty much every command (although quality of the pages differ vastly). Here's an example:
And the result will be:
You can navigate through the man page with arrow keys or page up/down.
The 'apropos' command searches through descriptions of man pages based on a keyword.
Lets say you forgot how to rename a file, or just simply didn't know how to to begin with you can type:
and the result will be:
Simple (and really useful too).
Say you wanted to create a file in your home directory called 'phonenumbers'. You need to use an editor. The editor on Redbrick that is the best to use when you're starting off, is nano. In fact, lots of experienced users still use it. So, to create your file, you would type:
This will open up the nano editor, with a blank file called 'phonenumbers'. Now, just simply type in whatever you want in this file.... To save it you can hold down control and hit 'o' (when I say control-o, that's what I mean), then hit return to confirm the filename 'phonenumbers'. If you want to exit, then you don't have to do a control-o, you can use control-x. It will ask you if you want to save the changes, so you press 'y' and again hit return to confirm the filename.
Some more unix commands:
The command 'who' lists all the users on the system, what pts they're on, the time they logged on and the machine they logged on from.
The command 'ls' simply lists all your files in the folder that you are in, One point, there can be 'hidden' files in a folder. Their names begin with a "." They aren't really hidden, it's just that ls won't see them, unless you tell it to look for them by using the command:
This will show ALL files in that folder. Another 'argument' that you can pass ls, is the l option, which gives a detailed listing of the files, and you can specify more than one argument to ls, or any other command for that matter. The command:
will give a detailed listing of all files in your current folder, including 'hidden' files.
will show the same listings with "human readable" file sizes, instead of bytes.
I've already covered this in a way, it changes your current folder or 'working directory' as is the proper name for it. Some examples:
changes your working directory to /usr/local/bin
changes your working directory to the root directory
changes to your parent directory
changes to your home directory
This command simply creates a directory. You can only create directories in directories that you have permission to write to, such as your home directory, or /tmp for example. Some examples:
creates a directory called 'project' in your current directory
does the same, only puts it in your home directory, regardless of whether your home directory is your working directory or not
The command cp is used to copy files around the place. There are two arguments you must pass to cp, the source file (the one you want to copy) and the target file (the file you want to copy it to). That sounds confusing but it's not really. When you copy a file, you can specify a directory as the target, that way the file will be copied with the same name into that directory. Some examples will show this better:
cp ~/project/intro.txt ~/
will copy intro.txt out of ~/project into your home directory
cp ~/project/intro.txt ~/introduction.txt
will make a copy of the same file in your home dir, only renamed to introduction.txt
cp ~/project/intro.txt ./
will copy the same file into your current working directory
You can't copy directories like this however, to copy a directory you must use the -R switch, which will copy all sub-directories of that directory as well, so an example would be:
cp -R ~/project/images ~/images
which will copy the directory 'images' out of 'project' to your home directory
The command mv moves files between folders, and can move folders themselves. Its usage is very similar to that of cp. in fact it's the same, only it deletes the source file, leaving the target file. That is, if you mv one file into another folder, the new file will remain, while the old one is deleted, in effect, a 'move'. mv is also used to rename files. Some examples:
mv ~/hello.txt ~/bye.txt
renames hello.txt to bye.txt (in your home directory)
mv ~/bye.txt ~/project/hello.txt
renames bye.txt to hello.txt and moves it into the directory ~/project
mv ~/project ~/oldstuff/project
moves the directory ~/project into ~/oldstuff
The command rm is used to delete files. Be careful with this command as once you remove a file, you've lost it unless you made a backup of it. The command is easy to use, an example is:
to delete the file 'hello.txt' out of your home directory
One of the simpler commands, simply typing pwd at the prompt will display your current working directory. 'pwd' stands for 'print working directory'.
This stands for concatenate. This command is really useful, if you have a text file you want to view without going into a text editor, you can simply type, for example:
which will simply display the text file on the screen. If the text file is large, even more than a screen, then this can be annoying. This is where the command more comes in. 'Piping' the 'cat hello.txt' into it will cause the page to be displayed on screenful at a time, using return to go down one line at a time, or space to go down one screenful at a time. There is a command called less which does the same, but it wont bring you back to the command line after youve finished viewing the text file until you press 'q'. The command you need to type is
cat hello.txt | less
The '|' is called a pipe, got usually by holding down shift and \, and is used for putting the output of one command, in this case, 'cat hello.txt' into the input of another command, in this case, 'less'. There are lots of things you can do with cat, and redirection(using pipes etc..) but I'm not going to go into that here.
There are more unix commands that you can imagine, the ones I have given here are basic ones, with a few basic examples for you to get started. To get more uses for any of the commands or any others, simply type:
to get detailed instructions on that command. The best way to learn Unix is to experiment, just be careful when you're going around deleting stuff. :) This is just a primer for those of you starting off on Unix, but there are numerous tutorials on unix to be found on the web and you can always talk to Helpdesk if you have a problem or a question.
Oh, one other thing: the clear command.
If your screen is filled up with text or program you've quit out of and are basically just in the way you can clear your screen like so:
And you'll be left with this:
Unix Advanced - a guide to some of the more advanced parts of Unix (if you're ready).