0% found this document useful (0 votes)
29 views44 pages

Unit-5 (Notes) OS

This document provides an overview of Linux, including its history, installation methods, architecture, and essential commands. It covers various aspects such as the Linux shell, file editing tools like vi and gedit, and the GNU compiler collection (gcc). The document serves as a foundational guide for understanding and using Linux operating systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views44 pages

Unit-5 (Notes) OS

This document provides an overview of Linux, including its history, installation methods, architecture, and essential commands. It covers various aspects such as the Linux shell, file editing tools like vi and gedit, and the GNU compiler collection (gcc). The document serves as a foundational guide for understanding and using Linux operating systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

UNIT:5

Linux Basic
1
SYLLABUS

 5.1 Overview of linux

 5.2 Installation and upgrade

 5.3 Introduction to shell and commands

 5.4 Editing files with vi , vim, gedit, gcc

 5.5 Linux Shell

2
5.1 OVERVIEW OF LINUX

 Linux was first developed by Linus torvads .

 Linux is the most famous free and open source OS.

 Open source Os are available in source code


format rather than as compiled binary code

 Free software means not by money point of view.


But software that is free means it is distributed
along with its source code.
3
 Anyone who receives it is free to make change and
redistribute it.
 There are many versions of Linux.famous versions
are,
 Red hat Linux  Fedora ,Centos
 DebianUbuntu,Linux
mint,Linspire,PCLinux
 Linux can be found on wide range of devices-from
personal computers,mobiles,tablets and embedded
systems to main frame computers and
4
supercomputers
5.2 INSTALLATION AND UPGRADE
 There are four different types of linux installations.

 1. Dual Boot

 Computer System can have more than one


operating system.

 Linux can be installed along with other operating


system such as windows.

 User has to decide which operation system to


boot into during boot process.
5
 2. Live CD/DVD booting
 Linux can be run as a completely bootable
operating system from cd/dvd.
 When computer system is booted from cd/dvd
required files are loaded into main memory form
cd/dvd.
 Operating system runs using these files.

3. Virtual Installation
Linux can be run as a virtual machine inside
6
another operating system.
User has to install some virtual server
application such as Vmware and then install linux
under host software

 Fresh Installation
 It is the most popular installation. It installs linux
as the only operating system of the computer.
 Here hard disk is formatted and if there is any
existing operating system in computer, it will
removed.
7
LINUX ARCHITECTURE
 It is also known as the layered structure of Linux.
 Linux is a UNIX-like OS, its architecture resembles
to that of UNIX.
 1. Hardware:

 Bottom layer is hard ware.

 It consist of physical devices such as CPU ,memory


,disks ,monitors ,printers etc.
 These devices provides various services.

8
Figure : Linux architecture

9
 Linux operating system:
 Next higher layer in Linux OS
 It is called system kernel.
 Kernel manages all the underlying hardware
 It directly interacts with the H/W and provides
user programs required services
 It hides complex details of H/W
 It provides interface between user program and
H/W
 Main service of OS :

 process management , memory


management ,file system management 10
,I/O management
 Standard library
 Contains a set of procedures, one procedure per
system call
 These procedures are written in assembly
language and used to invoke various system
calls from user program.
 4. Standard utility program

 All UNIX versions supply OS , system call ,


large no. of standard program
 Program include command processor (shell)
,compilers ,editors ,text processing program,
file manipulation utility a various
commands… 11
 Program makes user tasks simpler
 User interacts with program, program
interacts with OS to get services from OS

 Users
 Top most layers
 User program come in this layer
 They interacts with system either by library
procedure to invoke system call or by using utility
program such as shell
12
KERNEL
 Kernel is core part of any OS.
 Kernel is program, which is loaded in memory
,when system is turned on and provides various
services until system is turned off.
 Kernel manages all the underlying hardware

 It directly interacts with the H/W , It hides complex


details of H/W
 When user needs to use any H/W ,it has to use
services (system call) provided by kernel.
 System call request kernel and kernel performs the
job behalf on user process.
13
5.3 INTRODUCTION TO SHELL AND
COMMANDS
 Pwd- Print working directory
 Cd – Change directory

 Mkdir – Make directory.

 Rmdir – Remove a directory or an entire directory


tree.
 Ls – Display the contents of a directory.

 Cat – To open the file, create a new file and


append the data in files.Deletes one or more files.
 Copy – Places a copy of file(s) in a different folder.

14
DIRECTORY RELATED COMMANDS
 Creates a directory.
 % mkdir newdir

 Often people make an alias of md for it.

 Removes a directory.
 % rmdir dirname

 Equivalent:
 % rm -r dirname

15
CD AND PWD
 Changes your current directory to a new one.
 % cd /some/other/dir
 Absolute path
 % cd subdir
 Assuming subdir is in the current directory.
 % cd
 Returns you to your home directory.
 Displays personal working directory, i.e. your
current directory.
 % pwd
16
MAN
 Manual Pages
 The first command to remember
 Contains info about almost everything :-)
 other commands
 system calls
 c/library functions
 other utils, applications, configuration files
 Toread about man itself type:
% man man
 NOTE: unfortunately there’s no
% man woman ... 17
PASSWD
 Change your login password.
 A very good idea after you got a new one.

 It’s usually a paranoid program asking your


password to have at least 6 chars in the password,
at least two alphabetical and one numerical
characters. Some other restrictions (e.g. dictionary
words or previous password similarity) may apply.
 Depending on a privilege, one can change user’s
and group passwords as well as real name, login
shell, etc.
 % man passwd
18
DATE
 Guess what :-)
 Displays dates in various formats
 % date

 % date -u
 in GMT
 % man date

19
CAL
 Calendar
 for month
 entire year
 Years range: 1 - 9999
 No year 0
 Calendar was corrected in 1752 - removed 11 days
 % cal current month
 % cal 2 2000 Feb 2000, leap year
 % cal 2 2100 not a leap year
 % cal 2 2400 leap year
 % cal 9 1752 11 days skipped
 % cal 0 error
20
 % cal 2002 whole year
HISTORY
% cal current month
% cal 2 2000 Feb 2000, leap year
% cal 2 2100 not a leap year
% cal 2 2400 leap year
% cal 9 1752 11 days skipped
% cal 0 error
% cal 2002 whole year

21
LS
 List directory contents
 Has whole bunch of options, see man ls for details.
 % ls
 all files except those starting with a “.”
 % ls -a
 all
 % ls -A
 all without “.” and “..”

22
CAT
 Display and concatenate files.
 % cat
 Will read from STDIN and print to STDOT every line you
enter.
 % cat file1 [file2] ...
 Will concatenate all files in one and print them to STDOUT
 % cat > filename
 Will take whatever you type from STDIN and will put it into
the file filename
 To exit cat or cat > filename type Ctrl+D to
indicate EOF (End of File).
23
COPY
 Copies files / directories.
 % cp [options] <source>
<destination>
 % cp file1 file2

 % cp file1 [file2] … /directory

 Useful option: -i to prevent overwriting


existing files and prompt the user to confirm.

24
MV
 Movesor renames files/directories.
 % mv <source> <destination>
 The <source> gets removed
% mv file1 dir/
 % mv file1 file2
 rename
% mv file1 file2 dir/
 % mv dir1 dir2

25
RM
 Removes file(s) and/or directories.
% rm file1 [file2] ...
 % rm -r dir1 [dir2] ...

 % rm -r file1 dir1 dir2 file4


...

26
CHMOD
 Changes file permissions
 Possible invocations
 % chmod 600 filename
 -rw------- 1 user group 2785 Feb 8 14:18
filename
(a bit not intuitive where 600 comes from)
 % chmod u+rw filename
(the same thing, more readable)
 For the assignment:
 % chmod u+x myshellscript
(mysshellscript is now executable)
 -rwx------ 1 user group 2785 Feb 8 14:18 myshellscript
27
ECHO AND GREP
 Searches its input for a pattern.
 The pattern can be a simple substring or a complex
regular expression.
 If a line matches, it’s directed to STDOUT;
otherwise, it’s discarded.
 % echo “blah-foo” | grep blah
 Will print the matching line
 % echo “blah-foo” | grep zee
 Will not.
 See a separate grep tutorial.
28
PS
 Use ps to report the status of a process

 /export/home/morris07>ps

Output:
 PID TTY TIME CMD
 19834 pts/7 0:05 ksh
 19954 pts/7 0:04 ps

29
SORT
 The sort command sorts data (using ASCII
format).

 sort [-dfnru] [infile…] [-o outfile]


 >sort names -o sorted_names
 or
 >sort names > sorted_names

30
KILL
 The kill command waits for the process to
perform cleanup: write to files, close files,etc.

 If the process will not end, use the ‘-9’ or


 ‘-KILL’ to kill the process immediately

 > kill –9 19954


 > kill –KILL 19954

31
5.4 VI
 short for: visual editor

 available on all UNIX systems

 original vi part of BSD Unix

 written by Bill Joy in 1976

 many derived, improved versions available

 open source vim (vi improved)

is part of GNU/Linux

 vi has multiple modes of operation:


32

 input mode, command mode, last-line mode


VIM

 Syntax: vim [options] [filename]

 Filename is optional

 With it, it opens that file for editing

 Without, it opens a default screen

 Many options available, most commonly used


ones are for file recovery

33
 We’ll be using vim - vi improved

 Written by Bram Moolenaar

 In our RedHat distro, we have /bin/vim

 vi is just an alias to vim

 Standard in just about all Linux distros

 Available from www.vim.org

34
GEDIT

 It is a GUI based text editor and can be used with


linux shell as well as other OS .

 It is similar to notepad editor of windows OS but it is


more powerful than notepad.

 It is free software.

 It is support multi language spell checking and a


flexible plug in system.
35
GCC
 Gcc refers to GNU compiler collection.
 Gcc is a compiler for c, c++,java and other
programming languages.
 Compile the program by following code.
 Gcc test.c -o test.out
 Run the program by following commands.
 ./test.out

36
DIRECTORY
 It is a container for other files and sub-directories.
 They provide a hierarchical file structure. They
organize files in well manner.
 Directory is a file whose data is sequence of
entries. Each entry contains a file name and a
unique identification number called I-node number.
 I –node number provides a location of I-node where
information about a file is stored.
 Any directories contains two special entries : dot (.)
and dot dot (..) .
 These two entries refer to the current directory itself
and its parent directory respectively.

37
DIRECTORY STRUCTURE

38
 Top of file is called root (defined by / )

 The name of file is given by path name .it describes


location of a file and directory.

 A path name can be either absolute and relative.

 Absolute path :

 C:\ prog \ CPP \ test.cpp

 Relative path :

 ./test.cpp
39
5.5 LINUX SHELL
 A shell is a command interpreter that allows you to
type commands from the keyboard to interact with
the operating system kernel.

 A command is a program which interacts with the


kernel to provide the environment and perform the
functions called for by the user.

 A command can be: a built-in shell command; an


executable shell file, known as a shell script; or a
40
source compiled, object code file.
 The shell is a command line interpreter. The user
interacts with the kernel through the shell. You can
write ASCII (text) scripts to be acted upon by a shell.

 sh (Bourne Shell) The sh shell was the earliest


shell, being developed for UNIX back in the late
1970s.

 bash (Bourne-Again Shell) The bash shell is


an improved version of the sh shell and is one of
the most popular shells today. It’s the default
shell used by most Linux distributions. 41
 csh (C Shell) The csh shell was originally
developed for BSD UNIX. It uses a syntax
that is very similar to C programming.

 tsch The tsch shell is an improved version


of the C Shell. It is the default shell used on
FreeBSD systems.
 zsh (Z Shell) The Z Shell is an improved
version of the bash shell.

42
 Linux Command-Line Interface
 Libraries Libraries are pre-written code “pieces”
that application programmers use in their
programs.

 Utilities maintaining the file system, editing text


files, managing running processes, and
installing new software packages.

 User Interface command-line interface (CLI)


and a graphical user interface (GUI).
43
 Thank u

44

You might also like