Samba Installation and Configuation on CentOS

I was told to share some files from linux to windows. But it was complicated I could have done with NFS as its better for sharing drive around the network and no doubt works awesome but I just wanted to share folder to my local doamin or say broadcast my local linux server drive to all windows or mac. So I found old and simple tool  SAMBA.

Samba  is a useful service found in most Unix and Linux system that allows you to share file and print services with another computer, particularly a Microsoft Windows client. In Ubuntu, while the Nautiilus File Manager comes with a series of connection protocols to access files from a remote server, it doesn’t turn the machine into a file server and accept connection from other PC. Samba is the one that does the job. In this tutorial, we will show you how to install and configure Samba so you can turn your Ubuntu PC into a file server.

Step One: Install Samba.
Samba is not installed by default. Open a terminal and type the following command:
sudo yum install samba –y
sudo yum install samba – y
If you get a problem installing with yum  there is Alternatively way, you can install samba from source directly using this link.

Step Two: Lets Configure Samba.
To get Samba to work the way we want it to work, we have to make some changes to its configuration file.
We need to make some changes in samba main config file to get samba work as we want.. there are lots of configuration you ll see but we ll change only some basic… Note: whatever you change there is description on them with details.
sudo vim /etc/samba/smb. conf
sudo vim / etc / samba / smb. conf
On Line 65 you will get Global Setting. Make some changes below line   [global].
workgroup = WORKGROUP
workgroup = WORKGROUP
AS I told you will find the description below like this… «# workgroup = the Windows NT domain name or workgroup name, for example, MYGROUP..»
Now you might be thinking what exactly is this, lets understand this it will allow a Group or Domain which will be configured in WORKGROUP.
Next, scroll down on-line 112 on   «Standalone Server Options»   section. Its described as security = the mode Samba runs in. This can be set to user, share (deprecated), or server (deprecated).
security = user
security = user

Continue to scroll down on-line 280 «Share Definitions» section. This is where you configure the files/folders that you want to share with others.   If you want the Home folder to be accessible, you should uncomment (remove the «;» at the front of the line) the following lines:
[homes]
comment = Home Directories
browseable = yes
valid users = %S
comment = Home Directories
browseable = yes
valid users = % S

Don’t forget to change the  browseable  value to «yes». You can also uncomment the  read only = no  line if you allow others to write to your Home folder.
The last line  valid users = %S  means that only you, or anyone with your login account, can connect to your own Home folder via Samba.

To add additional file sharing path, add the following lines to the end of the file:
[share]
comment = New Share Path
path = /path/to/share/folder
browsable = yes
guest ok = yes
read only = no
create mask = 0755
comment = New Share Path
path = / path / to / share / folder
browsable = yes
guest ok = yes
read only = no
create mask = 0755

Change the name of this share configuration and change the path to the folder you want to share.
You can change the «guest ok=yes» line to «guest ok=no» if you want the share path only available for logged in users. Now save and exit.

Step Three: Create User and password.
To add yourself to the Samba user list, you just have to type the following command:
sudo smbpasswd -a
sudo smbpasswd – a
Replace     with your username. It will then prompt you to set a password for this Samba account. Alternatively, you can also create a new user account and add this user to the Samba user list
To create a user account, use the following command:
adduser
adduser

Lets restart Samba …

/etc/init. d/smb restart
Shutting down SMB services: [FAILED]
Starting SMB services: [ OK ]
/ etc / init. d / smb restart
Shutting down SMB services:                                  [ FAILED ]
Starting SMB services:                                      [    OK    ]
/etc/init. d/nmb restart
Shutting down NMB services: [FAILED]
Starting NMB services: [ OK ]
/ etc / init. d / nmb restart
Shutting down NMB services:                                  [ FAILED ]
Starting NMB services:                                      [    OK    ]

That’s it. You should be able to connect to this shared PC,   from another   PC, Laptop, or any Desktop in same domain or workspace. Hope you all like this small post please do share your comments..

Leave a Reply

Your email address will not be published. Required fields are marked *