0% found this document useful (0 votes)
37 views14 pages

Linux by Aravind

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 14

Overview

Hardware ===kernel=== OS

OS ===Shell=== User

•Kernel is a set of device drivers.


•Kernel plus additional software's will form an OS.
•Shell is a place where user executes a command.
Unix Architecture
UNIX History
• UNIX Was originally developed for internal use at At&T by ken Thompson
and Dennis Ritchie in 1969

• At&T licensed the source code widely allowing many companies to modify
and produce UNIX like OS.
• AIX from IBM
• Solaris from SUN
• HP/UX from HP

• GNU/ free software foundation :


• The goal of this project is to create free UNIX clone

• GPL (general public licensing)


• Primary license for open source software
Linux versions

Linux Kernel combined with GNU applications formed free UNIX like OS

Red hat Linux has 3 types of version of Linux for different level of users

• RH AS Advanced Server
• RH ES Entry Level Server
• RH WS Work Station

• Hardware Requirements:
• RHEL AS for very large servers - more than 2 cpu , more than 8 gb ram
• RHEL ES servers with limited requirements- upto 2 cpu & 8gb ram
• RHEL WS-desktop, 1 cpu , 256 MB RAM
Linux consoles and prompt
• Linux has text and GUI based consoles for multi logging and multi
tasking.

• Alt+Ctrl+F1-Alt+Ctrl+F6 text based console


• Alt+Ctrl+F7 GUI based console

• Linux has two prompts # and $ prompts

• [root@server ~]# roots shell prompt


• [aravind@server ~]$ users shell prompt
Running commands and getting help

• Running commands

• --help
• Whatis
• Man
• Info
• /usr/share/doc

• Commands have the following syntax:


• Command [options] [arguments]
Browsing the File system

• date shows date and time


• cal shows the calendar
• pwd shows the current working directory
• cd changes the current working directory
• ls list the contents in the directory
• cp copy files
• mv move files
• rm remove files
• mkdir makes directory
• rmdir removes directory
• touch creates empty files
• cat show the contents of a file
• history shows previously executed commands
Vi Editor
• Vi modes
• 1. command mode
• 2. insert mode -- i
• 3. exit mode

• Insert mode
• a appends after the cursor
• A appends to the end of line
• i insert before the cursor
• o opens a line below
• O opens a line above

• Exit mode
• w write
• q quit
• wq write and quit
Vi Editor continued
Command mode
Copy/yank lines yy
Paste lines p
Delete lines dd
Undo the changes u
Redo ctrl+r

File Repositioning
G goes to the last line in a file
nG goes to the nth line in a file

Setting line numbers


:set nu sets the line numbers in a file
:set nonu removes the line numbers in a file
Vi search and replace
• Search a pattern in a file
• /searchpattern
• n goes to the next search
• N goes to the previous search

• Search and replace


• :%s/old/new/g
• 1,16s/old/new/g

• r newfile inserts newfile contents


• r !date inserts output of date command in the file
• 1,20w file1 writes 1-20 lines to file1
• 1,20w >> file2 appends 1-20 lines to file2
• n file3 opens another file
• n# toggle between two files
Standard I/O and Pipes

• Linux provides three i/o channels

• Standard input keyboard


• Standard output terminal window
• Standard error terminal window

• > direct standard output of a command to a file.


• >> appends standard output of a command to a file.
• < command receives its input from a file.
• 2> error messages from the command are redirected to a file.
• 2>> error messages from the command are appended to a file.
• 2>&1 redirects both error and output to a file.
Introduction to string processing

• head
• Displays first few lines (default: 10 lines) of text in a file
#head output.txt
• Use –n parameter to change number of lines displayed.
#head –n 20 output.txt

• tail
• Displays last few lines (default: 10 lines) of text in a file
#tail output.txt
• Use –n parameter to change number of lines displayed.
#tail –n 20 output.txt

• Use –f to follow the end of a text file as it changes


• tail –f /var/log/messages (Used to watch log files.)
Introduction to string processing continued
• sort: sorts text to stdout.
• -r does a reverse sort
• -u removes duplicated lines

• uniq: removes duplicated lines in a file


• -c to count number of occurrences of duplicated data

• cut: displays specific columns of file data


• $ cut –f4 –d: /etc/passwd

• Where -f defines the filed and -d defines the delimiter used in the
file.
• -c cuts by characters
• $ cut –c2-5 /result.txt
Introduction to string processing continued

• tr: character translator


• $ tr ‘a-z’ ‘A-Z’ result.txt

• diff: compares two files for differences


• $ diff file1 file2

• aspell: interactive spell checker.


• $ aspell check result.txt

You might also like