Day 1 - Introduction to UNIX and Basic Commands
description
Transcript of Day 1 - Introduction to UNIX and Basic Commands
Class 1
Introduction to UNIX and Basic Commands
UNIX
An Operating System is a resource manager. It consists of a set of software programs (routines) that allow users and applications to access system resources in a secure, efficient and abstract manner UNIX is the first serious OS created in 1969Unix is a multi-tasking OS; It can perform multiple tasks at the same timeIt is a multi-user OS; several users can use the same computer/OS at the same time
UNIX
More importantly for today’s networked world: UNIX is the most stable OS with powerful networking capabilitiesUnix-based machines come in different names from various vendors:
- Sun Microsystems – Sparc, Solaris- IBM – AIX- HP computers – HP-UX- Macintosh – MacOS-X
UNIX Architecture
Layered architecture: 3 parts (kernel, shell, programs)Kernel: is the core of the UNIX OS. It is in direct control of the underlying hardware and provides the low-level processor, memory and device management functionsExample: allocating memory for programsShell: Acts as the interface between the user and the kernel
UNIX Architecture
The user issues a command to the shell which interprets it and requests the kernel through system calls and thus arranges for its executionAfter the command completes execution, the shell returns the UNIX prompt to the user indicating it is waiting for further commandsSeveral shells – Bourne (sh), C-shell (csh), Bourne Again shell (bash), Korn shell (ksh)The core features present in all; differ in additional features
Files & Processes
Everything in UNIX is represented a file or a processA file is a collection of data; could be text or binaryA process is a currently executing program uniquely identified by a PID (Process Identifier)
UNIX Directory Structure
The UNIX directory structure or file system is arranged hierarchically, like an inverted treeThe top of the hierarchy is called the root denoted by a ‘/’
Paths
Absolute path – always starts from the root ‘/’Relative path – relative to the current working directoryCurrent directory: represented by a single dot – ‘.’Parent directory: represented by 2 dots – ‘..’Home directory: represented by a tilde – ‘~’
UNIX Commands
0) man – display the manual for a command1) date – display today’s date2) clear – clear screen3) echo – echo content4) cd – change directory5) mkdir – make a new directory6) pwd – display the present/current working
directory
More Commands
7) rmdir – remove directory8) ls – list contents of a directory9) cat – display contents of a file10) head – display head (first 10 lines) of a file11) tail – display tail (last 10 lines) of a file12) more – display a file page-wise13) wc – display number of lines, words and
characters in a file
More Commands
14) mv – move/rename a file/directory15) cp – copy a file16) rm – delete/remove a file17) sleep – delay for a specified period of time
chmod Command
18) chmod – change permissions on a file/directory
Permission values: 4 – read (r) / 2 – write (w) / 1 – execute (x)Example: chmod 644 fileName
– sets permissions of rw-r--r-- for fileNameThe first digit is for owner, the second digit for the group that the owner belongs to and the third digit for everyone in the system
Process Manipulation commands
Process is an executing program uniquely identified with a PID (Process Identifier)
19) ps – lists all processes20) kill – kill/stop a process
kill -9 – Forcibly kill a process