For best entertainment links
To go to Session 1 click here
To go to Session 2 click here
To go to Session 3 click here
To go to UNIX basic commands click here
Online sample UNIX TERMINAL click here
To go to Session 1 click here
To go to Session 2 click here
To go to Session 3 click here
To go to UNIX basic commands click here
Online sample UNIX TERMINAL click here
Unix basics
File types
1.ordinary files – contains text or image does not have any other files in it
2.directories – branching points in hierarchy level directory tree. May contain other files , special files, other directories
3.special files – any devices connected to unix like(tape drives,printer, and terminal)
By default unix consider terminal as stdin as well as stdout(standard input and output)
Special files are normally stored under the directory /dev
4.pipes – temporary file used to link two commands together. (E.g) cat jai1.txt|more output of cat command is stored in a temp file pipe and sent to more command as input.
Symbol
|
File type
|
-
|
Normal file
|
D
|
directory
|
|
|
Symbolic link
|
B
|
Block device file
|
C
|
Character device FILE
|
P
|
FIFO or named pipe
|
File names
Unix file name can be upto 256 char, allows to use most char except spaces, tab spaces, and special symbols, unix is case sensitive.
Extensions can be used to identify the type of files.
.a archive file
.c c program fiile
.f forton file
.o object/executable file
.z compressed file
Hidden files begin with .(dot) example .login .mailrc .mwmrc
File names are unique that is under one directory two files cant have the same name.
Path names:
Path – location of a specific file or folder
Types of pathname
1.absolute pathname - starts with the root folder /
2.relative path name – does not start with root folder (E.g) ../bin ~/proj/rep.text
Unix commands:
OS is a set of programmed instruction that tells how to work.
An user interaction with OS can take place via command line interpreter (or shell) /terminal window.
Command cat – concatenate
This command concatenate file or files and puts it in the standard output device.
e.g 1: cat file1
cat file1 file2 concatenate file1 and file2 and puts in standard output.
Cat file1 file2 > file3 concatenate file1 and file2 and makes the file3.
Ls or directory command
Lists files and sub-directories in directory
ls – contents of directory
ls filename
ls directory (lists contents of directory)
ls –a list all files including hidden one
ls – al detail list of contents
ls –F marks directories with / and executable files as *
ls *.doc list all files with extention doc
ls –lt list with time of last modification
ls –lut show time of last time access
more command
one screen at a time
some helpful tips using more command is
h for help
space for page
b for back
q for quit
/string to search string
E.g cat file1.c|more
cp command
cp command used to copy files. This over writes a file until unless specified.
Syntax : cp [options] <source file/s> <destination directory/file>\
Options
|
function
|
-i
|
Promotes before overwriting
|
-r
|
Copies entire directory
|
cp f1 f2 copies f1 to f2
cp *.text dir copies all files with extention .text to directory dir
cp f1 f2 f3 f4 here f4 is taken as destination f1,f2,f3 as source
cp f1 dir copies file f1 to dir directory
cmp command
cmp command used to compare two files and find is that files identical
syntax:
cmp [options] file1 file2
E.g: cmp jc.txt jaya.txt
cmp –l jc.txt jaya.txt
mv command
move command mv moves file(s) to specified directory/file. To do this destination should have permission.
mv file1 file2
mv *.txt dir moves all files with extension .txt to dir directory
rm command
removes or deletes files or folders if permission allowed.
rm file1 removes file
rm ja?.txt deletes all text files with first two char ja and last four char .txt
rm –i * deletes all files in the current directory but asks for each file before deleting
rm –r/dir recursively delete all files including the directory
date,cal command
date displays the date and time
cal displays the current month calendar
cal 2012 displays the calendar 2012
cal march 2012 displays march calendar of 2012
the above can also be given as cal 3 2012
who command
shows all the user who have logged in
with login name,terminal type and number,date and time (* note this info is displayed to users those who r not logged in from the server)
whoami – displays self user name
who –q who without detail.
Command finger
This utility used to get list of user names,full name,terminal name,write status,idle time,login time,machine address.
Word count command
wc filename list the number of lines,words,char from a file
head command
Displays first n lines of a file
Tail command
Displays last n lines of a file
Uname command
Displays the name of the current system
Uname [-a] [-i] [-m] [-p][-r] [-s] [-v][-x][-s systemname]
Clear
To clear the screen
File
Determines the type of file
Which
Determines where is the executable for file for the given program
E.g – which perl , which java
Whereis
Locates binary,source and manual page files for a command
Syntax : whereis [-bmsu][-BMS directory] file name
-b searches only for binaries
-m searches only manual sections
-s searches only for sources
Directory Related commands
Pwd – current working directory
Mkdir – make directory
Rmdir – remove directory
Redirection and piping
Redirection – redirecting a command result to a file
Piping – result of one command is sent as input for another command
Redirection operators
Ø Indicates redirection of out put., send the output of a command to a file or printer.,
>> indicates redirection of out put of a command to a file which will be appended at last.
Unix wont show the out put in screen/std out put but redicted to a file
E.g
Cat >file
Cat file>file1
Cat file>>file1
< Indicates redirection of in put., takes the input from a file for a command rather than keybord.,
E.g
Cat<file
Piping Example
$ls |wc –l
Output of ls is given as output of wc command.
Pipe with redirection
$ls|wc –l>countfile
$who|sort
$who|sort>sorted
Click here for Unix Session 2
pls post ur comments to encourage me friends. thanks in advance
ReplyDeletegood try da.
ReplyDeletethanks a log ig.
Deletegood try da.
ReplyDeletehi jaya...
ReplyDeleteMay i know the importance of UNIX nowadays?
hi jaya...
ReplyDeletein which applications and all using Unix nowadays?
hi Jaya...
ReplyDeleteCan u please explain about "grep" with expansion and detailed explanation?
grep is very simple command used to find a text/pattern within a file.
Deletesyntax of grep is as follows
grep [options] pattern [file...]
grep [options] [-e pattern | -f file] [file..]
-v Print all lines that do not match pattern.
-n Print the matched line and its line number
-l Print only the names of files with matching lines
-c Print only the count of matching lines.
-i Match either upper- or lowercase
great work bro
ReplyDeleteCan u explain UNIX commands are case sensitive?
ReplyDeleteCommand cat – concatenate
ReplyDeleteThis command concatenate file or files and puts it in the standard output device.
e.g 1: cat file1
cat file1 file2 concatenate file1 and file2 and puts in standard output.
In above your example may i know after concatenate which file(file1 or file2)will be in Std Output device?