An overview of some problem-solving strategies that may be useful for programming and computing, followed by an introduction to Unix, and an assignment to do some problem-solving using Unix tools. We will also set up your account on the course server and create your first web page on the server.
Loggin In | Display Conventions | Command Line | The Shell | User accounts | The Tree Metaphor | The Plumbing Metaphor | Getting Help | List of Unix Commands | A Guided Tour | Assignment
An account has been created for you on sheu-hp.psy.depaul.edu. This machine will serve as our development host and web server for this course. It is where you can carry out assignments and work on projects, and generally mess around and learn things. You will also need to have an account on one of the university's public unix machines, such as shrike.depaul.edu. Most of what you learn to do on our development server should work on shrike or condor as well. For this tutorial we will be working only on our development server.
The first thing you need to do is log in. The steps below will walk you through the process.
telnet sheu-hp.psy.depaul.edu
Then click "OK." A window should then appear with something like the following in it:
Red Hat Linux release 7.1 (Seawolf)
Kernel 2.4.2-2 on an i586
login:
A quick note about my conventions for displaying input, output, and code: Code - the contents of a program or script - will be displayed like this. Output - text that the system displays to you such as the command prompt or output from a command or program - will look like this. Input - text that you are to type in, such as commands you type at the command prompt, or responses you type in as input when prompted by a program - will look like this. To indicate that you should press a certain key or combination of keys (like the tab key for example) this format will be used: tab.
If you logged in successfully, you should see something like this:
[orval@sheu-hp orval]$
This is what is affectionately known as the "command prompt," because it is where you type Unix commands. The command prompt contains some helpful information:
You can change the prompt if you like, but for now we will just use the default bash prompt and start typing in commands. Try the examples below to get you started. Remember that all commands are case sensitive - just as usernames and passwords are. By the way, I may omit telling you to "press Enter" all the time, but you can generally assume that you are expected to press "Enter" after typing in a command on the command line. Remember to type in any commands that you see next to a command prompt in the examples throughout this document.
The very first thing you should do when you log in for the first time is change your password.
Passwords can contain both upper and lower case letters, numbers, and punctuation, but no spaces. If you try to choose a password that is too easy to guess, the passwd program will not allow it. A good password is one that is not based on a dictionary word, and contains numbers or punctuation as well as letters. A good password is also one that you can remember.
Once you have successfully changed your password, log out and log back in again using your new password. To log out simply type logout or exit at the command prompt. Once you have logged back in, try out the following commands to learn more about the command line:
The output of whoami is your user name.
Notice what happens if you forget that Unix is case-sensitive!
This produces a list of the commands you have used
Command completion: The tab key completes the command name if possible. The same trick works for completing file names. If what you have typed so far does not uniquely identify the command or file, pressing the tab key again will display the list of possible completions.
This executes the most recent command that started with "his" - history in this case. Variations of the exclamation point trick include:
Most of these command line features are a function of the shell. The shell is the program that the user interacts with on the command line. There are several different shells available, and each works a little differently. We are using bash. It is the default shell for most machines. It is also favored by programmers because it is good for writing scripts - files of command lines that can be run as a batch rather than having to be typed on the command line one at a time. Another popular shell is tcsh, or the C-shell. It uses syntax that is similar to that of the C programming language. You can try out the tcsh shell by typing tcsh at the command line if you wish.
You can customize the way the shell behaves by editing the bash configuration files, .bashrc and .bash_profile. Later in the session we will edit your .bash_profle file to change the default behavior of the cp and mv commands.
Because Unix is designed to support multiple users at a time, it has a system for managing user accounts and files. Every file belongs to a user, and the owner of a file can determine whether other users can access it. The following commands demonstrate various aspects of file permissions and ownership.
This lists the files in the current directory
This demonstrates the use of an option with a command to change its behavior. It also produces some more detailed information about each file. The first field lists the file permissions. More on that in a moment. The third field lists the owner of the file. The fourth lists the group the file is assigned to. The fifth field is the size of the file.
The file permissions field has four sections. The first letter indicates whether it is a plain file or a directory. The next three letters are the owner permissions. An "r" indicates that the owner of the file can read the file. A "w" indicates write permission, and "x" indicates execute permission. The next three letters indicate the permissions for other users who are members of the file's group, and the last three letters are the permissions for all other users.
Some basic commands (and some fancier related commands)
This little exercise will introduce some commonly used Unix commands and, in the process, create a web page for you on the course server.
$ uname -a
$ id orval
$ who
$ w
$ TERM=vt100
$ export TERM
$ stty
$ mkdir tempd
$ cd tempd
$ pwd
$ mv ../w-output .
$ history | tail
$ cd
$ pwd
$ rmdir tempd
$ mv tempd/w-output .
$ rmdir tempd
$ pushd /etc
$ ls
$ more < passwd
$ pushd
$ ps -aux > processes
$ wc *
$ ls -l
$ sleep 5; ls
$ tail processes
$ ps >> processes
$ tail processes
$ chmod ugo-r processes
$ tail processes
$ chmod 744 processes
$ head processes
$ cat processes | grep root
$ cat processes | grep root | tail
$ ping shrike.depaul.edu
(Demonstrates control-c)
$ cat > controld-demo
$ echo 'control-d is the Unix end-of-file character' | sed -e 's/Unix/Linux/'
(Other special characters: control-z ~ \ )
$ rm controld-demo
$ rm -i w-output
$ cal
$ date
$ man date
$ info grep
$ locate hosts.allow
$ locate hosts
$ locate hosts | wc
$ locate hosts | grep '^.etc'
$ locate hosts | grep '^.etc.*y'
$ find /var/ftp/ -name '*index.html'
$ vi .bash_profile
(uncomment the lines for aliases for mv and cp)
$ source .bash_profile
$ ftp sheu-hp.psy.depaul.edu
log in as anonymous
cd pub
get sample-index.html
quit
$ ncftp sheu-hp.psy.depaul.edu
cd pub
get tidy_linux_x86.tar.gz
bookmark sheu-hp
quit
$ ls
$ gunzip tidy_linux_x86.tar.gz
$ tar -xf tidy_linux_x86.tar
$ ls
$ mkdir bin
$ mv tidy bin
$ which tidy
$ hash -r
$ mv sample-index.html public_html/
$ cd public_html/
$ tidy -h |more
$ tidy -i sample-index.html > index.html
$ diff sample-index.html index.html
$ vi index.html
(pico - an easier to use editor)
(emacs - a more powerful editor)
Now point your web browser at sheu-hp.psy.depaul.edu/~orval (but substitute your user name for "orval").