08448380779 Call Girls In Civil Lines Women Seeking Men
Introduction to UNIX Operating System and Commands
1. Introduction
UNIX Architecture
UNIX file system
Relative & Absolute path
File permission
Directory related commands
Files related commands
Miscellaneous commands
Presented by – Anil Kumar Kapil
February 7, 2014
UNIX
2. INTRODUCTION
What is UNIX?
Available in different flavors
An operating system
Invented in 1969 at AT&T Bell Labs
Command Line Interpreter
GUIs (Window systems) are now available
Written in the C programming language.
Multi-user : Several people can use a UNIX computer at the same time
Multi-process : A user can also run multiple programs at the same time
Solaris (Sun),
AIX (IBM)
Linux (open source)
Irix (SGI)
Berkeley
Unix is case-sensitive.
February 7, 2014
3.
The UNIX operating system is made up of
three parts; the kernel, the shell and the
programs.
Commands and Utilities: There are various
command and utilities which you would use in
your day to day activities. cp, mv, cat and grep
etc.
Shell: Shell is an interface between user and
kernel. Shell interprets your input as
commands and pass them to kernel.
Utilities and Programs
User Interface
Operating System
Computer
Hardware
Unix Kernel
Kernel : The kernel is the heart of the
operating system. It interacts with hardware
and most of the tasks like memory
management, task scheduling and file
management .
Shell
(sh, bash, tcsh, ksh …)
cp, cat, rm, mv, grep, find, ls etc…
February 7, 2014
UNIX ARCHITECTURE
4. UNIX FILE SUBSYSTEM
All data in UNIX is organized into files. All files are organized into directories. These
directories are organized into a tree-like structure called the filesystem.
In UNIX, data, directory, process, hard disk etc (almost everything) are expressed as a
file.
Basic Directory Terms
Home directory
The home directory is a directory assigned to a user. When you log
in, your working directory will be set to your home directory
Root directory
Top of a file tree
Current directory Directory you’re in now
Dot (.)
Another term for the current directory
Dot-dot (..)
Parent of the current directory
Tilde (~)
$HOME directory
February 7, 2014
5. UNIX FILE SUBSYSTEM
February 7, 2014
NOTE: Unix file names
are CASE SENSITIVE!
Important
Directories
/bin This contains files that are essential for correct operation of the system. These are
available for use by all users.
/home This is where user home directories are stored.
/var This directory is used to store files which change frequently, and must be available to be
written to.
/etc Various system configuration files are stored here
/dev This contains various devices as files, e.g. hard disk, CD- ROM drive, etc.
/sbin Binaries which are only expected to be used by the super user.
/tmp Temporary files.
6. UNIX FILE SUBSYSTEM
In UNIX there are three basic types of files:
Directory is a special file that contains the names of other files and/or
subdirectories..
Regular file holds ASCII text, binary data, image data, databases, applicationrelated data, and more
Symbolic link. A type of file that point to another file
Every file has a data structure (record) known as an I-node that stores
information about the file, and the filename is simply used as a reference to
that data structure.
February 7, 2014
7. UNIX FILE TYPE
Regular file :
Most common file type found in the Solaris Operating
Environment
Store different kinds of data.
Regular files can hold ASCII text, binary data, image data,
databases, application-related data, and more.
February 7, 2014
8. UNIX FILE TYPE
Directory file :
Directories store information that associates file names with
inode numbers.
Unlike regular files that can hold many different kinds of data,
directories can hold only one kind
February 7, 2014
9. UNIX FILE TYPE
Symbolic link :
A symbolic link is a file that points to another file.
Like directories, symbolic links contain only one kind of data.
A symbolic link contains the pathname of the file to which it
points.
February 7, 2014
10. RELATIVE & ABSOLUTE PATH
Path means a position in the directory tree.
Relative path
Absolute path
starts from current working directory
If you are already in the users directory, the
Relative pathname for file1 is usern/file1
start from root (/) and follow the tree
The absolute pathname for file1 is
/users/usern/file1
Specifying Paths
What is the absolute path to index.html?
What is the relative path to index.html
(assuming that usern is your pwd)?
February 7, 2014
11. LISTING FILES
ls: To list the files and directories stored in the current directory.
Syntax: ls [<file> … ]
ls - short listing
ls -l - long listing
ls -a list all the files including hidden files that start with . .
ls –lt list all files names based on the time of creation, newer files bring first.
ls –R lists all the files and files in the all the directories, recursively.
Example: ls –l backup
-rw-r--r-drwxr-xr-x
lrwxr-xr-x
1 ian wheel
4 ian admin
1 ian admin
9218
136
16
21
17
6
Aug 14:49
Jan 16:31
Jan 19:31
support.dat
talk-others
w -> /shared/w
In the ls -l listing example, every file line began with a d, -, or l. These characters indicate
the type of file
Prefix
Description
-
Regular file, such as an ASCII text file, binary executable, or hard link.
D
Directory file that contains a listing of other files and directories.
L
Symbolic link file. Links on any regular file.
February 7, 2014
12. FILE PERMISSION
Suppose you type in ls -l and the result is
Typesrwx r-x r--access supported22:28UNIX.
of file 1 hans doc 858 Aug 22 by hw1
-
r – read only permission
What do all these symbols mean?
w –write permission
x –execute permission
in case of directory, “x” grants permission to list directory contents. It signifies whether you are
permitted to search files under the directory
Unix users can be classified into these categories:
User – the user who created the file.
Group – the group owns the file.
Other – the rest of the world
February 7, 2014
13.
Chmod Change the access mode of one or more
files
Symbolic mode
Whose (user, group, or others) permissions you want to change
What (+ to add, - to subtract, = to equal) operation you want to
perform on the permission
The permission (r, w, x)
Numeric modes
Permissions are stored in the UNIX system in octal numbers.
An octal number is stored in UNIX system using three bits
Bit 1, value 0 or 1 (read permission) , weight 4
Bit 2, value 0 or 1 (write permission), weight 2
Bit 3, value 0 or 1 (defines execute permission),
weight 1
For example, a value of 101 will be 5. (The value of
binary 101 is (4 * 1) + (0 * 1) + (1 * 1) = 5.)
Examples:
umask: Each time a file is created, its initial file mode
is defined by applying the current value of the file
creation mask
chmod o+r file.txt
chmod u+x file.txt
chmod u=rwx, g=r, o=wr my_file
umask Show see the current value of the file creation mask
umask 077 To change the value of the file creation mask
chgrp: change group of the file
chown: change owner of the file
Examples
chmod 751 my_file
-R recursively descend through directory changing
group of all files and subdirectories
February 7, 2014
FILE PERMISSION
14.
pwd: the absolute pathname of your current working directory
cd: Change directory
Examples:
cd backups/unix-tutorial
cd ../class-notes
cd ~
cd ..
February 7, 2014
WORKING WITH DIRECTORIES
15.
cat: Display the contents of file
Syntax: cat <file>
Examples:
cat /export/home/xyz.txt cat displays a file with no page breaks
cat file1 file2 >file3 concatenates file1 and file2, and writes the results in
file3. If no input file is given, cat reads
from the standard input file.
cat /dev/null/ > message.log To Cleanup a file content :
# /dev/null/ acts as a black hole from where anything directed to or read from is set as Null.
more: displays a file one screenful at a time
more file1
cp: Copy file
Syntax: cp [options] <sources> <destination>
Options:
-i Interactive. cp prompts for confirmation whenever the copy would overwrite an existing target. A Y answer means that the
copy should proceed. Any other answer prevents cp from overwriting target.
-r Recursive. cp copies the directory and all its files, including any subdirectories and their files to target.
cp tutorials.txt tutorial.txt.bak
cp –r dir1 /export/home/bsarda/dir2
touch: update the access and modification times of given file
touch a.txt
-a - Changes the access time of file.
-m Changes the modification time of file.
February 7, 2014
FILES RELATED COMMANDS
16.
rm: remove file
Syntax: rm [options] <file>
Examples:
rm tutorials.txt
rm -rf /export/home/anil/dir2/ --This will remove files (write-protected too becoz of –f option) recursively from the
directory. If the dir is write-protected then it cant.
mv: Move/Rename file/directory
Syntax: mv [options] <sources> <destination>
Examples:
mv tutorials.txt tutorial2.txt
mv tutorials.txt /export/home/anil/dir2/
head: Showing first “n” lines of file, by default will display the first 10 lines of a file
Syntax: head –n file1
Examples:
head -20 tutorials.txt
tail: Showing last “n” lines of file, by default will display the last 10 lines of a file
Syntax: tail –n file1
Examples:
tail -20 tutorials.txt
wc: counts the characters, words or lines in a file depending upon the option.
wc -l filename print total number of lines in a file.
wc -w filename print total number of words in a file.
wc -c filename print total number of characters in a file.
diff: compare the two files and print out the differences
cmp: compare the two files and print out the differences
February 7, 2014
FILES RELATED COMMANDS
17.
man: This is help command, and will explains you about
online manual pages
date: Display date and time
date + “%m-%d-%y %H:%M:%S”
date + “%D” -- mm/dd/yy
date + “%T” --hh:mi:ss
To get year as 2009 in full use „Y‟ otherwise „y „will give 09 only.
# To have a new line in between Date and Time use %n like
$date “+Date : %D %n %T” will give the output as
Date: 09/19/08
09:29:28
banner: prints characters in a sort of ascii art poster
cal: print the calander on current month by default
Examples:
banner wait
Syntax: tail –n file1
Examples:
cal 8 1965 print calander of august of 1965
sleep
Examples:
sleep 10 Tell a shell script to pause for 10 seconds
env: See environment variables
clear: clear the screen
dircmp: compares two directories.
Example :If i have two directories in my home directory
named dirone and dirtwo and each has 5-10 files in it. Then
dircmp dirone dirtwo will return this
Dec 9 16:06 1997 dirone only and dirtwo only Page 1
./cal.txt
./fourth.txt
./dohazaar.txt
./rmt.txt
./four.txt
./te.txt
./junk.txt
./third.txt
February 7, 2014
MISCELLANEOUS COMMANDS
18. TEXT PROCESSING COMMANDS
echo
sort: sort command sort the lines of a file or files, in alphabetical order
Example:
sort file.txt
sort -r file.txt
sort –f file.txt
sort –n file.txt
sort -k3 file.txt
cut: selects a list of columns or fields from one or more files
-- display in reverse order
-- ignore case
-- numerical order
-- Sorts using the third field of each line
cut –d „ „ -f 1,2,11, 15-20 file.txt
cut –c 1-8 file.txt it will extract first 8 characters of every line in the file.
uniq: removes duplicate adjacent lines from sorted file while sending one copy of each second file
Examples
sort names | uniq -d will show which lines appear more than once in names file
Options:
-c print each line once, counting instances of each.
-d print duplicate lines once, but no unique lines.
-u print only unique lines
tee: Put output on screen and append to file
Examples
who | tee -a > <file>
February 7, 2014
19. VIEWING & SETTING ENVIRONMENT VARIABLES
env
PATH Variable
Which
List of places (directories) on the system where the shell should look to locate a command. Each command you type is
physically located as a file somewhere on your file system
To find whether a particular command exists in you search path. If it does exist, which tells directory contains that command
Where
February 7, 2014