Setting Up a Samba Server on CentOS/RHEL for File Sharing
Hi there! I'm Dinesh, a passionate Cloud and DevOps enthusiast. I love to dive into the latest new technologies and sharing my journey through blog.
Search for a command to run...
Hi there! I'm Dinesh, a passionate Cloud and DevOps enthusiast. I love to dive into the latest new technologies and sharing my journey through blog.
No comments yet. Be the first to comment.
1. Difference between Docker and Kubernetes Docker → Builds and runs containers.Kubernetes → Orchestrates containers across multiple nodes. Key points: Docker = container runtime. Kubernetes = container orchestration tool. Kubernetes provides auto...
In this session, we learn how to monitor a Kubernetes cluster using Prometheus and Grafana.This is not just theory — there is a GitHub repository containing all installation commands and demo steps.The repo will also be enhanced later with advanced K...
1. What is a ConfigMap in Kubernetes? A ConfigMap is used to store non-sensitive configuration data that your application needs — such as: Database port Connection type Any general configuration values In normal applications (non-Kubernetes), de...
Kubernetes normally supports built-in resources like: Deployment Service Pod ConfigMap Secret Ingress These are called native resources. Sometimes companies (Istio, ArgoCD, Prometheus Operator, Kyverno, etc.) want to add new features that Kub...
1. Why Kubernetes Services Are Needed When a Pod is created in Kubernetes, it receives a dynamic IP address.If the Pod dies and restarts, its IP changes.So other Pods (like checkout → payments) cannot rely on Pod IP because it changes, creating issue...
Samba is a powerful tool that allows Linux and Windows systems to share files and printers across a network. This guide will walk you through installing and configuring a Samba server on CentOS/RHEL, setting up both public and private shared folders, and managing user access.
To install Samba, update your packages and install Samba using the following command:
sudo yum install samba -y
Once installed, start and enable the Samba service to ensure it runs on boot.
sudo systemctl restart smbd
sudo systemctl enable smbd
Create directories for public and private sharing:
mkdir public private
chmod 777 public private # Give full access to these folders
Create user accounts that will have access to the Samba shares. Use /sbin/nologin to prevent shell access:
useradd user1 -s /sbin/nologin
smbpasswd -a user1 # Set a Samba password for user1
useradd user2 -s /sbin/nologin
smbpasswd -a user2 # Set a Samba password for user2
Before modifying the Samba configuration file, create a backup of the original file:
cp /etc/samba/smb.conf /etc/samba/smb.conf.original
Open the Samba configuration file with a text editor:
sudo nano /etc/samba/smb.conf
Add the following configuration at the end of the file:
The public share is accessible to everyone and does not require authentication:
[public]
comment = Public Shared Folder
path = /public
writeable = yes
browseable = yes
create mask = 666
directory mask = 777
The private share is restricted to specific users:
[private]
comment = Private Shared Folder
path = /private
writeable = yes
public = no
valid users = user1
browseable = yes
To restrict the private folder to user1:
chown user1:root /private
After updating the configuration, restart the Samba service to apply the changes:
sudo systemctl restart smbd
If you need to add more users to Samba, use the following commands. Here, we’ll add a user named sambauser:
sudo adduser sambauser
sudo smbpasswd -a sambauser # Add the user to Samba
sudo smbpasswd -e sambauser # Enable the user in Samba
To verify the Samba shares are accessible from a Windows machine:
Open File Explorer.
Enter \\<Server_IP_Address> in the address bar and press Enter.
You should see the public and private folders (private will prompt for credentials).
You have now set up a Samba server with both public and private shared folders. This configuration enables both open and restricted access, providing flexibility for file sharing across your network.
With Samba, you can customize permissions, add more users, and expand the configuration to meet the needs of your environment. Happy sharing!