Lecture-2_Linux Arch Vi
Lecture-2_Linux Arch Vi
Linux Architecture
Shell
Vi Editor
Q&A
Operating System (OS)
What is an OS?
Why OS?
How it works?
Types of OS?
On to Linux • Courtesy XKCD.com
Linux
Linux: A kernel for a Unix-like operating system.
Shells – applications that interpret the commands from the user. They
are active in the textual mode or terminal mode. Shells can also
execute script files. Examples: bash, tcsh, zsh, sh, etc.
• bootstrapping is the process of starting a large and complicated system via a number of very small steps.
• A characteristic feature of bootstrapping is that the wonderful and powerful functions of a large system
cannot be used to start the system itself – they are simply not yet available because the system is not
running.
Loading Linux (1)
The initial loader loads a more
BIOS loads initial boot powerful loader which possibly
loader from master does not use bios anymore
boot record on disk
master
boot lilo or grub linux kernel
loader
• Linux loaders are lilo or grub which are both found under /boot.
• The difference is that lilo knows exactly at which block of the partition the linux kernel starts and how big it is.
• It does NOT understand the linux filesystem and takes the information about the kernel from when the kernel
was installed under /boot and lilo was re-run.
• Grub understands the filesystem and can locate the kernel within.
Loading Linux (2): System Check and
Autoconfiguration
✓ During system start the following functions are performed:
• determine CPU type, RAM etc.
• stop interrupts and configure memory management and kernel stack
• Initialize rest of kernel (buffers, debug etc.)
• Start autoconfiguration of devices from configuration files and via probing hardware addresses.
✓ init: the first process and the only one started by the kernel itself. Starts other
processes e.g. User is waiting for logins from terminals
✓ Swapper and other system processes (yes, the kernel depends on processes
running in user mode)
✓ Shell scripts basically initialize the whole system once the kernel itself is
running.
Shell
• a very powerful
• but at the same time it is cryptic
• It is hard to learn, specially for windows users
So Practice…
Vim equals Vi
You exit the input mode by pressing the Esc key to get back to the command mode
How to exit from vi
:q! <enter> is the forced quit, it will discard the changes and quit
- - (minus) moves the cursor to the first character in the current line
( - moves the
} - move the cursor
) - moves cursor to cursor backward to
to the beginning of
the next sentence the beginning of the
next paragraph
current sentence
Control-b scrolls
Control-f scrolls
the screen
the screen forward
backward (full
(full screen)
screen).
Entering text
• To enter the text in vi you should first switch to input mode
• To switch to input mode there are several different commands
• a - Append mode places the insertion point after the current character
• i - Insert mode places the insertion point before the current character
Entering text
O - places the
R - starts the
insertion point
replace(overwrite)
before the current
mode
line
Editing text
d - is the delete command but pressing only d will not delete anything you
need to press a second key
• dw - deletes to end of word
• dd - deletes the current line
• d0 - deletes to beginning of line
c - this command deletes the text specified and changes the vi to input mode.
Once finished typing you should press <Esc> to go back to command mode
• n<command key(s)>
• For example dd deletes a line 5dd will delete five lines.
p - Paste the
yy - (yank) copy
nyy - Where n is yanked lines from
current line to
number of lines buffer to the line
buffer
below
vi myscript.sh