LINUX Sem5 RGPV
LINUX Sem5 RGPV
Technology
Linux lab
Subject Code – CSIT-505
1
Experiment No.1
An operating system (OS) is essential for managing and facilitating interactions between a computer's
hardware and software. It provides a structured environment for executing programs and handling tasks
like file management. In the context of a file experiment, the OS plays a crucial role by allowing users
to create, modify, and delete files, and by organizing these files into directories or folders.
It also manages file permissions, which control access rights and ensure that only authorized users can
perform certain actions on files. Additionally, the OS employs a file system, such as NTFS, FAT32, or
ext4, to systematically organize and store files on storage devices. During your experiment, you will
observe how the OS efficiently handles these file operations and maintains an organized structure for
data management.
● Booting the Computer- The process of starting or restarting the computer is known as
booting. If the computer is switched off completely and if turned on then it is called cold
booting. Warm booting is a process of using the operating system to restart the computer.
● Security- The operating system uses password protection to protect user data and similar
other techniques. it also prevents unauthorized access to programs and user data.
2
● User Interface or Command Interpreter- The user interacts with the computer system
through the operating system. Hence OS acts as an interface between the user and the
computer hardware. This user interface is offered through a set of commands or a graphical
user interface (GUI).
● Network Management- Network Communication: Think of them as traffic cops for your
internet traffic. Operating systems help computers talk to each other and the internet. Settings
and Monitoring: Think of them as the settings and security guard for your internet connection.
● User Interface: Almost all operating systems have a user interface (UI). This interface can take
several forms. One is a command-line interface(CLI), which uses text commands and a method
for entering them ( a keyboard for typing in commands in a specific format with specific
options).
● Program Execution: The Operating System is responsible for the execution of all types of
programs whether it be user programs or system programs.
● Handling Input/Output Operations: The Operating System is responsible for handling all
sorts of inputs, i.e., from the keyboard, mouse, desktop, etc. The Operating System does all
interfacing most appropriately regarding all kinds of Inputs and Outputs.
● Manipulation of File System: The Operating System is responsible for making decisions
regarding the storage of all types of data or files.
● Resource Allocation: The Operating System ensures the proper use of all the resources
available by deciding which resource to be used by whom for how much time.
● Accounting: The Operating System tracks an account of all the functionalities taking place in
the computer system at a time.
● System Services: The operating system provides various system services, such as printing, time
and date management, and event logging.
● Error Detection: The operating system needs to be detecting and correcting errors
constantly..For each type of error, the operating system should take the appropriate action to
ensure correct and consistent computing.
3
Need for linux operating system:
● Open Source: Linux is open source, meaning its source code is freely available for anyone to
view, modify, and distribute. This fosters innovation and customization.
● Stability and Reliability: Known for its stability and reliability, Linux is often used in
environments where uptime is critical, such as servers and embedded systems.
● Security: Linux is designed with robust security features and has a strong community of
developers who quickly address vulnerabilities and provide patches.
● Cost-Effective: Linux is free to use, reducing costs associated with licensing fees compared
to proprietary operating systems.
● Flexibility and Customization: Linux can be tailored to suit specific needs, from lightweight
distributions for older hardware to powerful configurations for advanced users and servers.
● Performance: Linux typically has a smaller footprint and can be optimized for performance,
making it suitable for a wide range of hardware.
Linux originated in 1991 when Linus Torvalds, a Finnish student, released the first version of the
Linux kernel as a free and open-source alternative to proprietary operating systems. Initially
developed as a personal project, Linux quickly garnered support from a global community of
developers.
By adhering to the principles of open source, it allowed continuous improvements and adaptations.
Over the years, Linux evolved into a robust and versatile operating system used across various
domains, from personal computers to servers and embedded systems.
Its development has been driven by contributions from both individual programmers and large
organizations,leading to a diverse ecosystem of distributions tailored for different needs.
4
Different Services and Application Of Linux Operating system :
● Web Servers: Powers popular web servers like Apache and Nginx.
● File Servers: Provides file sharing services with tools like Samba and NFS.
● Development Environment: Used by developers for programming with support for various
programming languages and development tools.
● Security: Provides strong security features and tools, including SELinux and AppArmor.
● Desktop Environments: Offers various desktop environments like GNOME, KDE, and
XFCE for user interfaces.
5
Experiment No.2
1.ls :
Description: list directory content.
Syntax: ls
2.ls -l :
Description: list directory contents with detail
Syntax: ls -l
3.cat :
Description: Concatenate files and print on the standard output
Syntax: cat
6
4..Whoami :-
Description: The whoami command in Linux displays the username of the currently logged-in user.
Syntax: Whoami
5.Whatis:-
Description: display one-line manual page descriptions
Syntax: Whatis
6.Date :-
Description: date command is used to display the system date and time. date command is also used to
set date and time of the system.
Syntax: Date
7.Man :-
Description: an interface to the system reference manuals
Syntax: Man
7
8.mkdir :-
Description: Create a new directory.
Syntax: mkdir folder name
9.cd :-
Description: Change directory.
Syntax: cd folder name
10.rmdir :-
Description: remove empty directories
Syntax: rmdir folder name
8
11.Vi :-
Description: Vi IMproved, a programmer's text editor
Syntax: Vi
12.MV :-
Description: move and rename files.
Syntax:MV currentfolder destinationfolder
9
13.CP :-
Description: copy files and directories
Syntax:CP
14.Grep :-
Description: print lines that match patterns
Syntax:Grep
15.Su :-
Description: run a command with substitute user and group ID
Syntax:Su
16.Sudo :-
Description: execute a command as another user
10
Syntax:Sudo
17.nano :-
Description: Nano's ANOther editor, inspired by Pico
Syntax:nano
18.find :-
Description: search for files in a directory hierarchy
Syntax: find -name file name
19.ps :-
Description: report a snapshot of the current processes.
Syntax:ps
11
21.Df :-
Description: report file system disk space usage.
Syntax:Df
22.Chmode :-
Description: change file mode bits
Syntax:Chmode +r file name
23.Touch :-
Description: Create File
Syntax:Touch filename
12
24.Pwd :-
Description: Print current working directory.
Syntax:Pwd
25.Cal :-
Description: to show the calendar.
Syntax:Cal
26.echo:-
Description: used to print something in the terminal
Syntax:echo text >filename
13
27.uname
Description:Linux command to get basic information about the OS
Syntax:uname -a
28.sort
Description:Linux command to sort the content of a file while outputting
Syntax: sort filename
29.Ps
Description:Display active processes
Syntax: ps
14
30. Cmp
Description-Allows you to check if two files are identical
Syntax: cmp file1.txt file2.txt
31. Wc
Description:The wc (word count) command prints counts of lines, words, and bytes in a file.
Syntax: wc file name
32.Umask
Description:The umask command controls the default permissions given to newly created files.
Syntax: umask
33.Free
Description:The free command shows the total, used and free amounts of physical and swap memory
on the system. T
Syntax:Free
15
34.Uptime
Description:The uptime command shows how long the Linux system has been running since it was
last rebooted.
Syntax: uptime
35.Date :-
Description: date command is used to display the system date and time. date command is also used to
set date and time of the system.
Syntax: Date
36.Chmod :-
Description: change file mode bits
Syntax:Chmod +r filename.txt
37.find :-
Description: search for files in a directory hierarchy
Syntax:find -name filename.txt
16
Experiment No.3
A] linux Architecture
The Linux operating system's architecture mainly contains some of the components: the Kernel,
System Library, Hardware layer, System, and Shell utility.
Architecture of OS linux
1. Kernel:-
The kernel is one of the core sections of an operating system. It is responsible for each of the major
actions of the Linux OS. This operating system contains distinct types of modules and cooperates
with underlying hardware directly. The kernel facilitates required abstraction for hiding details of
low-level hardware or application programs to the system.
17
2. System Libraries:-
These libraries can be specified as some special functions. These are applied for implementing the
operating system's functionality and don't need code access rights of the modules of the kernel.
4. Hardware layer:-
Linux operating system contains a hardware layer that consists of several peripheral devices like
CPU, HDD, and RAM.
5. Shell:-
It is an interface among the kernel and user. It can afford the services of the kernel. It can take
commands through the user and runs the functions of the kernel. These operating systems are
categorized into two different types, which are the graphical shells and command-line shells.
B] Types of kernel
The kernel manages the system’s resources and facilitates communication between hardware and
software components. These kernels are of different types as follows:
Types of kernel
18
1. Monolithic Kernel
It is one of the types of kernel where all operating system services operate in kernel space. It has
dependencies between system components. It has huge lines of code which is complex.
2. Micro Kernel
It is a kernel type which has a minimalist approach. It has virtual memory and thread scheduling. It is
more stable with less services in kernel space. It puts rest in user space. It is used in small os.
3. Hybrid Kernel
It is the combination of both monolithic kernel and microkernel. It has speed and design of
monolithic kernel and modularity and stability of microkernel.
4. Exo Kernel
It is the type of kernel which follows an end-to-end principle. It has as few hardware abstractions as
possible. It allocates physical resources to applications.
5. Nano Kernel
It is the type of kernel that offers hardware abstraction but without system services. Micro Kernel also
does not have system services therefore the Microkernel and Nano Kernel have become analogous.
19
C] Types of Shells
SHELL is a program which provides the interface between the user and an operating system. When
the user logs in, the OS starts a shell for the user.
1] Bash Shell
Bash, short for Bourne-Again SHell, is the most commonly used shell in Linux. It is the default shell
in most Linux distributions and is also the most powerful. Bash provides a range of features,
including command history, tab completion, and scripting.
Example − To use Bash shell, simply open the terminal and type "bash" or "bash -l" to start a new
session.
2] Tcsh Shell
Tcsh is an enhanced version of C shell (csh) that offers many advanced features designed to make
working in terminal more efficient. It includes advanced tab completion, command history, and job
control.
Example − To use Tcsh shell, first, check if it is installed on your system. If it is not, you can install it
using your package manager. Once installed, you can switch to the Tcsh shell by typing "tcsh" or
"tcsh -l" in the terminal.
20
3] Ksh Shell
Ksh, short for Korn SHell, is a powerful shell that offers many advanced features not available in
other shells. It includes advanced scripting capabilities, job control, and built-in arithmetic operations.
Ksh also provides extensive customization options, allowing users to create their own aliases and
functions.
Example − To use Ksh shell, first, check if it is installed on your system. If it is not, you can install it
using your package manager. Once installed, you can switch to the Ksh shell by typing "ksh" or "ksh
-l" in the terminal.
4] Zsh Shell
Zsh is a powerful and highly customizable shell that offers many features not available in Bash. It
includes advanced completion capabilities, spelling correction, and a powerful scripting language.
Zsh also offers extensive customization options, allowing users to create their own themes and
plugins.
Example − To use Zsh shell, first, check if it is installed on your system. If it is not, you can install it
using your package manager. Once installed, you can switch to the Zsh shell by typing "zsh" or "zsh
-l" in the terminal.
5] Fish Shell
Fish, short for Friendly Interactive SHell, is a user-friendly shell that offers many features designed to
make working in terminal more enjoyable. It includes syntax highlighting, auto-suggestions, and a
built-in help system. Fish is also highly customizable, allowing users to create their own functions
and commands.
Example − To use Fish shell, simply open the terminal and type "fish" or "fish -l" to start a new
session.
21
Difference Between Shell and Kernel
Shell Kernel
It is the interface between kernel and user. It is the core of the operating system.
Its types are – Bourne Shell, C shell, Korn Shell, Its types are – Monolithic Kernel, Micro
etc. kernel, Hybrid kernel, etc.
22
It carries out commands on a group of files by
It performs memory management.
specifying a pattern to match
23
Experiment No.4
A Linux file system is generally a built-in layer of a Linux operating system used to handle the data
management of the storage. It helps to arrange the file on the disk storage. It manages the file name,
file size, creation date, and much more information about a file.
If we have an unsupported file format in our file system, we can download software to deal with it.
The Logical File System acts as the interface between the user applications and the file system itself.
It facilitates essential operations such as opening, reading, and closing files. Essentially, it serves as
the user-friendly front-end, ensuring that applications can interact with the file system in a way that
aligns with user expectations.
The Virtual File System (VFS) is a crucial layer that enables the concurrent operation of multiple
instances of physical file systems. It provides a standardized interface, allowing different file systems
to coexist and operate simultaneously. This layer abstracts the underlying complexities, ensuring
compatibility and cohesion between various file system implementations.
The Physical File System is responsible for the tangible management and storage of physical memory
blocks on the disk. It handles the low-level details of storing and retrieving data, interacting directly
24
with the hardware components. This layer ensures the efficient allocation and utilization of physical
storage resources, contributing to the overall performance and reliability of the file system.
All files on a Linux system are stored on file systems which are organized into a single inverted tree
of directories, know as a file system hierarchy.In the inverted tree, root lies at the top and the
branches of directories and subdirectories stretch below the root.
The Linux File Hierarchy Structure or the Filesystem Hierarchy Standard (FHS) defines the directory
structure and directory contents in Unix-like operating systems. It is maintained by the Linux
Foundation.
● In the FHS, all files and directories appear under the root directory /, even if they are
stored on different physical or virtual devices.
● Some of these directories only exist on a particular system if certain subsystems, such as
the X Window System, are installed.
● Most of these directories exist in all UNIX operating systems and are generally used in
much the same way; however, the descriptions here are those used specifically for the FHS
and are not considered authoritative for platforms other than Linux.
Isha Choudhary 0827CI221065
25
Figure : Linux File System Hierarchy
Here, the directories ‘/’ is the root directory which lies at the top of file system hierarchy. The ‘/’
character is also used as a directory separator in the file name, for example ‘/etc’ is a sub-directory of
‘/’ directory.
Location Purpose
/usr
Installed software, shared libraries, include files, and static read-only program data. Important
subdirectories include:-
* /usr/bin: User commands.
* /usr/sbin: System administration commands.
* /usr/local: Locally customized software.
/etc
Configuration files specific to this system.
26
/var
Files that dynamically change (e.g. databases, cache directories, log files, printer spooled documents,
and website content) may be found under /var.
/run
Run-time data for processes started since the last boot. This includes process ID files and lock files,
among other things. The contents of this directory are recreated on reboot.
/home
Home directories where regular users store their personal data and configuration files.
/root
Home directory for the administrative superuser, root.
/tmp
A world-writable space for temporary files. Files more than 10 days are automatically deleted from
that directory. Another temporary directory exists at /var/tmp, in which files that have not been
accessed,changed, or modified in more than 30 days are deleted automatically.
/boot
Files needed in order to start the boot process.
/dev
Contains special device files which are used by the system to access hardware.
27
Types of Linux File System
When we install the Linux operating system, Linux offers many file systems such as Ext, Ext2, Ext3,
Ext4, JFS, ReiserFS, XFS, btrfs, and swap.
Ext2 is the first Linux file system that allows managing two terabytes of data. Ext3 is developed
through Ext2; it is an upgraded version of Ext2 and contains backward compatibility. The major
drawback of Ext3 is that it does not support servers because this file system does not support file
recovery and disk snapshot.
Ext4 file system is the faster file system among all the Ext file systems. It is a very compatible option
for the SSD (solid-state drive) disks, and it is the default file system in Linux distribution.
28
2. JFS File System
JFS stands for Journaled File System, and it is developed by IBM for AIX Unix. It is an alternative to
the Ext file system. It can also be used in place of Ext4, where stability is needed with few resources.
It is a handy file system when CPU power is limited.
29
Experiment No.5
Linux text editors are software applications used to create, modify, and manipulate text files in a
Linux operating system. They are essential tools for programmers, system administrators, and anyone
working with text-based data. Linux text editors can be broadly categorized into two types:
command-line editors and graphical editors.
● Syntax Highlighting: Most editors can highlight different parts of code or markup to improve
readability.
● Search and Replace: Editors typically include search functionality, often with support for
regular expressions.
● Multiple File Support: Many editors can handle multiple files at once, either through tabs or
split views.
● Customization: Users can often customize key bindings, themes, and other settings to
enhance their workflow.
● Version Control Integration: Some editors support integration with version control systems
like Git.
Use Cases
30
Linux text editors can be broadly categorized into two types:
These editors run in the terminal and are often preferred for their efficiency and speed. Some popular
command-line editors include:
● Vi/Vim:
● Nano:
These editors provide a graphical user interface (GUI) and are more visually oriented. They are
generally easier for beginners and often include features like syntax highlighting, multiple tabs, and
drag-and-drop support. Some popular graphical editors include:
● Sublime Text:
● Atom:
1. Vi/Vim
Overview:
● Vim is a popular text editor program used on Linux and other Unix operating systems. It is an
improved and updated version of the old vi editor. While vim looks basic, it is actually a very
powerful tool for editing files efficiently, especially for programmers and developers. What
makes vim unique is that it has different “modes” for different tasks like navigating files,
editing text, and running commands.
Basic Commands:
31
Nano Editor
Nano is a user-friendly and lightweight command-line text editor widely used on Unix-based systems,
known for its simple interface with on-screen keyboard shortcuts, syntax highlighting support for
programming languages, and basic editing features like search/replace, undo/redo, and multiple file
buffers, making it an accessible choice for beginners and experienced users alike.
Basic Commands:
32
Experiment No.6
AIM: Create a file called wlcc.txt with some line and display how many lines,
words and characters are present in the file
To create a file called wlcc.txt and display the number of lines, words, and characters it contains,
you can follow these steps:
Step 3: Display the text which is in the wlcc.txt by using cat command.
Step 4: Display how many lines, words and characters are present in the file by using wc command.
WC: wc stands for word count. As the name implies, it is mainly used for counting purposes.
It is used to find out the number of lines, word count, byte and characters count in the files specified
in the file arguments.
33
Experiment No.7
In Linux, text files store information in plain text, and each line typically represents a piece of data.
Appending lines involves adding new information to the end of an existing file, preserving its current
content.
34
Experiment No.8
In Linux, file permissions control who can read, write, or execute a file. Understanding how to
change file permissions is essential for system security and user management. The primary command
used to change file permissions is chmod.
File Permissions
Categories of Users
Types of Permissions
35
Permissions can be represented in two ways:
36
1.To Check the Permission of Files in Linux.
Command- ls -l
3.To revoke all the read(r), write(w), and execute(x) permission from all user(u), group(g), and
others(o) for the file wlcc.txt.
4.To add read(r) and write(w) permission to both user(u) and group(g) and revoke execute(x)
permission from others(o) for the file wlcc.txt.
37
Experiment No. 9
Shell Scripting
Usually, shells are interactive, which means they accept commands as input from users and execute
them. However, sometimes we want to execute a bunch of commands routinely, so we have to type in
all commands each time in the terminal.
As a shell can also take commands as input from file, we can write these commands in a file and can
execute them in shell to avoid this repetitive work. These files are called Shell Scripts or Shell
Programs. Shell scripts are similar to the batch file in MS-DOS. Each shell script is saved with `.sh`
file extension e.g., myscript.sh.
A shell script has syntax just like any other programming language. If you have any prior experience
with any programming language like Python, C/C++ etc. It would be very easy to get started with it.
A shell script comprises the following elements –
● Shell Keywords – if, else, break etc.
● Shell commands – cd, ls, echo, pwd, touch etc.
● Functions
● Control flow – if..then..else, case and shell loops etc.
38
Some Advantages of shell scripts
● The command and syntax are exactly the same as those directly entered in the command
line, so programmers do not need to switch to entirely different syntax
● Writing shell scripts are much quicker
● Quick start
● Interactive debugging etc.
39
1.Write a shell script to print “Hello Learner”.
Script:
Output:
2.Write a bash script program to take run-time argument from the user as a name
and print “Greetings <Your name>”.
Script:
Output:
40
3.Demonstrate the shell script with different usage of variables.
Script:
Output:
(a)
Script:
41
Output:
4(b):
Script:
Output:
42
5.Write a shell script to take two values as an argument from the user and compare them.
Script:
Output:
43
6.Write a shell script to check whether the given input is even or odd.
Script:
Output:
Script:
44
Output:
Script:
45
Output:
Script:
Output:
46
10.To check the given number and its reverse are the same.
Script:
Output:
47
11.Demonstrate shell script with diff variable.
Script:
Output:
Script:
48
Output:
Script:
Output:
49
15.WAP to print prime numbers between 1 and 50.
Script:
Output:
50
16. Write a shell script to count the number of vowels in a line of text.
Script:
Output:
51
17. Write a Shell Script to find the smallest number from a set of numbers.
Script:
Output:
52
18.Write a Shell Script to display student grades.
Script:
Output:
53
19. Write a Shell Script to print marksheet, that takes five subjects marks at runtime and
calculate the percentage of a student.
Script:
Output:
54
Experiment No. 10
Case Study: Setting Up and Configuring Apache Tomcat, Samba, DNS/LDAP Services,
Firewall, and Proxy Server Configuration in a Networked Environment
Overview:
This case study focuses on the implementation of a networked environment that includes Apache
Tomcat for web applications, Samba for file sharing, DNS and LDAP for directory services,
firewall configurations for security, and proxy server settings for controlled internet access. The
environment is designed to support a medium-sized organization with a focus on security,
performance, and ease of management.
Objective:
Environment Setup:
• Hardware:
A server with at least 16GB RAM, 4 CPU cores, and 500GB of storage.
• Operating System:
Ubuntu Server 22.04 LTS.
• Network Configuration:
Static IP addressing for servers, DHCP for client machines.
55
A. Deploying Apache Tomcat
Installation Steps:
4. Set Permissions:
5. Start Tomcat:
Configuration:
56
B. Setting Up Samba
Installation Steps:
1. Install Samba:
2. Configure Samba:
57
C. Implementing DNS and LDAP
1. Install Bind9
3. Restart Bind9
1. Install OpenLDAP
2. Configure LDAP:
Use dpkg-reconfigure slapd to set up the domain and admin password.
3. Add Users:
Create LDIF files and use ldapadd to populate the directory.
58
D. Configuring the Firewall Installation and Configuration:
1. Install UFW
1.Install Squid:
2.Configure Squid:
Summary
This setup provides a secure, scalable infrastructure with Apache Tomcat for web applications,
Samba for file sharing, DNS and LDAP for centralized resource and user management, and
firewall/proxy configurations for network security. Following best practices in securing access and
monitoring logs helps in maintaining a reliable and compliant environment.
59
Isha Choudhary 0827CI221065
60