[go: up one dir, main page]

0% found this document useful (0 votes)
160 views13 pages

303 Linux OS PDF

The document discusses Linux file systems, features of Linux operating systems, process management in Linux, different shells used in Linux, absolute and relative paths, filters and sorting commands, head/tail commands, grep/egrep commands, shell variables, exit status, and writing shell scripts. It provides explanations and examples of each topic.
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)
160 views13 pages

303 Linux OS PDF

The document discusses Linux file systems, features of Linux operating systems, process management in Linux, different shells used in Linux, absolute and relative paths, filters and sorting commands, head/tail commands, grep/egrep commands, shell variables, exit status, and writing shell scripts. It provides explanations and examples of each topic.
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/ 13

Paper Code: BCA 303

Paper Title: LINUX ENVIRONMENT


Last Date of submission: Max. Marks: 30
Note: Question No. 1 is of short answer type and is compulsory for all the students.
It carries 1 Mark each.
Section-A
i. Explain the Linux file system. What are basic features of Linux operating system.

Linux File System or any file system generally is a layer which is under the
operating system that handles the positioning of your data on the storage,
without it; the system cannot knows which file starts from where and ends
where.

Linux offers many file systems like these:

Ext, Ext2, Ext3, Ext4, JFS, XFS, btrfs and swap


Following are some of the important features of Linux Operating System.
• Portable – Portability means softwares can works on different types of hardwares in same way.Linux
kernel and application programs supports their installation on any kind of hardware platform.
• Open Source – Linux source code is freely available and it is community based development project.
Multiple teams works in collaboration to enhance the capability of Linux operating system and it is
continuously evolving.
• Multi-User – Linux is a multiuser system means multiple users can access system resources like
memory/ ram/ application programs at same time.
• Multiprogramming – Linux is a multiprogramming system means multiple applications can run at
same time.
• Hierarchical File System – Linux provides a standard file structure in which system files/ user files
are arranged.
• Shell – Linux provides a special interpreter program which can be used to execute commands of the
operating system. It can be used to do various types of operations, call application programs etc.
• Security – Linux provides user security using authentication features like password protection/
controlled access to specific files/ encryption of data.

ii. Explain process management in Linux.

Process management is a case in point. Linux creates a process whenever a program


is launched, either by you or by Linux. This process is a container of information about
how that program is running and what’s happening.

Any application that runs on a Linux system is assigned a process ID or PID. This is a numerical
representation of the instance of the application on the system. In most situations this
information is only relevant to the system administrator who may have to debug or terminate
processes by referencing the PID. Process Management is the series of tasks a System
Administrator completes to monitor, manage, and maintain instances of running applications.
Process Management beings with an understanding concept of Multitasking. Linux is
what is referred to as a preemptive multitasking operating system. Preemptive
multitasking systems rely on a scheduler. The function of the scheduler is to control the
process that is currently using the CPU. In contrast, symmetric multitasking systems
such as Windows 3.1 relied on each running process to voluntary relinquish control of
the processor. If an application in this system hung or stalled, the entire computer
system stalled. By making use of an additional component to pre-empt each process
when its “turn” is up, stalled programs do not affect the overall flow of the operating
system.

Each “turn” is called a time slice, and each time slice is only a fraction of a second long.
It is this rapid switching from process to process that allows a computer to “appear’ to
be doing two things at once, in much the same way a movie “appears” to be a continuous
picture.

iii. Explain the different types of shells used in Linux.

1. Bash Shell
Bash stands for Bourne Again Shell and it is the default shell on many Linux
distributions today. which includes:
1. Command line editing
2. Job Control
3. Unlimited size command history
4. Shell Functions and Aliases
5. Unlimited size Indexed arrays
6. Integer arithmetic in any base from two to sixty-four

2. Tcsh/Csh Shell
Tcsh is enhanced C shell, it can be used as a interactive login shell and shell
script command processor.
Tcsh has the following features:

1. C like syntax
2. Command-line editor
3. Programmable word and filename completion
4. Spelling correction
5. Job control
3. Ksh Shell
Ksh stands for Korn shell and was designed and developed by David G. Korn.
It is a complete, powerful, high-level programming language and also an
interactive command language just like many other Unix/GNU Linux shells.

4. Zsh Shell
Zsh is designed to be interactive and it incorporates many features of other
Unix/GNU Linux shells such as bash, tcsh and ksh.
1. Filename generation
2. Startup files
3. Login/Logout watching
4. Closing comments
5. Concept index
6. Variable index
7. Functions index
8. Key index and many more that you can find out in man pages

5. Fish
Fish in full stands for “friendly interactive shell” and was authored in 2005. that
includes:
1. Man page completions
2. Web based configuration
3. Auto-suggestions
4. Fully scriptable with clean scripts
5. Support for term256 terminal technology

iv. What are absolute and relative path? Which command is used to navigate in the file
system.

Absolute Path: An absolute path is defined as specifying the location of a file or directory
from the root directory(/). In other words we can say absolute path is a complete path from start
of actual filesystem from / directory.

example:
/home/user/Document/srv.txt
/root/data/dev.jpg
/var/log/messages
Relative Path: Relative path is defined as path related to the present working directory(pwd).
Suppose I am located in /home/user1 and I want to change directory to
/home/user1/Documents. I can use relative pathconcept to change directory to Documents.

example:

$ pwd
/home/user1
$cd Documents/
$pwd
/home/user1/Documents

LS — SEE THE FILES IN YOUR CURRENT DIRECTORY

CD — CHANGE YOUR CURRENT DIRECTORY

iv. What are filters? Explain sort with all the options available.

Linux Filter commands accept input data from stdin (standard input) and
produce output on stdout (standard output). It transforms plain-text data into a
meaningful way and can be used with pipes to perform higher operations.
These filters are very small programs that are designed for a specific function
which can be used as building blocks.

SORT command is used to sort a file, arranging the records in a particular order. By
default, the sort command sorts file assuming the contents are ASCII. Using options
in sort command, it can also be used to sort numerically.

-o Option : Unix also provides us with special facilities like if you want to write
the output to a new file, output.txt, redirects the output like this or you can also use
the built-in sort option -o, which allows you to specify an output file.
Using the -o option is functionally the same as redirecting the output to a file.

-r Option: Sorting In Reverse Order : You can perform a reverse-order sort using
the -r flag. the -r flag is an option of the sort command which sorts the input file in
reverse order i.e. descending order by default.

-n Option : To sort a file numerically used –n option. -n option is also predefined in


unix as the above options are. This option is used to sort the file with numeric data
present inside.

-nr option : To sort a file with numeric data in reverse order we can use the
combination of two options as stated below.
-c option : This option is used to check if the file given is already sorted or not &
checks if a file is already sorted pass the -c option to sort. This will write to standard
output if there are lines that are out of order.The sort tool can be used to understand
if this file is sorted and which lines are out of order

-u option : To sort and remove duplicates pass the -u option to sort. This will write
a sorted list to standard output and remove duplicates.

-M Option : To sort by month pass the -M option to sort. This will write a sorted list
to standard output ordered by month name.

vi. Explain the following :


a. Head and Tail. b. Grep and egret

The head command command prints lines from the beginning of a file (the
head), and the tail command prints lines from the end of files.

The Linux `head` command

By default the head command prints the first ten lines of a file, as shown in
this head command example:

If you want to print more or less than 10 lines from the beginning of the file,
the head command -n option lets you specify how many lines you want to see.
Here I specify that I only want five lines:
B.
The grep filter searches a file for a particular pattern of characters, and displays all lines that
contain that pattern. The pattern that is searched in the file is referred to as the regular
expression (grep stands for globally search for regular expression and print out).

egrep is a pattern searching command which belongs to the family of grep functions. It works
the same way as grep -E does. It treats the pattern as an extended regular expression and
prints out the lines that match the pattern. If there are several files with the matching pattern, it
also displays the file names for each line.

The egrep command used mainly due to the fact that it is faster than the grep command. The
egrep command treats the meta-characters as they are and do not require to be escaped as is
the case with grep. This allows reducing the overhead of replacing these characters while
pattern matching making egrep faster than grep
vii. What are shell variables? Explain the rules for assigning values to variables.

viii. What is exit status? How to check the exit status.


ix. Write a shell script to calculate sum, multiplication of three variables using expr.
keyword.
x. Write the steps to add a new user with the password as “123456”.
Section-B
Note: Answer any four questions. Each question carries 5 marks (Words limit 500)
Q.2 What are the common features of Linux Operating System and minimum hardware
requirement to install Linux on any system?
Following are some of the important features of Linux Operating System.
• Portable – Portability means softwares can works on different types of hardwares in same way.Linux
kernel and application programs supports their installation on any kind of hardware platform.
• Open Source – Linux source code is freely available and it is community based development project.
Multiple teams works in collaboration to enhance the capability of Linux operating system and it is
continuously evolving.
• Multi-User – Linux is a multiuser system means multiple users can access system resources like
memory/ ram/ application programs at same time.
• Multiprogramming – Linux is a multiprogramming system means multiple applications can run at
same time.
• Hierarchical File System – Linux provides a standard file structure in which system files/ user files
are arranged.
• Shell – Linux provides a special interpreter program which can be used to execute commands of the
operating system. It can be used to do various types of operations, call application programs etc.
• Security – Linux provides user security using authentication features like password protection/
controlled access to specific files/ encryption of data.
• Live CD/USB: Almost all Linux distributions have Live CD/USB feature by which user can run/try
the OS even without installing it on the system.
• Graphical user interface (X Window System): People think that Linux is a command line
OS, somewhere its true also but not necessarily, Linux have packages which can be installed to
make the whole OS graphics based as Windows.
• Support’s most national or customized keyboards: Linux is used worldwide and hence
available in multiple languages, and supports most of their custom national keyboards.
• Application Support: Linux has its own software repository from where users can download
and install thousands of applications just by issuing a command in Linux Terminal or Shell. Linux
can also run Windows applications if needed.

The Recommended Minimum System Requirements, here, should allow even someone fairly new to
installing Ubuntu or Gnu&Linux to easily install a usable system with enough room to be comfortable. A
good "rule of thumb" is that machines that could run XP, Vista, Windows 7 or x86 OS X will almost always
be a lot faster with Ubuntu even if they are lower-spec than described below. Simply try Ubuntu CD as
a LiveCD first to check the hardware works.

Ubuntu Desktop Edition


1. 2 GHz dual core processor
2. 2 GiB RAM (system memory)
3. 25 GB of hard-drive space (or USB stick, memory card or external drive but see LiveCD for an
alternative approach)
4. VGA capable of 1024x768 screen resolution
5. Either a CD/DVD drive or a USB port for the installer media
Ubuntu Desktop 11.04 through 17.04 uses Unity as the default GUI while the previous releases
used GNOME Panel by default. From 17.10 onwards the desktop uses GNOME Shell. In order to run these
environments the system needs a more capable graphics adapter. Like the following

1. 4096 MiB RAM (system memory) for physical installs.


2. 2048 MiB RAM (system memory) for virtualised installs.
3. 3D Acceleration Capable Videocard with at least 256 MB
If it is Ubuntu Server (CLI) Installation
1. 300 MHz x86 processor
2. 256 MiB of system memory (RAM)
3. 1.5 GB of disk space
4. Graphics card and monitor capable of 640x480
5. CD drive
Ubuntu 18.04 LTS Server Edition supports four (4) major architectures: AMD64, ARM, POWER8,
LinuxONE and z Systems (although this manual does not cover installation on LinuxONE or z Systems

Q.3. a. What are environment variables? Explain any three environment variables.
b. Explain the following with syntax :
i. tty ii. uname–r

iii. Cal iv. echo v. rmdir

Environment variables are dynamic values which affect the processes or programs
on a computer. They exist in every operating system, but types may vary.
Environment variables can be created, edited, saved, and deleted and give
information about the system behavior.

Environment variables can change the way a software/programs behave.

E.g. $LANG environment variable stores the value of the language that the user
understands. This value is read by an application such that a Chinese user is shown
a Mandarin interface while an American user is shown an English interface.

The following are explanation for 3 environment variables (Abbreviated as ENV)

• $PATH
This ENV stores the path of all the directories which holds
binary files you want to execute just by specifying the name of
the file and not by relative or absolute path.
This ENV comes very handy when you need to switch between
directories and still execute the binary file in some other
directory.
This variable contains a colon (:)-separated list of directories in which your system
looks for executable files.

When you enter a command on terminal, the shell looks for the command in
different directories mentioned in the $PATH variable. If the command is found, it
executes. Otherwise, it returns with an error 'command not found'.

• $USER
This ENV stores your username. This can be used in shell
scripts for various reasons.
• $HOME
This ENV stores the absolute path to your home directory.
This turns out to very handy when you need the path of your
home directory in shell scripts.
(i)
tty command in Linux with examples
Linux operating system represents everything in a file system, the hardware devices
that we attach are also represented as a file. The terminal is also represented as a file.
There a command exists called tty which displays information related to terminal.
The ttycommand of terminal basically prints the file name of the terminal connected to
standard input. tty is short of teletype, but popularly known as a terminal it allows you to
interact with the system by passing on the data (you input) to the system, and displaying
the output produced by the system.

(ii) uname -r
-r option: It prints the kernel release date.
Syntax:
$uname -r

(iii) Cal
If a user wants a quick view of calendar in Linux terminal, cal is the command for you.
By default, cal command shows current month calendar as output.
cal command is a calendar command in Linux which is used to see the calendar of a
specific month or a whole year.
(iv)echo
echo command in linux is used to display line of text/string that are passed as an
argument . This is a built in command that is mostly used in shell scripts and batch files
to output status text to the screen or a file.

(v)rmdir

rm stands for remove here. rm command is used to remove objects such as files,
directories, symbolic links and so on from the file system like UNIX. To be more precise,
rm removes references to objects from the filesystem, where those objects might have
had multiple references (for example, a file with two different names). By default, it
does not remove directories.
This command normally works silently and you should be very careful while
running rm command because once you delete the files then you are not able to
recover the contents of files and directories.
Q.4 a. Explain the basic file permissions and how to change these permissions.
b. What are the prompt characters used in Linux? Write steps to change the value of
prompt if required.

Permissions
Every file and directory in your UNIX/Linux system has following 3 permissions
defined for all the 3 owners discussed above.

• Read: This permission give you the authority to open and read a file. Read
permission on a directory gives you the ability to lists its content.
• Write: The write permission gives you the authority to modify the contents
of a file. The write permission on a directory gives you the authority to add,
remove and rename files stored in the directory. Consider a scenario where
you have to write permission on file but do not have write permission on the
directory where the file is stored. You will be able to modify the file contents.
But you will not be able to rename, move or remove the file from the
directory.
• Execute: In Windows, an executable program usually has an extension
".exe" and which you can easily run. In Unix/Linux, you cannot run a
program unless the execute permission is set. If the execute permission is
not set, you might still be able to see/modify the program code(provided
read & write permissions are set), but not run it.

Changing file/directory permissions with 'chmod'


command
Say you do not want your colleague to see your personal images. This can be
achieved by changing file permissions.
We can use the 'chmod' command which stands for 'change mode'. Using the
command, we can set permissions (read, write, execute) on a file/directory for the
owner, group and the world. Syntax:

chmod permissions filename

Q.5. a. Write a shell script which cheeks a input string is a palindrome or not.
b. What are the different methods used to execute a shell script.
Q.6 a. What are escape sequences? Explain with example.
b. What is process management? Explain.

You might also like