Você está na página 1de 6

EX No 1

STUDY OF LINUX

OPERATING SYSTEM

An operating system (commonly abbreviated OS and 0/5) is the software component of a


computer system that is responsible for the management and coordination of activities
and the sharing of the limited resources of the computer. The operating system acts as a
host for applications that are am on the machine. As a host, one of the purposes of an
operating system is to handle the details of the operation of the hardware..
Operating systems offer a number of services to application programs and
users. Applications access these services through application programming interfaces
(APIs) or system calls. By invoking these interfaces, the application can request a service
from the operating system, pass parameters, and receive the results of the operation.
Under LINUX, the operating system consists of many of
these utilities along with the master control program, the kernel. The kernel provides
services to start and stop programs, handle the file system and other common low level
tasks that most programs share, and, perhaps most importantly, schedules access to
hardware to avoid conflicts if two programs try to access the same resource or device
simultaneously. To mediate such access, the kernel was given special rights on the
system, leading to the division between user-space and kernel-space.
I.Kernel
2.Shell
3. Users shell programs.
It is the main part of the operating system. It controls all the resources, users,
hardware and tasks that are present in the system. So we can define kernel as the Master
program which act as the heart of the operating system.
Shell
1. Receives user command from the shell
2. Communicates with the hardware.
3. Control all the computer resources
4. Runs scheduler.
5. Run all the programs.
The user cannot directly interact with the kernel. During the login of the user the
kernel starts an interactive program for each user. This program is known as shell. The
shell acts as an interface between the user and kernel. The shell will act as an interpreter.
When user gives some command the shell analyses those commands and passes them to
the kernel. The kernel then submits these commands to hardware and the required actions
are carried out. This process is shown below:

FILES AND DIRECTORIES


A file is a collection of information that is assigned a name that is used to identify that
file. The file is always stored in secondary storage medium. A directory is a special type
file that contains a list of file names. All files are grouped together into directory for
easier access. A directory can have one or more directories rn it called sub-directories.
In LINUX files and directories are arranged in a hierarchical manner.
DIRECTORY HIERARCHY OF LINUX
In LINUX every file is assigned to some directory. The root directory is the main
directory and named as I. All the other files and directories are its subdirectories.

2.BASIC SHELL COMMANDS


ls --- lists your files
ls -l --- lists your files in 'long format', which contains lots of useful information, e.g. the
exact size of the file, who owns the file and who has the right to look at it, and when it
was last modified.
ls -a --- lists all files, including the ones whose filenames begin in a dot, which you do not
always There are many more options, for example to list files by size, by date, recursively
etc.
more filename --- shows the first part of a file, just as much as will fit on one screen. Just
hit the space bar to see more or q to quit. You can use /pattern to search for a pattern.
emacs filename --- is an editor that lets you create and edit a file.
.
mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it into a

different directory
cp filename1 filename2 --- copies a file
rm filename --- removes a file. It is wise to use the option rm -i, which will ask you for
confirmation before actually deleting anything.
diff filename1 filename2 --- compares files, and shows where they differ
wc filename --- tells you how many lines, words, and characters there are in a file
chmod options filename --- lets you change the read, write, and execute permissions on
your files. The default is that only you can look at them and change them, but you may
sometimes want to change these permissions. For example, chmod o+r filename will
make the file readable for everyone, and chmod o-r
Directories
Directories, like folders on a Macintosh, are used to group files together in a hierarchical
structure.
mkdir dirname --- make a new directory
cd dirname --- change directory. You basically 'go' to another directory, and you will see
the files in that directory when you do 'ls'. You always start out in your 'home directory',
and you can get back there by typing 'cd' without arguments. 'cd ..' will get you one level
up from your current position. You don't have to walk along step by step ..
SHELL PROGRAMMING
The shell is a program that interprets whatever user type at the terminal and responds
accordingly. The command given from the user is moved to the shell, the shell analyses
and interprets these commands into machine understandable form. The shell acts as an
interface between the user and the system.
PARTS OF LINUX OPERATING SYSTEM
The LINUX Operating System has three parts. They are
1. Kernel
2. Shell
3. Users shell program.
KERNEL (HEART OF A LINUX SYSTEM)
It is the core of the Operating System. It controls all the all the functions of an Operating
System, such as memory and file management etc and it keep track of programs that are
executing. When the computer is switch on or boot up, this program in LINUX is
loaded into the computers main memory, where it remains until the computer is shut
down. Once the Kernel is loaded to memory, it is ready to carry out the user requests. The

user makes requests to a shell, which interprets them, and passes them on to the Kernel.
The Kernel is responsible for
Functions of a Shell
Command line interpretation
1.Program initiation
2.Transmission Output redirection
3.Pipeline connection
4.Substitution of filenames
5.Maintenance of variables
6. Environment control
7.Shell programming
3.LINUX EDITOR
LINUX system starts a special version of a shell called an interactive shell, and shows a
shell prompt, usually in the form of a dollar sing ($), a percent sign( %), or a pound sign
(#), When we type a line of input at a shell prompt, the shett tries to interpret it. Input to a
shell prompt is sometimes called a command line.The basic format
Modes in vi
There are three basic modes of vi:
Command mode
This is the default when you enter vi. In command mode, most letters, or short sequences
of letters, that you type will be interpreted as commands, without explicitly pressing
Enter . If you press Esc when you're in command mode, your terminal will beep at you.
This is a very good way to tell when you're in command mode.
Insert mode
In insert mode, whatever you type is inserted in the file at the cursor position. Type a
(lowercase letter a, for append) to enter insert mode from command mode; press Esc to
end insert mode, and return to command mode.
Line mode
Use line mode to enter line oriented commands. To enter line mode from command
mode, type a colon . Your cursor moves to the bottom of the screen, by a colon prompt.
Type a line mode command, then press Enter. Any sensible command from the LINUX
line editor ex will work, and a few are good to know about. These commands are
indicated in this handout by a colon in front of the command. Each time you use a line
mode command, you must type a colon to enter line mode, then type the command by the
colon prompt at the bottom of the screen, then press Enter when you finish typing the
command.
Starting vi and Saving Files
Starting vi:
vi filename Start editing filename, create it if necessary

Saving the file you're working on and/or leaving vi:


:wq write the file to disk and quit
:q! Quit without saving any changes

Moving the Cursor


Many commands take number prefixes; for example 5w moves to the right by 5 words.
Type: To Move To:
H one space to the left (also try left arrow)
J one line down (also try down arrow)
K one line up (also try up arrow)
L one space to the right (also try right arrow)
$ end of current line
^ beginning of current line
Enter beginning first word on the next line
G end of file
:n line n; use :0 to move the beginning of the file
w beginning of next word; 5w moves to the beginning of the 5th word to the right
E end of next word
B beginning of previous word
Ctrl-b one page up
Searching for Text
Type: To:
/string search down for string
?string search up for string
N repeat last search from present position

Inserting Text
Type: To:
a append starting right of cursor
A append at the end of the current line
i insert starting left of cursor
I insert at beginning of the current line
o open line below cursor, then enter insert mode
O open line above cursor, then enter insert mode
:r newfile add the contents of the file newfile starting below the current line

Deleting Text
Type: To:
X Delete single character; 5x deletes 5 characters
Dw Delete word; 5dw deletes 5 words
Dd Delete line; 5dd deletes ... well you get the idea!
Cw Delete word, leaves you in insert mode (i.e. change word)
Cc change line -- delete line and start insert mode
S change character -- delete character and start insert mode
D Delete from cursor to end of line
C change from cursor to end of line -- delete and start insert mode
U undo last change

Cutting and Pasting


Type: To:
Xp transpose two characters (two commands, x followed by p)
Yy yank (i.e. copy) one line into a general buffer (5yy to yank 5 lines)
"ayy yank into the buffer named a
P put the general buffer back before the current line
"aP put from buffer a before current line
P put the general buffer back after the current line
"ap put from buffer a after the current line

Você também pode gostar