0% found this document useful (0 votes)
302 views31 pages

Linux Lab

command of linux

Uploaded by

santoshdhokare71
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
302 views31 pages

Linux Lab

command of linux

Uploaded by

santoshdhokare71
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 31

lOMoARcPSD|37387228

Linux lab

Linux (Rajiv Gandhi Proudyogiki Vishwavidyalaya)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)
lOMoARcPSD|37387228

Linux Lab [CS505]

SRI AUROBINDO INSTITUTE OF


TECHNOLOGY

LINUX LAB [CS-505]

Submitted to:
Mr. Suneet Joshi
Assistant Professor

BACHELORS OF TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE AND
ENGINEERING
Session-2021-22

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING

CERTIFICATE

This is to certify that Mr./Ms ………. with RGPV Enrollment No. ….…. has satisfactorily
completed the course of experiments in ….LINUX LAB…. laboratory, as prescribed by Rajiv
Gandhi Proudhyogiki Vishwavidhyalaya, Bhopal for ….5th …. Semester of the Computer
Science and Engineering Department during year 2020-2021

Signature of
Faculty In-charge

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

DEPT. OF COMPUTER SCIENCE & ENGG.


2020-2021
LIST OF EXPERIMENTS

CLASS: V SEM (CSE)


SUBJECT: Linux LAB [CS505]
Sl. LIST OF EXPERIMENTS Date of Date of Page Staff
No. Experiment submission No. Sign
1 To Study basic & User status Unix/Linux 6/08/2021 4-6
Commands.
2 Study & use of commands for performing 13/08/2021 7-9
arithmetic operations with Unix/Linux
3 Create a file called wlcc.txt with some lines and 20/08/2021 10-11
display how many lines, words and characters
are present in that file.
4 Append ten more simple lines to the wlcc.txt file 27/08/2021 12
created above and split the appended file into
3parts. What will be the names of these split
files? Display the contents of each of these files.
How many lines will be there on the last file?
5 Given two files each of which contains names of 3/09/2021 13
students. Create a program to display only those
names that are found on both the files.
6 Create a program to find out the inode number 17/09/2021 14
of any desired file.
7 Study & use of the Command for changing file 24/09/2021 15
permissions.
8 Write a pipeline of commands, which displays on 1/10/2021 16
the monitor as well as saves the information
about the number of users using the system at
present on a file called usere.ux.
9 Execute shell commands through vi editor. 8/10/2021 17
10 Write a shell script that accepts any number of 22/10/2021 18
arguments and prints them in the reverse order.
11 Write a shell script to find the smallest of three 29/10/2021 19
numbers that are read from the
keyboard.
12 Write a shell script that reports the logging in of 12/11/2021 20
a specified user within one minute after he/she
logs in. The script automatically terminates if the
specified user does not login during a specified
period of time.
13 Installation of SAMBA, APACHE, TOMCAT. 26/11/2021 21-22
14 Implementation of DNS, LDAP services 26/11/2021 23
15 Study & installation of Firewall & Proxy server. 26/11/2021 24-25

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 1

Aim: To Study basic & User status Unix/Linux Commands.

Theory:

>File 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 want to see.
• 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 (see below)
• 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.

>Directory Commands:

• cd - change directories. Use cd to change directories. Type cd followed by the name of a


directory to access that directory. Keep in mind that you are always in a directory and can
navigate to directories hierarchically above or below.
• mv- change the name of a directory. Type mv followed by the current name of a directory
and the new name of the directory. Ex: mv testdir newname dir
• pwd - print working directory will show you the full path to the directory you are currently
in. This is very handy to use, especially when performing some of the other commands on
this page
• rmdir - Remove an existing directory
• rm -r-Removes directories and files within the directories recursively.
• ls - Short listing of directory contents
o -a list hidden files
o -d list the name of the current directory
o -F show directories with a trailing '/'
o -o executable files with a trailing '*'
o -g show group ownership of file in long listing
o -i print the inode number of each file

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

o -l long listing giving details about files and directories


o -R list all subdirectories encountered
o -t sort by time modified instead of name
• cp - Copy files
o cp myfileyourfile
o Copy the files "myfile" to the file "yourfile" in the current working directory. This
command will create the file "yourfile" if it doesn't exist. It will normally overwrite
it without warning if it exists.
o cp -imyfileyourfile
o With the "-i" option, if the file "yourfile" exists, you will be prompted before it is
overwritten.
o cp -i /data/myfile
o Copy the file "/data/myfile" to the current working directory and name it "myfile".
Prompt before overwriting the file.
o cp -dprsrcdirdestdir
o Copy all files from the directory "srcdir" to the directory "destdir" preserving links
(-poption), file attributes (-p option), and copy recursively (-r option). With these
options, a directory and all it contents can be copied to another dir
• ln - Creates a symbolic link to a file.
o ln -s test symlink
o Creates a symbolic link named symlink that points to the file test Typing "ls -i test
symlink" will show the two files are different with different inodes. Typing "ls -l
test symlink" will show that symlink points to the file test.
• locate - A fast database driven file locator.
• slocate -u----This command builds the slocate database. It will take several minutes to
complete this command. This command must be used before searching for files, however
cron runs this command periodically on most systems.locatewhereis Lists all files whose
names contain the string "whereis". directory.
• more - Allows file contents or piped output to be sent to the screen one page at a time
• less - Opposite of the more command
• cat - Sends file contents to standard output. This is a way to list the contents of short files
to the screen. It works well with piping.
• whereis - Report all known instances of a command
• wc - Print byte, word, and line counts
• bg:bg jobs Places the current job (or, by using the alternative form, the specified jobs) in
the background, suspending its execution so that a new user prompt appears immediately.
Use the jobs command to discover the identities of background jobs.
• cal month year - Prints a calendar for the specified month of the specified year.
• cat files - Prints the contents of the specified files.
• clear - Clears the terminal screen.
• cmp file1 file2 - Compares two files, reporting all discrepancies. Similar to the diff
command, though the output format differs.
• diff file1 file2 - Compares two files, reporting all discrepancies. Similar to the cmp
command, though the output format differs.
• dmesg - Prints the messages resulting from the most recent system boot.
• Fg

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

o fg jobs - Brings the current job (or the specified jobs) to the foreground.
• file files - Determines and prints a description of the type of each specified file.
• find path -name pattern -print -----Searches the specified path for files with names
matching the specified pattern (usually enclosed in single quotes) and prints their names.
The find command has many other arguments and functions; see the online documentation.
• finger users - Prints descriptions of the specified users.
• free -Displays the amount of used and free system memory.
• ftp hostname: Opens an FTP connection to the specified host, allowing files to be
transferred. The FTP program provides subcommands for accomplishing file transfers; see
the online documentation.
• head files - Prints the first several lines of each specified file.
• ispell files - Checks the spelling of the contents of the specified files.
• kill process_ids
o kill - signal process_ids
o kill -l
o Kills the specified processes, sends the specified processes the specified signal
(given as a number or name), or prints a list of available signals.
• killall program
o killall - signal program:Kills all processes that are instances of the specified
program or sends the specified signal to all processes that are instances of the
specified program.
• mail - Launches a simple mail client that permits sending and receiving email messages.
• man title :man section title - Prints the specified man page.
• ping host - Sends an echo request via TCP/IP to the specified host. A response confirms
that the host is operational.
• reboot - Reboots the system (requires root privileges).
• shutdown minutes
o shutdown -r minutes
o Shuts down the system after the specified number of minutes elapses (requires root
privileges). The -r option causes the system to be rebooted once it has shut down.
• sleep time - Causes the command interpreter to pause for the specified number of seconds.
• sort files - Sorts the specified files. The command has many useful arguments; see the
online documentation.
• split file - Splits a file into several smaller files. The command has many arguments; see
the online documentation
• sync - Completes all pending input/output operations (requires root privileges).
• telnet host - Opens a login session on the specified host.
• top - Prints a display of system processes that's continually updated until the user presses
the q key.
• traceroute host - Uses echo requests to determine and print a network path to the host.
• uptime - Prints the system uptime.
• w - Prints the current system users.
• wall - Prints a message to each user except those who've disabled message reception.
Type Ctrl-D to end the message.

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 2

Aim: To understand how arithmetic operations work in Unix/Linux.

Theory:

The following arithmetic operators are supported by Bourne Shell.


Assume variable a holds 10 and variable b holds 20 then –
Operator Description Example

+ (Addition) Adds values on either side of the `expr $a + $b` will give 30
operator

- (Subtraction) Subtracts right hand operand from left `expr $a - $b` will give -10
hand operand

* (Multiplication) Multiplies values on either side of the `expr $a \* $b` will give 200
operator

/ (Division) Divides left hand operand by right hand `expr $b / $a` will give 2
operand

% (Modulus) Divides left hand operand by right hand `expr $b % $a` will give 0
operand and returns remainder

= (Assignment) a = $b would assign value of b into a


Assigns right operand in left operand

== (Equality) Compares two numbers, if both are [ $a == $b ] would return false.


same then returns true.

!=(Not Equality) Compares two numbers, if both are [ $a != $b ] would return true.
different then returns true.

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

It is very important to understand that all the conditional expressions should be inside square
braces with spaces around them, for example [ $a == $b ]is correct whereas, [$a==$b] is
incorrect.
All the arithmetical calculations are done using long integers.
Example
Here is an example which uses all the arithmetic operators –
Procedure:
Step 1 : Start with the header file .
Step 2: Initializes the two variables
Step 3: Perform the addition, subtraction, multiplication, division , comparison and
modulus operation
Step 4: Store the value in third variable.
Step 5: Print the value of third variable
#!/bin/sh

a=10
b=20

val=`expr $a + $b`
echo "a + b : $val"

val=`expr $a - $b`
echo "a - b : $val"

val=`expr $a \* $b`
echo "a * b : $val"

val=`expr $b / $a`
echo "b / a : $val"

val=`expr $b % $a`
echo "b % a : $val"

if [ $a == $b ]
then
echo "a is equal to b"
fi

if [ $a != $b ]
then
echo "a is not equal to b"
fi

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

a + b : 30
a - b : -10
a * b : 200
b / a : 2
b % a : 0
a is not equal to b

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 3

Aim: Create a file called wlcc.txt with some lines and display how many lines, words and
characters are present in that file.

Theory:

To introduce the concept of text editing and the options regarding the control of the editor. Few
commands with cat :

• Display Number of Bytes

Enter wc command with -c option to print no. of bytes in a file.

• Display Number of Words

Enter wc followed with -w option to print the no. of words in a file



Display Number of Characters

Enter wc with -m option to print no. of characters in a file

• Display Number of New lines

Enter wc with -l option to print the no. of new lines in the file.

• Display Length of the longest line

Enter wc with -L option to print the no. of characters in the longest line of the file

• Display All

Enter wc and filename without any option will show in the following column order: 1st
column- newlines count, 2nd column- words count and 3rd column- character count.

• Display counts for standard input

Just entering the wc command waits for you to enter some text and after you have written
the text press ctrl+d to end writing. wc counts number of lines, words and bytes.

10

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

$ cat state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh

$ cat capital.txt
Hyderabad
Itanagar
Dispur
Patna
Raipur

$ wc state.txt capital.txt
5 7 63 state.txt
5 5 45 capital.txt
10 12 108 total

$ cat state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh

$ cat capital.txt
Hyderabad
Itanagar
Dispur
Patna
Raipur

$ wc state.txt capital.txt
5 7 63 state.txt
5 5 45 capital.txt
10 12 108 total

11

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

12

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 4

Aim: Append ten more simple lines to the wlcc.txt file created above and split the appended file
into 3.

Theory:

Instead of overwriting another file, we can also append a source text file to another using the
redirection operator ">>".

For instance:

• cat wlcc.txt >> another-text-file.txt

If another-text-file.txt does not already exist, it will be created and the contents
of wlcc.txt will be written to the new file.

• Split file

split: outputs fixed-size pieces of input INPUT to files named PREFIXaa, PREFIXab,
The default size for each split file is 1000 lines, and default PREFIX is "x". With no
INPUT, or when INPUT is a dash ("-"), read from standard input.Split the file wlcc.txt into
files beginning with the name new, each containing 300 lines of text.

13

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

14

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 5

Aim: Append Experiment No.5. Given two files each of which contains names of students.
Create a program to display only those names that are found on both the files.

Theory:
grep command: grep is a command used to search text or searches the given file for lines
containing a match to the given strings or words. By default, grep displays the matching lines.

Code:

$grep -f file1 -o file2 | sort -u

15

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

echo "Which is the best Linux Distro?" >> file.txt


printf "Which is the best Linux Distro?\n" >> file.txt

16

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 6

Aim: Create a program to find out the inode number of any desired filL

Theory:

First find out file inode number with any one of the following commands:

1. stat {file-name}OR

2. ls -il {file-name}

• Use find command to remove file:

• Use find command as follows to find and remove a file:


• find . -inum [inode-number] -exec rm -i {} \;
• When prompted for confirmation, press Y to confirm removal of the file.

• Delete or remove files with inode number

• Let us try to delete file using inode number.


• Create a hard to delete file name:
• Try to remove this file with rm command.
• Remove file by an inode number, but first find out the file inode number.
• Use finds command to delete file by inode. .

Code:

17

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 7

Aim: Study & use of the Command for changing file permissions.

Theory:

>shown - change file owner and group

• Usage
• chown [OPTION] OWNER[:[GROUP]] FILE.
• The following options modify how a hierarchy is traversed when the -R option is also
specified. If more than one is specified, only the final one takes effect.
• -H if a command line argument is a symbolic link to a directory, traverse it.
• -L traverse every symbolic link to a directory encountered.
• -P do not traverse any symbolic links (default).
• chmod - change file access permissions
• chmod [-r] permissions filenames
• r Change the permission on files that are in the subdirectories of the directory that you are
currently in. Permission specifies the rights that are being granted. Below is the different
right that you can grant in an alpha-numeric format filenames. File or directory that are
associated with Permission.
• u - User who owns the file.
• g - Group that owns the file.
• - Other.
• a - All.
• r - Read the file.
• w - Write or edit the file.
• x - Execute or run the file as a program.

Code:
$ ls -li filename
$ ls -li /etc/resolv.conf

18

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

19

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 8

Aim: Write a pipeline of commands, which displays on the monitor as well as saves the
information about the number of users using the system at present on a file called usere.ux.

Theory:

>Script: It will basically save everything printed on the terminal in that script session.

From man script:

• Script makes a typescript of everything printed on your terminal.


• It is useful for students who need a hardcopy record of an interactive session as proof of an
assignment, as the typescript file can be printed out later with lpr(1).
• You can start a script session by just typing script in the terminal, all the subsequent
commands and their outputs will all be saved in a file named typescript in the current
directory. You can save the result to a different file too by just starting script like:

Script usere.ux

To logout of the screen session (stop saving the contents), just type exit.

Here is an example:

1. $ script usere.ux
2. $ ls
3. $ who –u(Show or list users logged in )
4. $ exit
5. $ cat usere.ux

Script also has many options e.g. running quietly -q (--quiet) without showing/saving program
messages, it can also run a specific command -c (--command) rather than a session, it also has
many other options

20

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. - 9

Aim: Execute shell commands through vi editor

Theory:

To introduce the concept of text editing vi editor and the options regarding the control of the editor.
To open a file in vi editor run the command: vi filename .shTo write or modify something in file
go to insert mod by pressing anyone of three keys a/i/oAfter writing in file following modes for
quit from editor.

First press “Escape” key then:

• :q! for quit without saving


• :wq for save & quit

>Operation Modes

While working with the vi editor, we usually come across the following two modes −
• Command mode − This mode enables you to perform administrative tasks such as saving
the files, executing the commands, moving the cursor, cutting (yanking) and pasting the
lines or words, as well as finding and replacing. In this mode, whatever you type is
interpreted as a command.
• Insert mode − This mode enables you to insert text into the file. Everything that's typed
in this mode is interpreted as input and placed in the file.
vi always starts in the command mode. To enter text, you must be in the insert mode for which
simply type i. To come out of the insert mode, press the Esc key, which will take you back to the
command mode.
Hint − If you are not sure which mode you are in, press the Esc key twice; this will take you to
the command mode. You open a file using the vi editor. Start by typing some characters and then
come to the command mode to understand the difference.

>Getting Out of vi

The command to quit out of vi is :q. Once in the command mode, type colon, and 'q', followed
by return. If your file has been modified in any way, the editor will warn you of this, and not let
you quit. To ignore this message, the command to quit out of vi without saving is :q!. This lets
you exit vi without saving any of the changes.
The command to save the contents of the editor is :w. You can combine the above command with
the quit command, or use :wq and return.
The easiest way to save your changes and exit vi is with the ZZ command. When you are in the
command mode, type ZZ. The ZZ command works the same way as the :wq command.

21

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. – 10

Aim: Write a shell script that accepts any number of arguments and prints them in the reverse
order.

Theory:
Procedure:
Step 1 : Start with the header file .
Step 2: Initializes the two variables: Sd and rev
Step 3: Perform the logic to reverse the number.
Step 4: Store the value in third variable.
Step 5: Print the value of third variable

Code:
echo "no of arguments:$#"
echo "arguments in reverse order:"
for i in $*
do
j=$i" "$j
done
echo $j

OR

echo Hello i am shivam and I write this code | rev

22

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. – 11

Aim: Write a shell script to find the smallest of three numbers that are read from the keyboard.

Theory:

Procedure:
Step 1 : Start with the header file .
Step 2: Initializes the three variables: a,b,c
Step 3: Perform the logic to know the smallest number among number entered by user.
Step 4: Store the value in third variable.
Step 5: Print the value of third variable

Code:
echo "enter a: "
read a
echo "enter b : "
read b
echo "enter c : "
read c
s=$a
if [ $b -lt $s ]
then
s=$b
fi
if [ $c -lt $s ]
then
s=$c
fi
echo Smallest of $a $b $c is $s

23

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

24

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. – 12

Aim: Write a shell script that reports the logging in of a specified user within one minute after
he/she logs in. The script automatically terminates if the specified user does not login during a
specified period of time.

Theory:

Procedure:

Step 1 : Start with the header file .


Step 2: Retrieve the user name and login time
Step 3: Give the command to print name and logging details.
Step 4: Print the specific period of time
Step 5: Print the value of third variable

Code:

if who -u | grep -q "^$user "; then


top -u "$user"
else
echo "User $user is not logged in"
fi

25

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. – 13

Aim: Installation of SAMBA, APACHE TOMCAT.

Theory:

An Apache Tomcat is an open source web application server which supports J2ee Servlet us,
JavaServer, Pages (JSP) and API's. Tomcat should not be confused with Apache web server
which an HTTPweb server.

>Some Terminology About Apache Tomcat.


An Apache Tomcat can be configured by editing server.xml file. This server.xml file of Tomcat
can take as synonyms to httpd.conf file for Apache web server.

Servlet is defined as a way add dynamic content to a Web server using the Java platform. A
servlet container is a compiled, executable program. The servlet container name of Tomcat is
called as Catalina.

>Prerequisite for apache tomcat are


1. java
2. JDK
>Step by step for installing apache tomcat
Note: Avoide installing tomcat from repositories, always prefer to install it from source
downloaded from Apache site.

Step1: Install all the prerequisites


Step2: Download tomcat source package and uncompress it.
Step3: Setup the paths for Catalina and others.
Step4: Now start tomcat server
Step5: By default Apache Tomcat will be hosted on localhost : 8080 port by default.

>Samba
Samba is the standard open source Windows interoperability suite of programs for Linux. It
implements the server message block (SMB) protocol. Modern versions of this protocol are also
known as the common Internet file system (CIFS) protocol. It allows the networking of
Microsoft Windows, Linux, UNIX, and other operating systems together, enabling access to
Windows-based file and printer shares. Samba’s use of SMB allows it to appear as a Windows
server to Windows clients.

Installing the samba package

In order to use Samba, first ensure the samba package is installed on your system by running,
as root:

26

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

~]# dnf install samba

>Introduction to Samba

Samba is an important component to seamlessly integrate Linux Servers and Desktops into
Active Directory (AD) environments. Samba can do:

• Serve directory trees and printers to Linux, UNIX, and Windows clients
• Assist in network browsing (with NetBIOS)
• Authenticate Windows domain logins
• Provide Windows Internet Name Service (WINS) name server resolution
• Act as a Windows NT-style Primary Domain Controller (PDC)
• Act as a Backup Domain Controller (BDC) for a Samba-based PDC

>Connecting to a Samba Share

Nautilus or command line to connect to available Samba shares.

Connecting to a Samba Share Using Nautilus

1. To view a list of Samba workgroups and domains on your network,


select Places Network from the GNOME panel, and then select the desired network.
Alternatively, type smb: in the File Open Location bar of Nautilus.

An icon appears for each available SMB workgroup or domain on the network.

2. Double-click one of the workgroup or domain icon to view a list of computers within the
workgroup or domain.

3. An icon exists for each machine within the workgroup. Double-click on an icon to view the
Samba shares on the machine. If a user name and password combination is required, you are
prompted for them.

27

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. – 14

Aim: Implementation of DNS, LDAP services.

Theory:

Domain Name Service (DNS) is an internet service that maps IP addresses to fully qualified
domain names (FQDN) and vice versa.

BIND stands for Berkley Internet Naming Daemon.

BIND is the most common program used for maintaining a name server on Linux.

1. Network Information
2. Install Bind
3. Configure Cache NameServer
4. Test the Cache NameServer
5. Configure Primary/Master Nameserver
6. Build the Forward Resolution for Primary/Master NameServer
7. Test the DNS server

28

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

Experiment No. – 15

Aim: Study & installation of Firewall & Proxy server.

Theory:

A proxy server is a computer that acts as an intermediary between a desktop computer and the
internet and allows a client machine to make an indirect connection to network servers and
services. There are many reasons why you might want to include a proxy server on your network:

• To share internet connection on a LAN


• To speed up internet surfing
• To hide the IP address of the client computer for anonymous surfing
• To implement internet access control
• To scan outbound content
• To circumvent regional restrictions

Procedure

Step #1 Install Squid


Step #2: Verify the Squid Installation
Step #3: Start Squid and Configure it To Start on Boot

>Configuring Firewall Port Settings

The main area of the Firewall Configuration tool consists of a list of categories on in the left hand
pane and the current corresponding settings for that category in the right hand panel.

The Trusted Services category essentially defines which TCP/IP ports are open to traffic on the
firewall. There a number of so called known ports which are assigned to specific servers (such as
port 80 for a web server).

>Primary services is as follows:

SSH - The secure shell provides an encrypted mechanism for allowing password protected remote
access to your system. With SSH you can remotely log into to your system, copy files to and from
your system and another systems and perform remote execution of programs. If you need remote
access to your system you will need to activate this. If you do not need remote access leave this
disabled. Note that the ssh server is not installed by default on Fedora Linux.

Telnet - Telnet provides remote terminal access to your system. It does not use encryption and use
is strongly discouraged. Leave this disabled and use SSH instead for remote access.

WWW (HTTP) - If you are hosting a web server on your Fedora Linux System you will need to
enable HTTP traffic through the firewall to enable web page requests to reach the http server. If
you do not plan to host a web server, leave this disabled. Note that the Apache web server is not

29

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)


lOMoARcPSD|37387228

Linux Lab [CS505]

installed by default on Fedora Linux unless you specifically requested during the installation
process.

Mail (SMTP) - Specifies whether the firewall blocks Simple Mail Transfer Protocol traffic. This
is only necessary if you are hosting a mail server on your Fedora Linux system. If you only use a
mail client to download email from a POP3 or IMAP server you can safely leave this disabled.
Note that the SMTP server is not installed by default on Fedora Linux.

FTP - Controls whether File Transfer Protocol traffic is permitted through the firewall. Unless you
plan to set up an ftp server (unlikely for typical users) leave this option disabled. Note that the FTP
server is not installed by default on Fedora Linux.

Samba - The Samba service is allows files and printers to be shared between Linux and Windows
systems. If this traffic is blocked in the firewall, it will not be possible to use Samba on this system.

30

Downloaded by Santosh Dhokare (santoshdhokare71@gmail.com)

You might also like