Unix (with Linux) is probably still the most important operating system in the world. Most other operating systems in common use incorporate many features of Unix. For example the MS-DOS command line does input output redirection and piping in the same way as Unix, and has a similar directory tree. Windows NT executables use a file format directly derived from Unix, and the OBJ files created by Win32 C compilers are in a format known as COFF (common object file format) which was invented for Unix. NT security, kernel and networking functions incorporate many ideas from Unix. (On the other hand new versions of Unix are incorporating more and more Windowsy features)
Unix can be very daunting to the novice. Unix seems to have been invented for computer users who cannot type and have a religious objection to words with vowels in. Most Unix commands have very short and obscure names. The other things which make Unix difficult to use are:
However, if you are used to using a DOS command prompt, you will be able to use Unix without too much difficulty. Although Unix is difficult, the various releases of Unix are very similar to each other and use most of the same commands. Installation and administration of a Unix machine is a bit more complicated, and tends to be release specific.
Unix servers are usually accessible without leaving your normal PC. You can use a program called telnet to log in and run programs on a Unix server from your Windows PC.
When you boot a Unix machine or connect to it with TELNET you will have to log in by supplying a username and password. After logging in you will get a command prompt, which is traditionally just a $
| PATH=/fred : $PATH |
| export PATH |
| more |
Unix commands don't page their output nicely. You can use more in the same way as on MS-DOS. e.g. ls -lt | more. Sometimes there is a more powerful equivalent called pg or less . Backspace may or may not let you go back a page. |
| ls |
Directory listing. Use ls -l for listing with date/time. ls -lt lists by date/time. Sometimes lc gives a multi-column listing. You can specify a filename to restrict the search: ls a* looks for files beginning with a ls *a* looks for files with an a in the name. N.B. *.* matches files with a . in the name, NOT all files. |
| mv |
Used to rename files. e.g. mv oldfilename newfilename |
| cd |
Change directory. cd by itself takes you back to your login directory. |
| pwd | Displays the current directory. |
| cat |
Can be used to "type" files. e.g. cat fred.c |
| cp |
Used to copy files. e.g. cp file1 file2 You have to give two arguments. So to copy a file to the current directory from somewhere else you do something like this: cp /usr/datafit/bkp/system.dat . |
| su |
Used to become super-user (root). You will be asked for the root password. Running su is not the same as logging on as root, as you don't get the root path or environment. This may mean that administration tools are not in your path. Log on as root to administer a Unix machine, or sysadm on some flavours. |
| mv |
Used to rename files. e.g. mv oldfilename newfilename |
| rm |
Used to delete files. You can use rm -r to delete whole directory trees. (Be careful - there is no undelete!) |
| chmod |
Used to change the permissions for a file. The most common uses for this program are to make something executable, or to make something writable. chmod +x filename , makes filename executable chmod +w filename , makes filename writable. You can also specify desired accesses with octal numbers got by adding up 1=execute 2=write 4=read e.g chmod 666 filename makes filename readable and writeable by everyone. |
| chown |
e.g. chown fred filename . Makes fred the owner of filename . You may well want to run chown after extracting a tar file from another machine |
| chgrp |
e.g. chgrp system filename. Makes filename part of the "system" group. |
| ps |
Displays running programs. This has different command tails depending on what you are running on. ps -a or ps -e or ps -u datafit are likely to be useful. |
| man |
Displays an online manual. You have to say what you want to read. e.g. man ps will tell you about the command tails that ps accepts. On Linux a program called info is used as well. Unfortunately man pages delight in explaining commands in a highly abstract way, which is usually extremely hard to understand, and hardly ever give examples. |
| find |
Used to find a file on the machine. For example: find / -name *fred* -print lists files with fred in the name. |
| grep |
Finds text in files. You can use it in a simple way. e.g. grep Fred * looks for files containing Fred . This program is VERY complicated. Use man to find out more. Note that the search string is case sensitive. |
| tar |
This program is used to "zip" files, though it does not necessarily compress them. DP4 is installed using this program. tar -x can be used to extract files, or tar -xv if you want to see what is going on. On Linux you may need to specify tar -xPv or tar -xP . There is a DP4 version of tar which can be used to create tar files and tar format diskettes. winzip can read tar files. tar diskettes are not readable using DOS or Windows (except with tar) , because the area used for the FAT and directory is just used for data. They need to be reformatted to be usable as ordinary diskettes. |
| telnet |
You can use this program from a Windows (or another Unix PC) to remotely access any of the Unix machines in this office. |
| ftp |
You use this program to transfer files from your local machine to or from a Unix machine. Separate instructions are given later on. |
| ipcs |
Used to display stuff called shared memory, queues and semaphores. You may need to use this program if there is a problem with DP4 |
| ipcrm |
Used to clean up the information displayed by ipcs. The ipcrm on some distributions of Liunx is completely different from the Unix program. |
| vi |
The Unix text editor. It's hard to use until you get used to it. If DP4 is installed and working dp4ed may be an easier alternative, but cannot be used for files needing Tab characters (e.g. makefiles) |
| ln |
In Unix or Linux it is possible to create "alias" names for files. For example DP4 is always installed in a directory called /usr/datafit. However you are likely to want to install it somewhere else, such as /home/dp4 instead. Using ln you can create a "link" which will fool DP4 into thinking it is installed in /usr/datafit when it is really in /home/dp4. Typically this is done with ln -s. Consult man ln for details (which may be different on different machines). |
| Ctrl+Alt+Func key |
Usually Unix comes with lots of "virtual consoles", and you can use this key combination to switch to another. This can be useful if something goes wrong! On some machines you use Alt+Print Screen, followed by a number key instead. |
| kill |
Used to kill programs that have hung. You have to use ps to disover the "pid" (process id). Then kill nnn where nnn is the pid should kill the program. If it doesn't kill -9 pid will definitely work. |
| init |
Used to shutdown or reboot the machine. init 0 does a shutdown. init 6 does a reboot. Ctrl+Alt+Del works on Linux. You have to be "super user" to do this. Either log in as root, or run su and give the root password. |
| doscp,dosdir |
Unix machines are often capable of reading and writing information from DOS diskettes or hard disks. The commands used to do this tend to be different on each flavour of Unix. This can be useful - for example on a "dual boot" machine when you want to copy files from a Unix to a DOS partition. |
ftp is used to transfer files to and from Unix servers (or other servers - you can't tell what OS an ftp server is running).
An extremely important point to bear in mind is that Unix text files have a different format from DOS. When copying to and from Unix ftp can do one of three things:
You have to make sure you are an appropriate mode when copying files between DOS and Unix.
Most Unix machines set up an ftp server by default when Unix /Linux is installed. If this doesn't happen you will have to set up the server yourself. On Red Hat Linux this involves finding and installing something called wuftpd. Don't try it if you're feeling stressed!
|
open <server_name> |
Creates a connection with a Unix or Linux server. e.g. open rs6000 When you do this you will be asked to supply a username and a password. Different machines have different restrictions on what accounts you can use:
Depending on what you log on as there will also be restrictions as to what you can copy to and from the Unix machine. Inactive ftp connections time out after a fairly short time - usually 5 or 15 minutes, so you may need to use this command several times. |
|
put <srcfilename> <tarfilename> |
Copies a file to the Unix server. Both filenames can include path information. You don't have to specify the tarfilename, in which case the file will be copied to your current directory on the target machine and the filename is converted to upper case. This is very annoying so you should specify the filename both times. e.g. put x:\521\unix\unxsco.tar unxsco.tar Tip: If you want to transfer a lot of files, it may well be easier to build a tar file containing all the files and ftp that |
|
get <srcfilename> <tarfilename> |
The reverse of put - copies a file from the Unix server. You can usually miss out <tarfilename> |
|
ascii |
Switches ftp to using ascii transfer |
|
bin |
Switches ftp to using binary transfer |
|
ls dir |
Used to list contents of directories on the server. Pretty much the same as the regular Unix ls . dir is equivalent to ls -l (but won't exist on most Unix ftp clients) |
|
cd pwd |
Used to change and display directory on the server. Again the same as the regular Unix commands. |
|
lcd |
Used to display and change your directory on the local machine. |
|
close |
Terminates your connection. |
|
quit |
Exits ftp |
|
help |
Lists the available ftp commands. I've only included a selection - but I've hardly ever used any of the others. |
vi is supposedly a wonderful editor. Some people like it so much they have even gone to the trouble of writing versions for MS-DOS/Windows. I am not a very skillful user of vi, so this summary is very rudimentary. Try the man pages for more information. When running vi, it is important that the term environment variable is set correctly. If it is not vi is likely to be unusable. This is especially the case if you are running vi in a telnet session. Beware of editing files with lines longer than 80 characters. This can be very confusing as it is all to easy to find yourselef editing something different from what you thought you were editing.
You start vi with vi filename where filename is the name of the file you want to edit. This will open the file. You can probably use the four cursor arrow keys to move round the file. If not term is not set correctly, or TELNET isn't set up .properly. To start editing the file you press i . After that characters you type will appear in the file. Backspace will delete characters you type in but not existing parts of the file. Esc will take you out of the edit mode again (and move the cursor back one space!), which you need to do when you want to use other commands. x will delete the character at the cursor. You can use a instead of i to enter an edit mode. You do this to append to the end of a line.You can go to a specific line in the file by entering a : followed by the desired line number. You can find the string fred in the file by entering /fred/ . Entering / repeatedly will cycle through all the occurrences of this string in the file. There is also a search and replace facility but I don't know how to use it. If I want to do serious editing I generally use ftp to transfer the file to DOS/Windows where I can use an editor I actually like. dd deletes a line, dw deletes a word. Ctrl+F pages down through the file. :x saves and exits. :q! exits without saving. :w saves without exiting.
I'm not going to explain this in detail, but just give you a few tips: