Showing posts with label STUDY OF UNIX OPERATING SYSTEM. Show all posts
Showing posts with label STUDY OF UNIX OPERATING SYSTEM. Show all posts

Wednesday, March 4, 2015

Regular Expression

Command                                                       Function
grep this demo                            Lists the lines that contains the string this
grep 'end of' demo                      Quotes mandatory for text containing space
grep this demo*                          Search this in multiple files
grep –c to demo                             Number of occurrence of the word to in the file
grep –n sequence demo                   Display line numbers along with matching lines
grep –v word demo                     Displays lines that does not contain the text word
grep –l vim *                               Displays files containing text vim
grep –i WORD demo                  Search for text ignoring case differences
grep '^[0-9]' demo                     Lines that start with a number
grep '[0-9]$' demo                     Lines that end with a number
ls -l | grep "^d"                      Display the subdirectory names
grep –c "^$" demo                   Display count of blank lines in the file.
grep "2....$" stud                      Display lines that ends in the range 20000–29999
egrep "lower|UPPER" demo         Display lines that match either lower or upper
egrep "(previous|current)
word" demo                              Display lines that match either previous word or current word

Tuesday, March 3, 2015

Simple Filters

Command                                                       Function
head                                               􀊊used to display the first few records (10 records by default)
head stud                                           Displays first 10 records by default
head -5 stud                                       Displays first 5 records
head -1 stud | wc –c                                 length of first record
tail􀊊                                                 used to  display the last few records (10 records by default)
tail stud                                                   Displays last 10 records by default
tail -5 stud | tee last5                               Last 5 records listed & stored in file last5 using tee
cut􀊊used to extract specific field         The d option specifies the delimiter and f for specifying the field list.                                                              The c option may be used if extraction is done character wise
cut –d \| -f 1,3,4 stud                                          Fields 1,3,4 listed
cut –d \| -f 2-4 stud                                            Fields 2,3,4 listed
paste –d \| list1 list2                                 merges two cut files list1 and list2
sort                              􀊊reorders the file as per ASCII sequence. The t option is used to specify delimiter and k option to specify the field
sort stud                                                Sorted on 1st column by default
sort –t \| -k 3                                                stud Sort as per 3rd column
sort –c stud                                           Check if file is sorted using c option
sort -t \| -k 4,4 -k 3,3
stud
Sorting on secondary keys
sort -t \| -nr –k 4 stud                        Sort on numeric field using n option, r for reverse
uniq stud                                        Display unique entries in a sorted file

Monday, March 2, 2015

File commands

Command                                               Function
cat > filename                                   To create a file with some contents. To end typing press Ctrl+d.
The > symbol means redirecting output to a file. (< for input)
cat filename                                           Displays the file contents.
cat >> filename                                   Used to append contents to a file
cp src des                                          Copy files to given location. If already exists, it will be overwritten
cp –i src des                                     Warns the user prior to overwriting the destination file
cp –r src des                                      Copies the entire directory, all its sub-directories and files.
mv old new                                        To rename an existing file or directory. –i option can also be used
mv f1 f2 f3 dir                                     To move a group of files to a directory.
mv –v old new                                    Display name of each file as it is moved.
rm file                                                Used to delete a file or group of files. –i option can also be used
rm *                                                  To delete all the files in the directory.
rm –r *                                              Deletes all files and sub-directories
rm –f *                                                To forcibly remove even write-protected files

Sunday, March 1, 2015

BASIC COMMANDS - Unix

General commands
Command                 Function
date                 Used to display the current system date and time.
date                +%D Displays date only
date                +%T Displays time only
date               +% Y Displays the year part of date
date               +% H Displays the hour part of time
cal                 Calendar of the current month
cal year           Displays calendar for all months of the specified year
cal month year Displays calendar for the specified month of the year
who               Login details of all users such as their IP, Terminal No, User name,
who am i        Used to display the login details of the user
tty                   Used to display the terminal name
uname           Displays the Operating System
uname –r        Shows version number of the OS (kernel).
uname –n           Displays domain name of the server
echo "txt"          Displays the given text on the screen
echo $HOME       Displays the user's home directory
bc Basic calculator. Press Ctrl+d to quit
lp file                     Allows the user to spool a job along with others in a print queue.
man cmdname         Manual for the given command. Press q to exit
history              To display the commands used by the user since log on.
exit                       Exit from a process. If shell is the only process then logs out

Saturday, February 28, 2015

FILE SYSTEM

A file in UNIX is nothing but a storehouse of information and everything is treated as a file by UNIX. The files can be broadly classified as follows:
􀂾 Ordinary files—Contains stream of data. All data, text, source programs, object and executable code, commands fall into this category.
􀂾 Directory files—Contains no external data. It contains an entry, name of the file and its inode (identification number) for each file and subdirectory under that directory.
Directory files are not created by the user but by the UNIX system itself.
􀂾 Device files—Even physical devices are treated as files. These are special in the sense that any output directed to it will be reflected onto the respective device.


All files in UNIX are related to one another. The file system of UNIX resembles a tree that grows from top to bottom as shown in the figure. The file system begins with a directory called root (at the top). The root directory is denoted by a slash (\). Branching from root there are several directories such as bin, lib, etc, tmp, dev. Each of these directories contains several sub-directories and files.

Friday, February 27, 2015

ORGANIZATION OF UNIX

The UNIX system is functionally organized at three levels and are:
1. The kernel, which schedules tasks and manages storage;
2. The shell, which connects and interprets users' commands, calls programs from memory, and executes them; and
3. The tools and applications that offer additional functionality to the OS


The kernel is the heart of the system, a collection of programs written in C that directly communicate with the hardware. There is only one kernel for any system. It's that part of UNIX system that is loaded into memory when the system is booted. It manages the system resources, allocates time between user and processes, decides process priorities, and performs all other tasks. The kernel, in traditional parlance, is often called the Operating system.
The shell, on the other hand, is the "sleeping beauty" of UNIX. It is actually the interface between the user and the kernel. The shell is the agency which takes care of the features of redirection and has a programming capability of its own.
The Tools and Applications consist of Application Software, Compilers, Database Package, Internet tools, UNIX commands, etc.

Thursday, February 26, 2015

STUDY OF UNIX OPERATING SYSTEM


OPERATING SYSTEM
An Operating System is a set of programs that
􀁸 Functions as an virtual machine by presenting an interface that is easier to program than the underlying hardware
􀁸 Acts as resource management through orderly and controlled allocation of the processors, memories, and I/O devices among the programs competing for it.
OS TYPES
1. Single User—The system will have its own hard disk, memory, CPU and other resources all dedicated to a single user. Eg. MS-DOS
2. Multi User—The users having access to a multi-user system will have just a terminal and a keyboard. The other resources such as hard disk, printers are centrally located.
The user is expected to simply hook onto his account, perform the work, disconnect and leave quietly. Eg. UNIX

UNIX FEATURES
1. Multi-user system—Multi-user capability of UNIX allows several users to use the same computer to perform their tasks. Several terminals [Keyboards and Monitors] are connected to a single powerful computer [UNIX server] and each user can work with their terminals.
2. Multi-tasking system—Multitasking is the capability of the operating system to perform various task simultaneously, i.e. a user can run multiple tasks concurrently.