Samba – A short guide for sharing files and printers
Introduction
Samba is a service in Unix like operating systems which can be used to share folders across a Windows Network. Samba is a standard service among almost all the Linux distributions.Samba can perform the following operations.
- Act as file server among Windows and Linux machines
- Act as a printer sharing service
- Act as a domain controller for a Windows network
- Act as a client under a Windows domain
Details
Samba Port No | 445 | ||||||
Folders related to Samba | /etc/samba/usr/lib/samba/usr/share/doc/samba-x.x.x/usr/log/samba | ||||||
Samba Configuration file | /etc/samba/smb.conf | ||||||
Starting, stopping and restarting Samba server | /etc/init.d/smb {start | stop | restart} (Red hat, Debian,SUSE) /etc/init.d/samba {start | stop | restart} (Ubuntu) |
||||||
File-system | CIFS
|
||||||
GUI Configuration tool | System-config-samba ( Red hat, Ubuntu) | ||||||
Web Configuration tool | SWAT
|
Installation
Samba can be installed using the following commands.
For installing Samba on a Ubuntu or Debian machine, use the following command:
$ sudo apt-get install samba
For installing Samba on a Fedora or any other Redhat based machine, use the following command:
$ yum install samba
If you want to install Samba from a source package, you can download it from the following link:
http://samba.org/samba/download/
Installing system-config-samba
system-config-samba is a GUI tool which is used to configure Samba server in a Linux machine with GUI. You can install it by using the appropriate commands below.
$ yum install system-config-samba (for Redhat based)
$ sudo apt-get install system-config-samba (for Debian based)
SWAT
SWAT is web based configuration tool which helps to configure the Samba server from a remote location. It is often used to configure complex smb.conf files. SWAT uses port no 901 to access the Samba server.
Installation
SWAT can be installed on a Redhat based OS using the following command:
$ yum install samba-swat
For a Debian based system the command would be as follows:
$ sudo apt-get install swat
Configuration of Samba using SWAT
Open a browser in a remote or local machine and enter the following address in the address bar
http://<ip-address of the samba server>:901
Now you can browse through the page to configure various options such as adding shares and adding printers.
User Management in Samba
Using command line
For authentication, Samba uses a separate set of users that differ from the Linux users. Hence we need to create Samba users for accessing the shares form a Samba server.
To create a Samba user the following command can be used:
$ smbpasswd -a <username>
To delete a Samba user you can use the following command
$ smbpasswd -x <username>
Adding Samba users using system-config-samba
Use the following steps to add users
You can find the screenshots below
Sharing Folders
Sharing folders using command line
The configuration file for Samba is /etc/samba/smb.conf.
For sharing a folder in Samba you can append the following lines to the file.
[<share-name>] path =<share-path> Browseable = yes Guest ok = yes read only = no Valid users = <user1>,<user2>
Restart the Samba service by using the following command:
$ sudo /etc/init.d/samba restart
Sharing folders using system-config-samba
The sharing can also be done using the GUI toot. You can share the folders using the following procedure:
You can find the screenshots below.
Accessing the Samba share from a Windows Client
Accessing the Samba share directly
If you want to browse through the network
Goto Start Menu -> Computer, A window will open, Click on Network. It shows all the network computers, including your Samba server, connected to your PC. Now you can browse through the network.
To mount the share every time Windows boots, use the following steps:
Accessing the Samba share from a Linux machine with Gnome
Accessing the Samba share directly
You can view the screenshots below
If you want to browse through the network
To mount the share using Command line interface
Use the following command:
$ sudo mount -t cifs /<ip-address>/<share-name>/ /<mount-point> -o user=<username>
To mount the share at every boot
Add the following line to the /etc/fstab file
//<ip-address>/<share-name> /<mount-point> cifs user=<username>,password=<password> 0 0
Sharing printers
Sharing through command line
[ printers] comment = All Printers path = /var/spool/samba browseable = yes printable = yes
Restart the Samba service by using the following command:
$ sudo /etc/init.d/samba restart
Configuring the shared printer on a Windows Client:
Configuring the shared printer on a Linux Client with Gnome:
Logging in Samba
Logs related to Samba can be found in the folder /var/log/samba. When we try to access the Samba share from another machine it creates a new file with the file name in the following format.
/var/log/samba/log.<hostname>
Associated services
nmbd
nmbd is a NetBIOS name server which is used to resolve NetBIOS names to IP addresses. It is a part of the Samba Suite and in many of the distros, nmbd daemon is automatically started when samba daemon is started.
nmbd can be started manually using the command:
$ service nmb start ( For Redhat based machines)
$ /etc/init.d/nmbd start (For Ubuntu machines)
Some useful commands related to Samba
findsmb
findsmd can be used to find the machines in the network which respond to smb queries.
testparm
testparm command can be used to test the Samba configuration in the server.
smbtree
This command can be used to list all the Samba and Windows file servers in the network.
very nice tutorial, i was just hang on how to configure samba for both Linux and windows environments and this post help very much. thanks.
imran
May 1, 2011 at 6:01 pm
[…] https://cssoss.wordpress.com/2010/05/25/samba-sharing/ […]
File Sharing Menggunakan Samba « Administrasi Sistem
April 3, 2012 at 3:26 pm