Unix Overview


INTRODUCTION

What is Unix?

  • Unix is an operating system - meaning it is a program that acts as an intermediary between a user and the computer hardware. Windows NT is an operating system.
  • Unix is a Registered Trademark of AT&T.

Why is Unix so popular?

  • Multi-Tasking Capability - multiple jobs are executed by the CPU switching between them. The switching is done so frequently and quickly that the users may interact with each program while it is running. This increases the efficiency by allowing several jobs to complete in the time one would run on another system.
  • Development Environment -
    • When new development occurs in industry Unix can usually absorb it and still remain Unix.
    • Unix was written in the C programming language, which was developed to support Unix.
    • Unix was designed by programmers for programmers.
  • Independence of Vendor/Hardware - Unlike MacOS or Windows, Unix is not designed for specific machines or vendors. This makes it portable, and theoretically any program written under Unix can run on another Unix system.
  • Unix runs on personal computers, workstations, mini computers, mainframes and super computers. It can run on machines from the Apple Macintosh II to a Cray II.

 HISTORY OF UNIX

  • Developed in 1969 at Bell Labs by Ken Thompson and Dennis Ritchie.
  • It was widely used within Bell Laboratories and spread to just a few universities.
  • The first version available outside of Bell Labs was in 1976, Version 6.
  • In 1978 Version 7 was released.
  • The Unix Support Group (USG) assumed administrative control and responsibility from the research group for distributing Unix within AT&T.
  • The first external distribution from USG was System III in 1982. It incorporated Version 7 and other Unix systems developed by groups other than Research.
  • Version 8 was later released, and contained a remote file system similar to NFS. This version also allowed multi user login.
  • System V, released in 1983, was the first version marketed aggressively. The USG was restructured as Unix System Development Lab (USDL).
  • In 1984 USDL released System V Release 2 (V.2). This version added virtual memory and shared memory.
  • The small size, modularity and clean design of Unix lead to much Unix-based work elsewhere: Rand, Harvard University, Purdue University, DEC and, the most influential of all non-Bell labs, University of California at Berkeley.
  • Unix software from Berkeley is released as Berkeley Software Distribution (BSD).
  • 1986 - 4.3 BSD Released.
  • 1988 - 4.3 BSD Tahoe released - included improved networking control and TCP/IP performance.
  • Version 10 was released by USDL in 1989 but it is only available in Bell Labs.
  • In an attempt to standardize all Unix flavors the POSIX (Portable Operating System Standard for Computer Environments) standard was created. Under these standards eventually there will be only one programming interface to Unix.
  • The first merged Unix was in 1989, called System V Release 4. System V R.4 combined System V, 4.3 BSD and SunOS. This new Unix conforms to the published POSIX standard, POSIX.1.
  • The last Berkeley release, 4.4 BSD, was finalized in June 1993. It is POSIX Standard Compliant and includes an implementation of Sun's NFS. Sun Microsystems helped to popularize BSD Unix by shipping it on their workstations.

A wide variety of Unix systems have been created. All of these go under a different name than Unix (since it is a registered trademark), but they are Unix operating systems.

  • HP uses HPUX.
  • Microsoft rewrote Unix for the 8088 family and called it Xenix. Windows NT was heavily influenced by Unix as well.
  • Sun Microsystems uses SunOS.

OUR USER INTERFACE

Before using the user interface; a telnet client, such as PuTTY, must be configured to connect to the Missouri S&T Campus machines.

You will need:

Missouri S&T also has Numerically Intensive Computing (NIC) machines Icon indicated a new window/tab will be opened by pressing link, which run the Unix operating system. Access to these machines are for research purposes only and not available without an advisor signature.

Logging In:

  • You will receive a login prompt that looks like "login:" -- This expects you to type in your Single Sign-on Username. You will then be prompted for your University password.
  • You are allowed to have multiple logins at the same time. This means you do not need to exit one session before opening a second session.

Login Settings:

Login Settings are set in the .bashrc file. Do not delete data from this file.

Logging Out:

To logout you can issue one of two commands

  • logout
  • exit

Depending on the shell you use one may be more appropriate than the other.

Character Information

  • Unix is case sensitive. This means there is a difference between ls and LS. These will be taken as two different commands.
  • The Unix erase character is ^ h (control + h). If your backspace does not work you can use the combination of control and the 'h' key to erase characters one at a time.
  • The Unix line kill character is ^ u (control + u). To delete an entire line of text, you can use the combination of the control and the 'u' key.

Shells

Unix shells are a command interpreter. They get the command statements and execute them. The default shell at Missouri S&T is the bash shell.


UNIX FILE SYSTEM

Unix uses a Hierarchical Directory Structure with Tree Structured Directories.
This allows users to have non-unique file and directory names within their own directory structure. (Directories on the same level must have unique names, and files in the same directory must have unique names).
This also allows for non-unique names across user accounts. If this was not the case, every file name would have to be unique for the whole system, not just for an individual user.

What is a Unix File?

  • File format is a string of bytes.
  • Types of Files
    • Ordinary - text or binary files
    • Directory - directory information is stored in a file.
    • Special - linked files.

Where Your Account is Located

  • The login process will take you directly to your home directory. You will not have to find your directory after logging in, you are already there.
  • The absolute path to your home directory is /nethome/users/(your Username).

Types of Pathnames

Unix has 3 types of paths that will get you to a specific file/directory.

Absolute Paths

  • All begin with a forward slash, '/'
  • Are fully specified addresses from the root directory
  • Example: /nethome/users/<YourUsername>

Relative Paths

  • All pathnames that do not start with a forward slash '/' or a tilde '~' are relative paths.
  • Relative means it is relative to the current directory.
  • Example: A file in your home directory would just be the filename.
  • Example: A file in a subdirectory off of your home directory would be subdir/filename.

User Relative Paths 

  • All pathnames begin with a tilde '~'
  • Your home directory would be   ~
  • To change to another user's directory you can specify it as,  ~  joeuser instead of /nethome/users/ joeuser
  • Everything using user relative paths is relative to the specified users home directory. It will not matter what your current directory is if you use user relative paths.

Unix Special Files

Unix creates two special files in each directory. These are useful when navigating around the file system and when referring to files.

  • The file . refers to the current directory. It is commonly used to refer to executables in the current directory, e.g ./a.out.
  • The file .. refers to the parent directory. It is commonly used to navigate up the file system, e.g. cd ..

FILE MANIPULATION AND DIRECTORIES

  • To Create a Directory
    • mkdir - Makes a directory named   
  • To Remove a Directory
    • rmdir - Deletes a directory named   
  • To Change Directories
    • cd - cd alone will take you to your home directory
    • cd - Takes you to a directory named   
  • Find Current Directory
    • pwd - Print Working Directory

List the Contents of a Directory:

Unix does not have a 'dir' command. There is a command ls which lists the contents of a specified directory. ls has many options to make viewing the information easier.

  • ls - lists just the file names and sub-directory names in the current directory.
  • ls - lists just the file names and sub-directory names in the specified directory.
  • Use the online manuals to obtain the remainder of the ls options: man ls.
    • ls -l- lists the long format of the directory information.
      • drwxr-xr-x 18 joeuser ssouser 4096 Jul 11 20:20 OldFiles
      • -rw-r--r-- 1 joeuser ssouser 726 Sep 13 1993 READ.ME.NEW.SSO.USER
    • ls - a - lists all the files and directories in the specified directory. This includes the dot (.) files (system files), which do not appear in a ls command.
    • ls -al - lists the long format of all the files and directories, including the system files.
    • ls -F - lists the directory names and executable files only.
    • ls -R - recursively list files in all subdirectories, not just the subdirectory names.

File Manipulation

  • To copy files :
    • cp file1 file2
    • cp file(s) dirname
  • To rename files :
    • (Unix does not rename, it moves from one filename to another) mv oldname newname
  • To move files to a different directory.
    • mv file directory
    • mv file(s) directory
  • To remove (delete) files:
    • rm filename
    • rm file1 file2 .. fileN
    • rm -f filename - forced removal of a file
    • rm -i filename - interactive query before removal
    • rm -r filename - recursive delete - dangerous.
    • rm -rf dir(s) file(s) - recursive force - CAREFUL!!!

To Edit Files in Unix:

  • pico editor: 
    • This editor is the most user friendly of the Unix file editors. There are no special codes to type in text, and a command menu is available at the bottom of the screen. This editor also has a primitive spell checker.
    • Syntax: pico filename
    • The filename can be an existing file you want to edit, or a new file you want to create.
  • vim editor: 
    • This editor was designed for programming in the Unix environment. It is neither intuitive nor user friendly. It is difficult to use if you have not used the editor before. There is an insert and a command mode (typing can only be done in the insert mode).
    • Syntax: vim filename
    • The filename can be an existing file or a new file

Creating New Files in Unix

  • When creating new files remember Unix is case sensitive. A file named 'Test' will be different from the file 'test'.
  • File names can be 1 to 255 characters long.
  • File names may contain A-Z, a-z, 0-9, a period ., underscore _, or a dash -.
  • Try to avoid blanks, tabs, asterisks *, question marks ?, parentheses (), brackets [], braces {}, angle brackets <>, pipes |, slashes /\, or any control characters. These may cause problems because of complications with the Unix shell. File names containing these characters are usually hard to create, but not impossible.

Viewing Files without Opening

  • cat filename - concatenates and print. This will print out the contents of the file to the screen.
  • cat file1 .. fileN - Concatenate and print. This will concatenate several files together and print to the screen.
  • more filename - displays files one page (screen) at a time. Keeps one line of text from the previous screen.
  • page filename - displays files one page (screen) at a time. Does not keep any old text. Clears the screen before each new screen.
  • for both page and more:
    • spacebar - will advance to the next full screen.
    • carriage return - advances one line.
    • /pattern carriage return - finds next occurrence of the pattern in the file.

Disk Space

  • Disk space is shared on Unix. You are given a 500 megabyte allotment, initially, at Missouri S&T.
  • To determine amount of disk quota used
    • Run the command du -hs
    • This will output the amount of space your files are consuming.
  • If you receive disk space errors, or you can not write out files to your account, check your %Used. If you are close to 100% (depending on the size of the file you want to save), at 100% or over 100%, then you will not be able to write out any more information until some files are removed or the disk quota increased.
  • Certain types of files are unusually large and may be the bulk of a disk space problem. Postscript files and graphics files are normally the largest space users. This includes graphics for the World Wide Web.
  • "core" files can also take up several megabytes of space. These files are generated by programs that crashed and created the core file for debugging purposes. The core files should be removed, they are not needed by users.

RUNNING PROGRAMS/FILES UNDER UNIX

  • Under Unix users can run more than one process (program) at a time. You don't have to wait for one to complete to begin the next. This is called multi-tasking. It is done with time slices handed out to each process by the CPU.
  • Programs that are not interactive, meaning they do not prompt the user for input from the terminal/window, can be run in the background. By running a program in the background you still have a prompt that is usable, but the process will run to completion while you continue to work on other things.
  • To put a process (program) in the background, attach an ampersand at the end of the command.
    Example : ls -al&
  • When a background process ends you will receive a message to your terminal the next time you hit return.
  • To regain interactive control of a background process, bring the process to the foreground with the command fg.
  • To interrupt a command (or a process) issue the kill character : control+c.
    This will halt a process that was running in the foreground only. By pressing the control key and the c key at the same time you will send the command interrupt message to the current process. This is useful for exceptionally long directory listings that you want to halt, or runaway programs.

PRINTING FROM UNIX

There are two types of printing commands for Unix. One is lp and the other is lpr.
Commands:

  • To show the default printer : lpstat -d most will be set to mcs116dist
  • To print to the default printer : lp filename
  • To print to a specific printer : lp -d printer filename

Note: if no file name is given for either of the lp commands then standard input will be assumed


MISCELLANEOUS INFORMATION

There are several Unix commands that can make working under Unix easier.

  • date - prints the date and time.
  • who - prints a list of users logged in currently.
  • who am i - prints just who you are.
  • whoami - prints just your Username.
  • w (under BSD Unix only) - lists users currently logged in and what they are doing.
  • finger ssouserid - provides user information : name, last login time, etc.
  • man command - prints out the manual page for the specified command.
  • man -k keyword - prints a list of the commands containing that keyword.