0% found this document useful (0 votes)
19 views24 pages

OS Lab Part-I

The document discusses Linux operating systems and commands. It provides an overview of Linux, describes the kernel and system calls. It also discusses Ubuntu operating system, shells, and introduces common Linux commands like ls, cd, mkdir and their usage.

Uploaded by

Miki Micah
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)
19 views24 pages

OS Lab Part-I

The document discusses Linux operating systems and commands. It provides an overview of Linux, describes the kernel and system calls. It also discusses Ubuntu operating system, shells, and introduces common Linux commands like ls, cd, mkdir and their usage.

Uploaded by

Miki Micah
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/ 24

Operating Systems

ECEG-5202

Lab Session

Surafel Lemma Abebe (Ph. D.)


Overview

• Linux vs GNU/Linux
• Linux
– Production OS
– Dynamic kernel
– Hypervisor
– Monolithic
– Efficient in terms of both memory and CPU usage
– Stable
– Portable

Surafel Lemma Abebe (Ph. D.) 2


Overview…
• Kernel
– Resource manager
– Arbitrates access to resources between multiple competing
users
– Schedules work
– Provides tools with which other services could be built
– Prevents anyone from accessing the hardware directly
– Provides some protection to users (from other users)
– System programs, and other programs, run on top of the kernel
• user mode
– System vs. application programs
• Word processor vs. mount

Surafel Lemma Abebe (Ph. D.) 3


Overview…

• System call interface (SCI)


– Provides the means to perform function calls from
user space into the kernel
– Could be architecture dependent

Surafel Lemma Abebe (Ph. D.) 4


Ubuntu
• What is Ubuntu
– Is a Linux based operating system
– Comprises Linux kernel, GNU tools, desktop
environments and other applications
• Ubuntu (Human-ness, humanity to others)
• Originated from South Africa
• Has two versions: desktop and server
• Is expected to be released every six months
(supported for 9 months)
• Every 2 years LTS versions are released

Surafel Lemma Abebe (Ph. D.) 5


What is Shell?
• Shell is a utility program
– Loaded into memory for execution whenever you log into
the system
– Virtually every command you know under the Unix system
is classified as a utility
– The type of shell program to be loaded is defined in the
/etc/passwd

Surafel Lemma Abebe (Ph. D.) 6


What is a Shell...
• Shell
– Is just a program
– Serves as a user interface
• Character-based UI
– Can be used
• For interaction
– Enter commands at the command prompt
• As an interpreter
– To write and execute a shell script
– Has no special privileges on the system
– General steps
• Takes an input from the user
• Translates the input into instruction that the OS understands
• Conveys the OS’s output back to the user
Surafel Lemma Abebe (Ph. D.) 7
What is Shell…
• When the shell starts up, it displays a command prompt
(typically a dollar sign)
• When you type and enter a command, shell analyzes the
line you typed and then proceeds to carry out your request

while (1) {
read line from terminal;
parse into words;
substitute variables;
execute commands (execv or
builtin);
}

Surafel Lemma Abebe (Ph. D.) 8


What is Shell?
• Shell responsibilities

Surafel Lemma Abebe (Ph. D.) 9


What is Shell…
• Shell types
– Shell is independent of the UNIX OS
• Led to development of dozens of shells
• Examples
– Bourne shell, Bourne Again shell, C shell, Thomas C shell, Korn
shell, public domain Korn shell, zsh, …
– Bourne shell (sh)
• Named after its inventor Steven Bourne of AT & T’s Bell
Lab
• The first major shell

Surafel Lemma Abebe (Ph. D.) 10


What is Shell…
• Shell types
– C shell (csh)
• The first widely used alternative shell
• Written by Bill Joy at the University of California at Berkley as part of the BSD
• Commands resemble C programming language statements
• Supports a number of OS features that were unique to BSD UNIX then
– E.g., job control, aliases
– Korn shell
• Commercial product
• Incorporates the best features of the Bourne and C shells, plus many features of its own
– Bourne Again Shell (bash)
• Named after Steve Bourne’s shell
• Officially “born” on Sunday Jan 10, 1988
• Created for use in the GNU project
• Freely available
• Standard shell included with Linux and Apple’s Mac OS X
• Compatible with Bourne shell

Surafel Lemma Abebe (Ph. D.) 11


Introduction to LINUX commands
• Linux commands are executable files
• Location of executable files
– /bin
– /usr/bin
– /usr/local/bin
– /usr/sbin
• Linux command format
commandName [- switches ] [parameterList]
Where
commandName Name of the executable program
- switches List of switches that modifies the operation of the command
parameterList List of arguments that the command will operate on

Surafel Lemma Abebe (Ph. D.) 12


Introduction to LINUX commands…
• Linux command format…
– Example
echo ‘Hello World \n’
echo -e ‘Hello World !\n’
• Command = echo
• Switch = -e
– enable interpretation of backslash escapes
• Argument = Hello World \n

Surafel Lemma Abebe (Ph. D.) 13


Introduction to LINUX commands…
• Moving around
– Usually the default starting location of a terminal is the home
folder /home/the_username
• This is called the home directory
– To move to a different location we use the “cd” (change
directory) command
cd where_we_want_to_go
• Note
– where_we_want_to_go could be a relative or absolute path

• Example
cd / >>> will take you to the root directory
cd >>> will take you back to the home directory
cd .. >>> will take you one directory up

Surafel Lemma Abebe (Ph. D.) 14


Introduction to LINUX commands…
• Seeing content of a directory
– To list the files and folders inside a directory we use “ls”
ls the_directory_you_wanted_to_list_Its_content
• Example
ls >>> list the files and folders inside current directory
ls ~ >>> list the files and folders inside the ~(home) directory
ls -lh >>> shows the long list of file names with hidden files

• Online help
– Linux comes with online help called man pages
– Man pages are short references for commands
– Syntax
man commandName
– Example
man ls

– Alternative
commandName --help

Surafel Lemma Abebe (Ph. D.) 15


Introduction to LINUX commands…
• Some Linux commands

Surafel Lemma Abebe (Ph. D.) 16


Introduction to LINUX commands…
• Working with files
– Creating new directories (make directory)
mkdir ~/folder_name
– Creating new files
touch file_name >> create new file if it doesn’t exist or updates last
modified date and time if it does.
– Removing a file or folder
rm file_name >> removes the file with the specified file name
rm -r folder_name >> removes the folder and everything inside
– Copy files and folder
cp new_file des_dir >> copies the file ‘new_file’ into the directory
‘des_dir’
– Moving a file
mv old_file des_dir >> moves the file ‘old_file’ into the directory
‘des_dir’

Surafel Lemma Abebe (Ph. D.) 17


Introduction to LINUX commands…
• Exercise
– Create the folder structure “~/computer/os/comp1”
– Create a file named with your name inside the folder
“~/computer/os/comp1/”
– Copy the file into the folder “~/computer”
– Create a new file named “my_new_file” inside the
folder “~/computer/os”
– Move my_new_file into the folder “comp1”

– Delete the folder comp1

Surafel Lemma Abebe (Ph. D.) 18


Introduction to LINUX commands…
• More commands
– whoami
• Displays who the computer thinks you are currently logged
in as
– uname
• Displays information about the OS
– date
• Displays the current date and time according to the
computer
– cal
• Displays a calendar (for a specific month and year)

Surafel Lemma Abebe (Ph. D.) 19


Introduction to LINUX commands…
• I/O redirection
– Output redirection
> and |
– Input redirection
<

• Editors
– Vi
– gedit

Surafel Lemma Abebe (Ph. D.) 20


Introduction to LINUX commands…
• Filters
– Are Linux commands that take input or contents of a
file, modify the content and then display the result
– cat
• The simplest filter
• Does not perform any modification on the information
passed through it
– more and less
• These filters display their input one page at a time. At the
end of each page they pause and wait for the user to hit a
key
• Example: ls –l | less

Surafel Lemma Abebe (Ph. D.) 21


Introduction to LINUX commands…
• Filters…
– head and tail
• Head and tail allow you to view the first or last few lines of a file
• Examples
head file
» Displays the first 10 lines of file
head –l 20 file
» Displays the first 20 lines of file
head –c 15 file
» Displays the first 15 bytes of file
– grep
• Stands for Global Regular Expression Pattern match
• Used to search a file for a particular pattern of characters
• Example
grep home /etc/passwd

Surafel Lemma Abebe (Ph. D.) 22


Introduction to LINUX commands…
• Common commands for file management
– df
• summarizes the free disk space by file system
– du
• summarizes disk usage by directory
– ln
• used to generate links between files
– tar
• archiving utility
– find
• find files or patterns of files
– fsck
• attempts to verify that all links and blocks are correctly tied together
– fdisk
• managing partitions
– mke2fs
• creating file systems
– mkswap
• creating swap file system

Surafel Lemma Abebe (Ph. D.) 23


Introduction to LINUX commands…
• Common commands for controlling processes
– kill
• Terminates a process specified by pid
– killall
• Terminates processes by name
– nice
• Sets the nice value at the time of process creation
– renice
• Adjusts the niceness value
– ps
• Monitor processes
– top
• Provides a regular updated summary of active processes and their use of
resources
– strace
• Used to observe a process

Surafel Lemma Abebe (Ph. D.) 24

You might also like