Module 5file
Module 5file
General Samba configuration involves installing the software, editing the primary configuration
file located at /etc/samba/[Link], defining shares, and managing user access. Samba provides
seamless file and print services across Linux/Unix and Windows clients using the SMB/CIFS
protocol.
2. Create a Shared Directory: Create a directory on the server that you intend to share and
set appropriate Linux permissions (e.g., /srv/samba/shared).
3. Edit the Configuration File: The main configuration is within the [Link] file. It is
recommended to make a backup of the original file before editing: sudo cp
/etc/samba/[Link] /etc/samba/[Link].
Open the file in a text editor like nano: sudo nano /etc/samba/[Link].
The file uses sections (e.g., [global], [homes]) and name = value parameters.
4. Configure Global Settings: The [global] section defines server-wide behavior. Key
parameters include:
server role = standalone server: Defines the server's role in the network.
interfaces = lo eth0 (optional): Binds Samba to specific network interfaces for
security.
5. Define a Share: Add a new section at the end of the [Link] file to define a shared
directory.
browsable = yes: Makes the share visible in network browsing (e.g., Windows
File Explorer).
guest ok = no: Requires authentication to access the share (use yes for
public/anonymous access).
6. Create Samba Users: Users must exist as system accounts and be added to the Samba
database to access protected shares.
Create a system user (without a login shell if they only need Samba access): sudo
useradd -M -s /sbin/nologin exampleuser.
Add the user to the Samba database and set a Samba-specific password: sudo
smbpasswd -a exampleuser.
7. Test and Restart: Verify the configuration file for errors using testparm -s and restart the
Samba services to apply changes.
testparm -s
sudo systemctl restart smbd nmbd (or sudo service smbd restart on older systems).
Features: Provides a wizard interface for initial setup and help pages for configuration
options.
Security Risk: Because it can be used to modify Samba configurations and requires root
credentials, it poses risks if exposed, and it has been associated with vulnerabilities.
Graphical Configuration: Provides a simple GUI for adjusting server settings without
manual text editing.
Context-Sensitive Help: Features direct links to man pages and detailed explanations for
every configuration parameter.
Wizard Interface: Includes a setup wizard to help quickly establish a basic Samba
configuration.
Security Risks: SWAT is often disabled by default because it sends passwords in clear
text unless configured with SSL/TLS. It has also been subject to vulnerabilities
like clickjacking and CSRF in older versions.
Important Warning
When SWAT saves changes, it rewrites the [Link] file, which removes all manual
comments and rearranges parameters into its own internal order. It is highly
recommended to back up your configuration before use.
NFS is a distributed file system protocol, originally developed by Sun Microsystems, that allows
users to access files and directories on remote computers over a network as if they were on a
local machine. It facilitates centralized storage and seamless sharing across Linux, Unix, and
Windows environments.
Functionality: NFS servers "export" directories, which clients then "mount" to access
files.
Protocols & Versions: It relies on Remote Procedure Calls (RPC). Key versions include
NFSv3 (robust, supports 64-bit file sizes) and NFSv4 (modern version with built-in
locking).
Use Cases: Primarily used in enterprise networks, data centers, and cloud storage for
shared file access.
Configuring an NFS:
Configuring an NFS client involves installing the necessary software, creating a local directory
as a mount point, and using the mount command or editing the /etc/fstab file to access the
remote share.
On Linux
The specific package names and commands may vary slightly based on the Linux distribution
(e.g., Ubuntu/Debian uses apt, RHEL/CentOS uses yum or dnf), but the general process is the
same.
For Ubuntu/Debian: sudo apt update followed by sudo apt install nfs-common.
2. Create a local mount point directory: This is where the remote share will be accessed
from. The directory should ideally be empty.
3. Mount the NFS share temporarily: Use the mount command to manually mount the
share.
You can specify mount options (like rw, sync, hard, noresvport) with the -o flag
for performance or data integrity.
4. Verify the mount: Check that the share is mounted using df -h or mount | grep nfs.
5. Mount the NFS share permanently (optional): To have the share automatically
mounted on system boot, add an entry to the /etc/fstab file.
Add a line with the server details, mount point, file system type (nfs), and options:
<NFS_server_IP>:/path/on/server /mnt/nfs_share_client nfs defaults 0 0
Run sudo mount -a to mount all entries in fstab and verify the entry is correct
before the next reboot.
On Windows
On the Select features page, check the box for Client for NFS and
click Install.
2. Mount the NFS share: After installation, you can use the [Link] command in
PowerShell (as Administrator) to mount the share.
The share will now be accessible via the assigned drive letter in File
Explorer.
CUPS (Common UNIX Printing System) manages printing on Linux, accessible primarily via a
web interface at [Link] Key basics involve configuring /etc/cups/[Link] for
network access (listening on port 631), managing printers via the web interface or command line,
enabling printer sharing, and using PPD files or IPP Everywhere for driverless printing.
Web Interface & Access: Access the admin panel at [Link] Remote access
requires editing [Link] to change Listen localhost:631 to Port 631 and allowing IP
ranges in the <Location> blocks.
Essential Files:
Adding Printers: Use the "Administration" tab in the web interface, which prompts for
administrative user credentials (system user with sudo privileges).
Network Sharing: Enable "Share printers connected to this system" in the web interface.
This requires enabling the Avahi daemon (mDNS/Bonjour) for automatic printer
discovery on the network.
Drivers & PPD: CUPS often automatically detects drivers. If not, you may need to select
a vendor/model or upload a .ppd file. IPP Everywhere is recommended for modern,
driverless printing.
Common Commands
File transfer protocol (FTP) is an Internet tool provided by TCP/IP. It helps to transfer files from
one computer to another by providing access to directories or folders on remote computers and
allows software, data and text files to be transferred between different kinds of computers.
It shields users from system variations (operating system, directory structures, file
structures, etc.)
Applications of FTP
Business File Sharing: Used by large enterprises to share files between employees
across locations.
Backup & Recovery: IT companies use FTP to maintain disaster recovery backup sites.
Financial Sector: For secure transmission of sensitive documents between institutions
and regulatory authorities.
Collaboration: Employees use FTP to share files and project data with co-workers.
FTP Client: A program that runs on the user’s computer, enabling communication with
an FTP server. It provides commands to connect, browse and transfer files.
FTP Server: A system that hosts the files and directories, waiting for requests from
clients.
Commands
get the filename(retrieve the file from the directories get server)
In an Active FTP connection, the client establishes the command channel and the server
establishes the data channel.
When the client requests the data over the connection the server initiates the transfer of
the data to the client.
It is not the default connection because it may cause problems if there is a firewall in
between the client and the server.
n a Passive FTP connection, the client establishes both the data channel as well as the
command channel.
When the client requests the data over the connection, the server sends a random port
number to the client, as soon as the client receives this port number it establishes the data
channel.
It is the default connection, as it works better even if the client is protected by the
firewall.
Anonymous FTP
Some servers provide anonymous FTP, where files are available for public access without
authentication.
Access is limited: users can download files but not browse directories or make
modifications.
1. Command Channel: Used for transmitting commands (like login, navigation and file
requests). Operates over Port 21.
2. Data Channel: Used for transferring the actual data/files. Operates over Port 20.
Detail Steps of FTP
When a file transfer is requested, the server opens a new data connection to the
client.
After transferring a file, the data connection closes (but the control connection
remains open).
Transmission Mode
1. Stream Mode: (Default) Data is sent as a continuous stream of bytes. TCP handles
fragmentation. Connection closes automatically at the end of transmission.
2. Block Mode: Data is sent in blocks, each with a 3-byte header describing the block.
Useful for structured data.
3. Compressed Mode: Large files are compressed before transfer to save bandwidth
and speed up transmission.
FTP Commands
Why FTP?
While other protocols like HTTP can also transfer files, FTP provides a more specialized,
reliable and standardized way to handle file exchanges between heterogeneous systems.
Binary (image) files (default for non-text files like executables, images, etc.).
o Control Channel (Port 21): Handles commands and replies (e.g., user login,
commands to list files).
o Data Channel (Port 20): Used for the actual file data transfer.
TCP-Based Reliability: Built on TCP, ensuring that data is transmitted reliably without
errors.
Operational Modes:
o Active Mode: The client initiates the control connection, but the server initiates
the data connection.
o Passive Mode (PASV): The client initiates both the control and data connections,
which is better for navigating firewalls.
Transfer Modes: Supports different modes to handle data: Stream (continuous), Block
(divided), and Compressed.
Key Operations
FTP Troubleshooting
Troubleshoot FTP issues by verifying credentials, switching to Passive Mode, and checking
firewall settings. Common fixes include ensuring the correct host, username, and password,
setting port 21 (or 990 for implicit SSL), and allowing passive port ranges (e.g., 40000–50000)
through firewalls. If issues persist, try a different FTP client like FileZilla.
Verify Credentials & Host: Confirm the hostname, username, password, and port
(typically 21 for FTP or 22 for SFTP) are correct and lack extra spaces.
Use Passive Mode: Switch to passive mode in your client to resolve data connection
failures caused by firewalls or NAT.
Firewall/Network Check: If you can connect but not browse/transfer files, the data
channel is likely blocked. Ensure your firewall allows FTP passive ports.
Test with Another Client: Use a tool like FileZilla to rule out issues with your specific
FTP application.
Check Server Logs: Review FTP server job logs for specific error codes.
Handle "Zero-Byte" Files: If files appear as 0KB, it indicates a failed transfer, often
caused by blocked data channels.
Restart/Reset Network: If all else fails, a network reset may be required, as shown in
this video for Windows 11.
IP Blocked: Excessive failed attempts may cause the server to block your IP.
Mail Server: SMTP, POP and IMAP principles- SMTP Relaying Principles-Mail Domain
Administration- Basic Mail Server Configuration (Sendmail, postfix, qmail, exim..)-SPAM
control and Filtering-Troubleshooting
SMTP (Simple Mail Transfer Protocol) sends emails from client to server and between
servers. POP3 (Post Office Protocol) downloads messages to one device and usually deletes
them from the server. IMAP (Internet Message Access Protocol) syncs emails across multiple
devices, keeping them on the server for access anywhere
SMTP (Sending): Operates as a "push" protocol, transferring mail from the sender's mail
client to the recipient's mail server, typically on port 25, 465, or 587.
Usage: Use IMAP for accessing email on multiple devices (phone, desktop).
Use POP3 if you only use one device and want to archive emails locally.
Storage: IMAP requires more server storage; POP3 frees up server space.
IMAP is best for accessing emails on multiple devices while keeping them stored on the
server.
POP3 is better for those who want to download emails to a single device and free up
server space.
SMTP is used for sending emails and works alongside IMAP or POP3 for complete
email functionality.
SMTP (Simple Mail Transfer Protocol) handles the sending of emails. It ensures that messages
are relayed from the sender’s device to the recipient’s mail server. It is text based protocol. This
means that the communication between the client (sender's email program) and the server
(sender's outgoing mail server or recipient's incoming mail server) is carried out using plain
text commands and responses.
You Hit “Send”: When you write an email and click “send,” your email app (like Gmail
or Outlook) connects to an SMTP server (your email provider’s “mail delivery
person”).
Checking the Sender: The SMTP server checks if you’re allowed to send emails (like
verifying your username/password).
Finding the Recipient’s Mailbox: The server looks at the recipient’s email address
(e.g., friend@[Link]) and splits it into two parts:
o Username: “friend”
o Domain: “[Link]”
It then asks the internet’s “address book” (DNS) to find the correct mail server
for “[Link].”
Delivering the Email: Your SMTP server sends the email to the recipient’s mail server
(like handing a letter to another post office). If their server is busy, yours will try again
later.
Storing the Email: The recipient’s server stores the email in their inbox. When they
check their email, their app (using protocols like POP3 or IMAP) fetches it.
SMTP Advantages:
SMTP Disadvantages:
POP3 (Post Office Protocol 3) downloads emails to a single device and removes them from the
server by default. It works on TCP port number 110. It is a simple protocol to download the
email. we can read email after download only.
POP3 (Post Office Protocol version 3) is like a digital mailbox for receiving emails. It lets you
download emails from a server to your device (like your computer or phone). Here’s how it
works step-by-step:
You Open Your Email App: When you open your email app (like Gmail or Outlook)
and click “Check Email,” it connects to the POP3 server (your email provider’s “mail
storage”).
Logging In: Your email app sends your username and password to the POP3 server to
prove you’re allowed to access the emails.
Downloading Emails: Once logged in, the POP3 server sends all the emails stored on it
to your device. By default, POP3 downloads the emails and removes them from the
server (like taking letters out of a mailbox).
Storing Emails Locally: The emails are saved on your device (computer, phone, etc.).
This means you can read them even without an internet connection.
Some email apps let you choose to keep a copy of emails on the server after downloading
them. This way, you can access them from other devices too.
Downloads emails locally and deletes them from the server (default behavior).
POP3 Advantages:
IMAP (Internet Message Access Protocol) is designed to access and manage emails directly on
the mail server. It keeps messages on the server, synchronizing changes across all devices.
IMAP (Internet Message Access Protocol) is like a cloud-based email system that lets you access
your emails from multiple devices (like your phone, laptop, or tablet). Unlike POP3, which
downloads emails to one device, IMAP keeps your emails on the server and syncs them across
all your devices. Here’s how it works step-by-step:
You Open Your Email App: When you open your email app (like Gmail, Outlook,
or Apple Mail) and click “Check Email,” it connects to the IMAP server (your email
provider’s “mail storage”).
Logging In: Your email app sends your username and password to the IMAP server to
prove you’re allowed to access the emails.
Syncing Emails: Instead of downloading all the emails to your device, IMAP only syncs
the email headers (subject, sender, date, etc.) or a preview of the emails. This makes it
faster to load your inbox.
Reading and Organizing Emails: When you open an email, IMAP downloads it from
the server so you can read it. If you organize your emails (e.g., move them to folders,
mark them as read, or delete them), these changes are synced back to the server. This
means all your devices stay up-to-date.
Emails Stay on the Server: IMAP keeps all your emails on the server unless you
manually delete them. This allows you to access your emails from any device, anytime,
as long as you’re connected to the internet.
IMAP Disadvantages:
Choosing the right email protocol—SMTP, POP3, or IMAP—depends on how emails need to be
sent, stored, and accessed. SMTP is essential for sending emails, while POP3 is suited for
downloading messages to a single device, and IMAP provides flexible, multi-device access with
server-side storage.
Understanding these differences helps in configuring email settings for better security,
accessibility, and efficiency. Whether setting up a personal inbox or managing business email
systems, selecting the appropriate protocol ensures smooth and reliable email communication.
Authentication & Security: Before relaying, the server must authenticate the sender to
prevent unauthorized use (open relay), typically using SSL/TLS for encryption.
Routing via DNS: The relay uses Domain Name Service (DNS) to locate the recipient's
Mail Exchange (MX) records to direct the message to the correct destination server.
Improved Deliverability: SMTP relay services manage sender reputation, handle IP
warm-ups, and provide detailed reporting, which increases the likelihood of reaching the
inbox, particularly for bulk or transactional messages.
Handling "Hops": Emails may pass through multiple intermediate servers (relays) to
reach their final destination.
Recipient Server: Receives the final message via Mail Delivery Agent (MDA).
Devices/Apps: Systems that cannot authenticate directly with standard mail servers, such
as scanners or printers.
Security Considerations:
Avoiding Open Relays: A misconfigured server that allows anyone to send mail, often
exploited by spammers.
Domain Verification & DNS: To use a custom domain, you must prove ownership via
TXT records and configure MX (Mail Exchange) records to route email correctly.
Authentication & Security (Deliverability):
o DMARC: Uses SPF and DKIM to provide instructions on how to handle failed
emails.
Platform-Specific Tools:
o Google Workspace: Managed through the Admin console under Account >
Domains.
o Microsoft 365: Managed via the Admin center for user, device, and security
settings.
o Zoho Mail: Uses an Admin Console for policy, role, and integration
management.
Security & Compliance: Blocking spam, managing user access, and enforcing security
policies.
Adding/Removing domains
Installation:
o myorigin = $mydomain (Uses the domain name as the origin for locally posted
mail)
SPF Record: Helps prevent spoofing by specifying authorized senders for your domain.
[Link]. IN TXT "v=spf1 mx a ~all"
Spam Control
Effective spam control requires a combination of automated filters, user awareness, and
protective habits. Key actions include enabling built-in AI filters in email/phone apps, reporting
junk mail to train algorithms, using disposable email addresses for sign-ups, and hiding your
email address from public forums to avoid bot harvesting.
Email Protection:
o Utilize Filters: Use built-in tools like Gmail, Yahoo, or Outlook filters, and mark
unwanted messages as "Spam" or "Junk" to improve AI detection.
o Hide Address: Avoid posting your email address publicly; use obscured formats
like "name (at) email (dot) com".
Filtering
Spam control and filtering systems scan incoming emails for junk, malware, and
phishing attempts, protecting users by blocking, quarantining, or flagging
malicious messages. They use techniques like Bayesian filtering (learning user
preferences), content analysis (keywords), and reputation checks (IP blocklists) to
automatically filter unwanted content.
Key Spam Filtering Techniques & Methods
Content/Phrase Filtering: Scans the email body for common spam indicators like
"win," "money," or excessive capital letters.
Bayesian Filtering: A machine learning approach that adapts to user behavior, becoming
more accurate over time by analyzing which emails a user marks as spam.
Header Analysis: Examines email metadata, such as source IP, routing info, and
recipient fields (e.g., checking if the "To" field is empty or suspicious).
Authentication Checks: Verifies sender identity using protocols like SPF (Sender Policy
Framework), DKIM (DomainKeys Identified Mail), and DMARC (Domain-based
Message Authentication, Reporting, and Conformance) to prevent spoofing.
Client-Side Filters: Built into email providers like Gmail or Outlook, which use user
feedback to train filters.
Rule-based Systems: Admins create specific rules, such as blocking all emails from a
specific country or containing certain attachments.
Use Proper Content: Avoid excessive capitalization, shady links, and "spammy"
keywords.
Maintain List Quality: Regularly clean subscriber lists to remove inactive or non-
existent addresses.