0% found this document useful (0 votes)
35 views

(Compatibility Mode

This document provides an overview of the UNIX operating system, including its history, features, basic components and commands. It describes what UNIX is, how it was developed in the 1960s-1970s, and its main components like the kernel, shell, file system and standard utility programs. It also summarizes basic UNIX commands for working with directories, running programs, and interacting with the shell.

Uploaded by

sainandha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

(Compatibility Mode

This document provides an overview of the UNIX operating system, including its history, features, basic components and commands. It describes what UNIX is, how it was developed in the 1960s-1970s, and its main components like the kernel, shell, file system and standard utility programs. It also summarizes basic UNIX commands for working with directories, running programs, and interacting with the shell.

Uploaded by

sainandha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

UNIX

What is UNIX? Basic UNIX Commands Working with Directories Running Programs Editors The Shell Exercise

What is UNIX?
Unix is a operating system A software development environment Built in late '60s, early '70s by Ken Thompson and Dennis Ritchie Originally written in assembler, later rewritten in C (allowing greater portability), a language invented by Ritchie.

What is Operating Systems?


The operating system is the master controller of the computer The glue that holds together all the components of the system Including the administrators, programmers and users.

UNIX Features

Basic X Concepts
X Server runs on local machine
PC Apple Mac Exceed UNIX Workstation Included in OS Exodus

X Client runs on remote machine


Graphical Application
xterm file manager Modelling Package

Basic X Concepts

UNIX Internals (Simplified)


Kernel
System Internals

Shell
Command Interpreter Programming language

File System Process Management

UNIX Structure

UNIX Shells
C-Shell Bourne Shell Korn Shell T-Shell bash

Parts of UNIX
The kernel The standard utility programs The system configuration files.

The kernel
The kernel is the core of the Unix operating system. The kernel is a large program that is loaded into memory when the machine is turned on, and it controls the allocation of hardware resources from that point forward. The kernel knows what hardware resources are available (like the processor(s), the on-board memory, the disk drives, network interfaces, etc.), and it has the necessary programs to talk to all the devices connected to it.

The standard utility programs


These programs include simple utilities like cp, which copies files, and complex utilities, like the shell that allows you to issue commands to the operating system.

The system configuration files


The system configuration files are read by the kernel, and some of the standard utilities. The Unix kernel and the utilities are flexible programs, and certain aspects of their behavior can be controlled by changing the standard configuration files. One example of a system configuration file is the filesystem table "fstab" , which tells the kernel where to find all the files on the disk drives.

Accessing a Unix System

Session Startup

Your Home Directory

Interacting with the shell

Entering shell commands


The basic form of a Unix command is: commandname [-options] [arguments] The command name is the name of the program you want the shell to execute. The command options, usually indicated by a dash, allow you to alter the behavior of the command. The arguments are the names of files, directories, or programs that the command needs to access.

Entering shell commands contd


The square brackets ([ and ]) signify optional parts of the command that may be omitted. EXAMPLE: Type the command ls -l /tmp to get a long listing of the contents of the /tmp directory. In this example, "ls" is the command name, "-l" is an option that tells ls to create a long, detailed output, and "/tmp" is an argument naming the directory that ls is to list.

Aborting a shell command


Most Unix systems will allow you to abort the current command by typing Control-C. To issue a Control-C abort, hold the control key down, and press the "c" key.

Special characters in Unix


Unix recognizes certain special characters, called "meta characters," as command directives. The shell meta characters are recognized anywhere they appear in the command line, even if they are not surrounded by blank space. For that reason, it is safest to only use the characters A-Z, a-z, 0-9, and the period, dash, and underscore characters when naming files and directories on Unix.

Special characters in Unix contd...


If your file or directory has a shell meta character in the name, you will find it difficult to use the name in a shell command. The shell meta characters include: \/<>!$%^&*|{}[]"'`~; Different shells may differ in the meta characters recognized.

Rules of Unix
UNIX is case sensitive Commands are in lower case Backspace and Del Keys correct typing errors Ctrl U clears the command line Ctrl C Aborts a program or command Do Not use the arrow keys

File System
All files are "flat": just a sequence of bytes File system is hierarchical

File System

File System

File System

Filenames
Filenames can comprise: a-z, A-Z alphabetic characters 0-9 digits .-_+ special characters mon+tue_01.06-03-96 Wildcards * means any character or sequence of characters

Format of UNIX commands


command [option ...] [filename ...] eg: ls ls -l tutorial more tutorial

List Directory

ls ls -l ls -a
-rw------ l

list directory list directory in long format list all (inc. hidden) files
course01 57 Oct 18 11:05 hello.c

Access Permissions

Number of bytes in file

Date and time last modified

Displaying a Text File

more

filename

Spacebar next screenful Enter next line q quit ? list commands

Copy, Rename and Remove

Copy a file cp oldfile newfile Rename a file mv oldname newname Remove a file rm afile

Searching Files

grep string file string = word or phrase file = file or list of files

Redirection

The output of a command usually goes to the screen Redirect the output to a file using > ls -l > dirlist

Piping

Feeding the output of one command into the input of another command The symbol | is called a pipe command | command eg: ls -al | more
ls -la | grep Nov

Manual Pages

man command man - k topic man - k topic | more

Directories

pwd cd cd cd .. cd mydir cd /var/adm

print working directory change directory move to home directory move up one level move into a subdirectory move to an absolute directory

Running programs
Two modes of operation foreground and background
Foreground Interact with program via keyboard/screen Background No connection with keyboard/screen Submit to backbround by Appending & EG: myprog > myfile &

The symbols >& redirect output and any errors to the file myfile

Another method of submitting programs to the background is via a batch processing system, such as Sun Grid Engine (as used on Titania)

Foreground Program Control

Kill a program Ctrl C Stop a program Ctrl Z Note a stopped program still exists in the system

Program control using ps and kill


ps Report process status
TIME 0:00 0:01 0:00 CMD sleep 2 -csh /bin/sh time.sh

ps -f -u username
UID PID PPID C STIME TTY username 24816 24585 0 16:23:04 pts/50 username 20169 19956 0 16:05:45 pts/50 username 24585 20169 0 16:35:07 pts/50

kill
kill 24585

Terminate process

Find its process ID (PID) using the ps command Kill the process using the kill command Sometimes kill on its own does not work so try
kill -KILL 24585

T-Shell - Filename Completion


Complete a partially typed filename
Operation
Type enough characters to uniquely identify the name Press the Tab key (for C shell use Esc key) If the response is a bleep press Ctrl-d to list possible matches

Setup
Add the following to your .cshrc file set filec

T-Shell -Repeating Previous Commands


Operation
history !! !n !str List previous commands re-run last command re-run the nth command last command starting with str

eg: Setup

!vi

Add the following to your .cshrc file set history=40

T-Shell - Command Aliasing


Definitions
alias alias alias ll h dir ' ls -lF ' ' history 24 ' ' ls '

Setup
Add alias definitions to your .cshrc file

You might also like