Chapter 3 Network File System

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 41

Ch.

3 Network File System


Introduction to Network file system
• Network File System (NFS) is a distributed file system protocol
• allows a computer to access and share files over a network as if they
were local files.
• NFS enables transparent remote file access and sharing between
computers, even if they have different operating systems.
• NFS allows the user or system administrator to mount (designate as
accessible) all or a portion of a file system on a server. The portion of
the file system that is mounted can be accessed by clients with
whatever privileges are assigned to each file (read-only or read-write).
Key features of NFS include:
• Remote File Access
• Cross-Platform Support
• File Caching
• Security
Portmapper
• When a program on a client machine wants to access a particular RPC
service on a server, it needs to know the port number where that
service is listening. The Portmapper daemon maintains a list of
program numbers and their corresponding port numbers, making it
easier for client programs to locate and communicate with the
appropriate RPC services on a serve
• Dynamic Port Allocation:
• Service Discovery:
NFSD deamon
• The nfsd daemon is a component of the Network File System (NFS)
infrastructure that runs on UNIX-like operating systems, including
Linux.
• It is responsible for providing the server-side functionality of the NFS
protocol, allowing remote clients to access and interact with files and
directories on the server as if they were local.
• Here's how the nfsd daemon works:
• Exported File Systems: The nfsd daemon exports specific directories (file systems) on the server to be
accessible by remote NFS clients. These exported directories are referred to as "exports" or "exports file
systems."
• Client Requests: When a remote NFS client wants to access files on the server, it sends NFS requests to the
nfsd daemon running on the server. These requests could include actions such as reading files, writing files,
creating directories, and more.
• NFS Protocol Handling: The nfsd daemon interprets the incoming NFS requests, performs the requested
operations on the server's file system, and generates corresponding responses to be sent back to the
client.
• File System Operations: The nfsd daemon interacts with the local file system to perform the requested
operations. For example, if a client requests to read a file, the nfsd daemon reads the file from the local
disk and sends the content back to the client.
• Response to Client: After processing the NFS request and performing the necessary file system operations,
the nfsd daemon sends a response back to the client. This response contains the requested data or the
result of the operation.
Mountd Deamon
• The mountd daemon is a component of the Network File System
(NFS) infrastructure that runs on UNIX-like operating systems,
including Linux.
• It works in conjunction with the nfsd daemon to provide NFS server
functionality.
• Specifically, the mountd daemon is responsible for handling client
requests to mount (attach) remote file systems on the server.
• Client Mount Requests: When a remote NFS client wants to access a
specific exported directory on the NFS server, it sends a mount request to
the mountd daemon running on the server.
• Mount Export Verification: The mountd daemon verifies whether the
requested directory is actually exported and allowed for mounting by the
client. It checks the /etc/exports file (or a designated configuration file) to
determine which directories can be mounted by which clients.
• Mount Point Creation: If the requested directory is exportable, the
mountd daemon creates a mount point for the remote file system within
the server's file system hierarchy. This allows the client to access the
remote files as if they were local.
Here's how the mountd daemon works:
• Response to Client: After the mount point is created, the mountd
daemon sends a response back to the client, indicating that the
mount request has been granted and providing the necessary
information for the client to access the remote file system.
• Access Control: The mountd daemon also enforces access control by
checking client IP addresses against the export configuration. This
ensures that only authorized clients can mount the specified
directories.
Setting up the host server
Step 1: Install NFS Kernel Server
$ sudo apt update
$sudo apt install nfs-kernel-server
Step 2: Create the Export Directory
The directory that we want to share with the client system is called an
export directory. You can name it according to your choice; here, we
are creating an export directory by the name of “sharedfolder” in our
system’s mnt(mount) directory.
$ sudo mkdir /mnt/sharedfolder
As we want all clients to access the directory, we will remove restrictive
permissions of the export folder through the following commands:
$ sudo chown nobody:nogroup /mnt/sharedfolder
$ sudo chmod 777 /mnt/sharedfolder
Step 3: Assign server access to client(s) through NFS export file

• After creating the export folder, we will need to provide the clients
the permission to access the host server machine. This permission is
defined through the exports file located in your system’s /etc folder.
$ sudo /etc/exports
• Once you have opened the file, you can allow access to:

• A single client by adding the following line in the file:


• /mnt/sharedfolder clientIP(rw)
• Multiple clients by adding the following lines in the file:
• /mnt/sharedfolder client1IP(rw)
• /mnt/sharedfolder client2IP(rw)
Step 4: Export the shared directory

• After making all the above configurations in the host system, now is
the time to export the shared directory through the following
command as sudo:

$ sudo exportfs –a
Sudo systemctl enable nfs-kernel-server
Step 5: Open firewall for the client (s)

$ sudo ufw allow from [clientIP ] to any port nfs


• Now when you check the status of your Ubuntu firewall through the
following command, you will be able to view the Action status as
“Allow” for the client’s IP. $ sudo ufw status
Configuring the Client Machine

• Step 1: Install NFS Common


$ sudo apt update
$ sudo apt install nfs-common
Step 2: Create a mount point

• Your client’s system needs a directory where all the content shared by
the host server in the export folder can be accessed. You can create
this folder anywhere on your system. We are creating a mount folder
in the mnt directory of our client’s machine:
• $ sudo mkdir -p /mnt/sharedfolder_client
Step 3: Mount the shared directory on the client

• The folder that you created in the above step is like any other folder on
your system unless you mount the shared directory from your host to
this newly created folder.

• Use the following command in order to mount the shared folder from
the host to a mount folder on the client:

• $ sudo mount serverIP:/exportFolder_server /mnt/mountfolder_client


• ls /mnt/nfs-mount
How to Mount and Unmount Filesystem in Linux

• Mount is to access a filesystem in Linux.


• You can mount a filesystem on any directory and access content by
entering to that directory. In Linux terms, these directories are called
mount points
• Create a Mount Point: A mount point is an empty directory where
you will attach the filesystem. You can create a directory using the
mkdir command. For example, to create a mount point named
"my_mount_point", use:

• sudo mkdir /mnt/my_mount_point


Use mount Command

• Mount the Filesystem: Use the mount command to attach the


filesystem to the mount point. The basic syntax is:
• sudo mount [device/partition] [mount_point]
• For example, to mount a partition /dev/sdb1 to the mount point
/mnt/my_mount_point, use:
• sudo mount /dev/sdb1 /mnt/my_mount_point
Unmount Filesystem

• Use umount command to unmount any mounted filesystem on your


system.
• Run umount command with disk name or mount point name to
unmount currently mounted disk.
• $ umount /dev/sdb

• $ umount /data
Introduction to printing
• Printing in Linux involves sending documents or files from your computer to a
physical printer for hard-copy output.
• Here are the general steps to print in Linux:
• Connect the Printer:
• Install Printer Drivers:
• Open the Document:
• Select Printer and Configure Settings:
• Print the Document:
• Monitor the Print Queue:
• Manage Print Jobs:
• Troubleshooting:
Components in printing System.
• Print Device File
• Spooler:
• A software program responsible for managing all print jobs currently
being sent to the computer printer or print server.
• The print spooler program may allow a user to delete a print job
being processed or otherwise manage the print jobs currently waiting
to be printed.
• he spooler also handles communication between the application, the
printer driver, and the printer.
Print queue
• A print queue is a list of printer output jobs held in a reserved memory area. It
maintains the most current status of all active and pending print jobs.
• A print queue generally displays the following information:
Document name: Shows the file name of the print job
• Status: Indicates the status of the print job
• Owner: Shows the user, which is helpful in a shared network printing
environment
• Pages: Shows the total number of printed pages
• Size: Shows the printed document size, usually in KB
• Submitted: Shows the date and timestamp of a pending or printed document
• Port: Shows the printer port
/etc/printcap
• The /etc/printcap file is a configuration file used in Unix-like operating
systems, including Linux, to define printer settings and capabilities
for the system's printing subsystem.
• It's a plain text file that provides information about the printers
available on the system, their capabilities, and how print jobs should
be processed and sent to the printers.
• The printcap database for describing printers
• The spooling system accesses the printcap file every time it is used, so
you can dynamically add or remove printers.
• Each entry in the database describes one printer.
Managing the Print Queues
lp Command
• The lp command is a command-line utility in Linux and other Unix-like
operating systems that is used to send print jobs to printers. It is a part
of the printing subsystem and allows users to print documents and files
from the command line. Linux lp printing command examples
• Commonly used options with the lp command include:
• -d printer: Specifies the printer to which the print job should be sent.
• -n copies: Specifies the number of copies to print.
• -o option=value: Specifies additional options for printing, such as page
orientation, page size, etc.
• -q priority: Sets the print job priority in the print queue.
• Print a file named document.txt to the default printer:
• lp document.txt
• Print multiple copies of a file and set the printer:
• lp -d printer_name -n 3 document.txt
lpq
• The lpq command is a command-line utility in Linux and other Unix-like
operating systems that allows you to view the print queue status and
display information about print jobs that are waiting to be printed.
• It provides a snapshot of the current state of the print queue, showing
details about pending print jobs, such as their job IDs, owner names, status,
and position in the queue.
• lpq [options] [printer]
• Here, [options] are various command options you can use with the lpq
command, and [printer] is the name of the printer whose queue you want
to view. If you omit the printer name, the lpq command will display
information for the default printer.
• -P printer: Specifies the name of the printer whose queue you want to
view.
• -a: Shows all printers' queues, not just the default printer.
• -l: Provides more detailed information, including the time the job was
submitted and the size of the print job.
lprm
• The lprm command is a command-line utility in Linux and other Unix-
like operating systems that allows you to remove or cancel print jobs
from the print queue.
• It is used to delete print jobs that are currently waiting to be printed
or are in the process of being printed.
• The lprm command requires administrative privileges (usually
superuser or root access) in order to remove print jobs from the
queue.
• lprm [options] [job number(s)] [user(s)]
• Here, [options] are various command options you can use with the
lprm command, [job number(s)] are the identifiers of the print jobs
you want to remove, and [user(s)] are the names of users whose print
jobs you want to remove. If you don't specify any job numbers or
users, lprm will remove the jobs of the current user.
• Commonly used options with the lprm command include:
• -: Removes all jobs belonging to the current user.
• -P printer: Specifies the name of the printer from which you want to
remove jobs.
• -U user: Removes jobs belonging to the specified user.
• -J job-name: Removes jobs with the specified name.
lpstat
• used to display information about print queues and printer status on a
system. It provides various details about the current state of printers
and print jobs, which can be useful for administrators and users who
need to manage printing tasks.
• Displaying a list of available printers and their status.
• Showing the status of print jobs in the queue, such as whether they
are printing, held, or completed.
• Providing information about the default printer.
• Showing information about the classes of printers (groups of printers
that share the same destination).
• To display a list of printers and their status:
• lpstat –p
• To display information about a specific printer (replace printer-name with the actual
printer name):
• lpstat -p printer-name
• To display the status of print jobs in the queue:
• lpstat –o
• To display information about the default printer:
• lpstat –d
• To display information about printer classes:
• lpstat -c
Installing CUPS

• CUPS stands for Common UNIX Printing System. It is a modular, open-source


printing system that provides a standardized interface for managing and
printing documents on Unix-like operating systems, including Linux.
• allow administrators and users to easily configure, manage, and share
printers on a network. sudo apt-get update && sudo apt-get install cups
• Printer Management
• Driver Support:
• Network Printing
• Authentication and Authorization
• This command will install the Common Unix Printing System on your system.

You might also like