•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the *nix Hardware Configuration section within the Tech Talk category of DaniWeb, a massive community of 374,031 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,860 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our *nix Hardware Configuration advertiser: Lunarpages Linux Web Hosting
Views: 89572 | Replies: 15
![]() |
| |
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,873
Reputation:
Rep Power: 32
Solved Threads: 109
What's Samba?
Samba allows linux computers to share files and printers across a network connection. By using its SMB protocol, your linux box can appear in Windows Network Neighborhood or My Network Places just like any other windows machine. You can share files this way, as well as printers. By using samba on my home network, for example, my Windows machines have access to a printer directly hooked up to my Linux box, and my Linux box has access to a printer directly hooked up to one of my Windows machines. In addition, everyone can access everyone else's shared files. You can see how samba can be very useful if you have a network of both Windows as well as Linux machines.
Samba configurations are slightly different depending on the distribution you're using. Therefore, this tutorial explains how it's done on a RedHat Linux machine, as this is my distro of choice, and the only one I've ever installed samba on. The following method has been used by me on RedHat 7.2, 7.3, and 8.
Installing Samba
The first step to configuring samba is, obviously, to make sure that it's installed. In most cases, this will already be the case. It is often a good idea to install the samba daemon package with the RedHat installation.
You can test to see if samba is installed by typing rpm -q samba in a terminal. This performs a query on the samba package. If installed, it will indicate the version. If not, it will indicate "package not installed".
If samba is not currently installed, there are a multitude of places to get it. The RPM package is available on the RedHat CDs, on the RedHat network, or straight from www.samba.org or one of the samba mirror sites. In addition, you might wish to find it at www.rpmfind.net, a nice resource for RPM packages.
Once you have the samba RPM package downloaded somewhere on your harddrive, it's time to install it. Browse to where the file is located and perform one of the following two operations:
smb.conf file
All of samba is configured in one single file, the smb.conf file. This file, located at /etc/samba/smb.conf, allows you to specify which resources on the linux machine you wish to share and who they can be accessed by.
A fresh installation of samba will include a sample smb.conf file. This file is completely commented, pointing out all of your available options, and how you can change them. However, samba is an extremely powerful tool, and most casual users have no need for 3/4 of the contents of this sample file. Therefore, I'm providing my own smb.conf file below. If you wish to just share a few folders across a small home LAN, you might be better off basing your own smb.conf file off of mine, as opposed to the long-winded sample file.
Since we're using user level security (the best option when connecting to a WinNT based machine, such as Windows 2000 or Windows XP), we need to set up samba users.
First, lets create the smbpasswd file that we defined in the smb.conf file. The best way to go about this is to create it based on your existing /etc/passwd file. In other words, samba users are created based on existing linux users:
However, this file only copies over Linux users to samba users. It doesn't copy over their passwords, as well. Therefore, use the following command to set each samba user's password:
Samba Service
Now that everything has been configured, the final step is to start the samba service. Samba runs in the background as a linux daemon. Therefore, it can be controlled by typing:
Connecting To A Samba Resource
Now that everything should be working, let's test it out. We use the samba client to connect to a samba resource. For testing purposes, we can connect to localhost.
Since you are using the samba client while already logged in as a linux user, you will only be prompted for a password. The username will be assumed to be the samba counterpart of the linux username you're currently logged in as.
If you wish, you can go to a Windows machine such as Windows XP. If you open My Network Places, and browse to your workgroup, your linux machine should be listed. When trying to access it, you should be prompted with a username and password. This can be any of the samba users you previously created. Once logged in, you should see a listing of all available resources available.
Congratulations! Samba should now successfully be set up and working on your network!
Samba allows linux computers to share files and printers across a network connection. By using its SMB protocol, your linux box can appear in Windows Network Neighborhood or My Network Places just like any other windows machine. You can share files this way, as well as printers. By using samba on my home network, for example, my Windows machines have access to a printer directly hooked up to my Linux box, and my Linux box has access to a printer directly hooked up to one of my Windows machines. In addition, everyone can access everyone else's shared files. You can see how samba can be very useful if you have a network of both Windows as well as Linux machines.
Samba configurations are slightly different depending on the distribution you're using. Therefore, this tutorial explains how it's done on a RedHat Linux machine, as this is my distro of choice, and the only one I've ever installed samba on. The following method has been used by me on RedHat 7.2, 7.3, and 8.
Installing Samba
The first step to configuring samba is, obviously, to make sure that it's installed. In most cases, this will already be the case. It is often a good idea to install the samba daemon package with the RedHat installation.
You can test to see if samba is installed by typing rpm -q samba in a terminal. This performs a query on the samba package. If installed, it will indicate the version. If not, it will indicate "package not installed".
If samba is not currently installed, there are a multitude of places to get it. The RPM package is available on the RedHat CDs, on the RedHat network, or straight from www.samba.org or one of the samba mirror sites. In addition, you might wish to find it at www.rpmfind.net, a nice resource for RPM packages.
Once you have the samba RPM package downloaded somewhere on your harddrive, it's time to install it. Browse to where the file is located and perform one of the following two operations:
if samba is not currently installed,Now that samba is installed, we can work on configuring this program.
rpm -i samba.rpm
(replace samba.rpm with the full version name of the file)
if you wish to upgrade your samba version,
rpm -U samba.rpm
smb.conf file
All of samba is configured in one single file, the smb.conf file. This file, located at /etc/samba/smb.conf, allows you to specify which resources on the linux machine you wish to share and who they can be accessed by.
A fresh installation of samba will include a sample smb.conf file. This file is completely commented, pointing out all of your available options, and how you can change them. However, samba is an extremely powerful tool, and most casual users have no need for 3/4 of the contents of this sample file. Therefore, I'm providing my own smb.conf file below. If you wish to just share a few folders across a small home LAN, you might be better off basing your own smb.conf file off of mine, as opposed to the long-winded sample file.
[global]Samba Users
workgroup = PUTIEVILLE
server string = My Lil Linux Box
hosts allow = 192.168. 127.
log file = /var/log/samba/%m.log
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
[Downloads]
comment = Downloads
path = /home/windisk/Downloads
browseable = yes
writable = yes
public = yes
read only = no
[homes]
comment = My Home Directory
browseable = yes
writable = yes
public = yes
read only = no
[printers]
path = /var/spool/samba
public = yes
guest ok = yes
printable = yes
browseable = yes
writable = yes
read only = no
Since we're using user level security (the best option when connecting to a WinNT based machine, such as Windows 2000 or Windows XP), we need to set up samba users.
First, lets create the smbpasswd file that we defined in the smb.conf file. The best way to go about this is to create it based on your existing /etc/passwd file. In other words, samba users are created based on existing linux users:
cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswdChmod 600 this file (/etc/samba/smbpasswd) so that only root has read and write permissions.
However, this file only copies over Linux users to samba users. It doesn't copy over their passwords, as well. Therefore, use the following command to set each samba user's password:
smbpasswd usernameObviously, replace username with each of your user's usernames. You will then be prompted to enter a password for this user account. I like to set my samba user's passwords the same as their linux user counterparts. However, this isn't necessary.
Samba Service
Now that everything has been configured, the final step is to start the samba service. Samba runs in the background as a linux daemon. Therefore, it can be controlled by typing:
service smb startNote that once the computer is restarted or shutdown, the samba service won't start up again the next time. I use the GUI (xwindows) program serviceconf to set up all my services to execute automatically.
service smb stop
service smb restart
Connecting To A Samba Resource
Now that everything should be working, let's test it out. We use the samba client to connect to a samba resource. For testing purposes, we can connect to localhost.
smbclient //localhost/DownloadsYou must specify the name of the computer as well as the resource you wish to connect to. In this case, I can connect to the Downloads resource because I specified this resource in my smb.conf file (note it points to /home/windisk/Downloads).
Since you are using the samba client while already logged in as a linux user, you will only be prompted for a password. The username will be assumed to be the samba counterpart of the linux username you're currently logged in as.
If you wish, you can go to a Windows machine such as Windows XP. If you open My Network Places, and browse to your workgroup, your linux machine should be listed. When trying to access it, you should be prompted with a username and password. This can be any of the samba users you previously created. Once logged in, you should see a listing of all available resources available.
Congratulations! Samba should now successfully be set up and working on your network!
Last edited by cscgal : May 25th, 2008 at 4:11 pm. Reason: Formatting
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
•
•
Join Date: Dec 2003
Location: Marin County, CA
Posts: 6,439
Reputation:
Rep Power: 18
Solved Threads: 338
Two further Samba references, although parts of them might be out of date:
O'Reilly's Using Samba
Samba/SWAT configuration help. Swat (Samba Web Administration Tool) is a popular GUI front-end for Samba configuration. Webmin, although not limited to Samba configuration, is another popular GUI config tool.
*Note: When reading documentation concerning Samba/SWAT, watch out for references to inetd. In most cases, that material applies only to older distros, as inetd is deprecated, and has been replaced by xinetd (which has an entirely different config structure).
Also, for a Linux equivalent to Windows' "Network Neighborhood/ My Network Places" network browsers, check out LinNeighborhood.
O'Reilly's Using Samba
Samba/SWAT configuration help. Swat (Samba Web Administration Tool) is a popular GUI front-end for Samba configuration. Webmin, although not limited to Samba configuration, is another popular GUI config tool.
*Note: When reading documentation concerning Samba/SWAT, watch out for references to inetd. In most cases, that material applies only to older distros, as inetd is deprecated, and has been replaced by xinetd (which has an entirely different config structure).
Also, for a Linux equivalent to Windows' "Network Neighborhood/ My Network Places" network browsers, check out LinNeighborhood.
Last edited by DMR : Dec 4th, 2003 at 10:48 pm.
•
•
Join Date: Aug 2003
Location: Jersey - You gotta problem wit dat?
Posts: 332
Reputation:
Rep Power: 7
Solved Threads: 5
chmod 777 /path/to/samba/share
provided you want everyone to have read+write access
man chmod for more info about assigning attributes to a directory/file
provided you want everyone to have read+write access
man chmod for more info about assigning attributes to a directory/file
If you spend more on coffee than on IT security, you will be hacked.
What's more, you deserve to be hacked.
-- former White House cybersecurity czar Richard Clarke
What's more, you deserve to be hacked.
-- former White House cybersecurity czar Richard Clarke
•
•
Join Date: Feb 2004
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
I used your config file but I had to change one thing to make things work on my network.
I had to add:
[global]
netbios name = yourServerName
Before that, the Server was showing up as localHost and said that I had a duplicate name on the network and I couldn't access the share.
Thanks for all the help otherwise!!!
I had to add:
[global]
netbios name = yourServerName
Before that, the Server was showing up as localHost and said that I had a duplicate name on the network and I couldn't access the share.
Thanks for all the help otherwise!!!
Hello,
IF this computer that you have SAMBA installed on is going to be part of the internet, and if this computer is the firewall, then I would strongly suggest that you firewall out the Microsoft ports, before someone tries to attach to your machine via the internet. I would also firewall out any OUTBOUND messages that SAMBA will try to make so that your computer doesn't show up on someone's Network Neighborhood.
Inside IPTABLES:
## Explicit drops of Samba ports
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 139 -j DROP
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 445 -j DROP
$IPTABLES -A udpin_packets -p UDP -s 0/0 --dport 139 -j DROP
$IPTABLES -A udpin_packets -p UDP -s 0/0 --dport 445 -j DROP
(I have a rule called tcp_packets and udpin_packets. You will have to modify that to fit your IPTABLES firewall. If you are using something else to firewall, take the port numbers and work with it)
# Rule Test to drop Microsoft packets outbound from server.
# Want to stop Samba Advertising
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 139 -j DROP
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 445 -j DROP
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 32875 -j DROP
$IPTABLES -A OUTPUT -p UDP -o $INET_IFACE --source-port 32875 -j DROP
$IPTABLES -A OUTPUT -p UDP -o $INET_IFACE --dport 137 -j DROP
If anyone needs more help with this, come find me.
Christian
IF this computer that you have SAMBA installed on is going to be part of the internet, and if this computer is the firewall, then I would strongly suggest that you firewall out the Microsoft ports, before someone tries to attach to your machine via the internet. I would also firewall out any OUTBOUND messages that SAMBA will try to make so that your computer doesn't show up on someone's Network Neighborhood.
Inside IPTABLES:
## Explicit drops of Samba ports
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 139 -j DROP
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 445 -j DROP
$IPTABLES -A udpin_packets -p UDP -s 0/0 --dport 139 -j DROP
$IPTABLES -A udpin_packets -p UDP -s 0/0 --dport 445 -j DROP
(I have a rule called tcp_packets and udpin_packets. You will have to modify that to fit your IPTABLES firewall. If you are using something else to firewall, take the port numbers and work with it)
# Rule Test to drop Microsoft packets outbound from server.
# Want to stop Samba Advertising
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 139 -j DROP
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 445 -j DROP
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 32875 -j DROP
$IPTABLES -A OUTPUT -p UDP -o $INET_IFACE --source-port 32875 -j DROP
$IPTABLES -A OUTPUT -p UDP -o $INET_IFACE --dport 137 -j DROP
If anyone needs more help with this, come find me.
Christian
•
•
Join Date: Dec 2003
Location: Marin County, CA
Posts: 6,439
Reputation:
Rep Power: 18
Solved Threads: 338
HoWS,
We ask that members who have a question start their own thread and post their question in that thread. In that light, I've split your post here into its own thread in the main Linux forum; you can find it here:
http://www.daniweb.com/techtalkforum...ead.php?t=7934
We ask that members who have a question start their own thread and post their question in that thread. In that light, I've split your post here into its own thread in the main Linux forum; you can find it here:
http://www.daniweb.com/techtalkforum...ead.php?t=7934
"May the Wombat of Happiness snuffle through your underbrush."
- Ancient Aborigine blessing
Please do not contact me by email or PM for help. We're all volunteers here, and only have so much free time to dedicate to our efforts.
However, if I've been working on a thread with you already, and seem to have "forgotten" your thread, please do send me a message. I try not to let things slip through the cracks, but it does happen sometimes.
- Ancient Aborigine blessing
Please do not contact me by email or PM for help. We're all volunteers here, and only have so much free time to dedicate to our efforts.
However, if I've been working on a thread with you already, and seem to have "forgotten" your thread, please do send me a message. I try not to let things slip through the cracks, but it does happen sometimes.
•
•
Join Date: Dec 2003
Location: Marin County, CA
Posts: 6,439
Reputation:
Rep Power: 18
Solved Threads: 338
Cr4nberry,
For the reason given in my previous post above, I've split your post into its own thread in the main Linux forum. You can find it here:
http://www.daniweb.com/techtalkforums/thread9598.html
For the reason given in my previous post above, I've split your post into its own thread in the main Linux forum. You can find it here:
http://www.daniweb.com/techtalkforums/thread9598.html
"May the Wombat of Happiness snuffle through your underbrush."
- Ancient Aborigine blessing
Please do not contact me by email or PM for help. We're all volunteers here, and only have so much free time to dedicate to our efforts.
However, if I've been working on a thread with you already, and seem to have "forgotten" your thread, please do send me a message. I try not to let things slip through the cracks, but it does happen sometimes.
- Ancient Aborigine blessing
Please do not contact me by email or PM for help. We're all volunteers here, and only have so much free time to dedicate to our efforts.
However, if I've been working on a thread with you already, and seem to have "forgotten" your thread, please do send me a message. I try not to let things slip through the cracks, but it does happen sometimes.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb *nix Hardware Configuration Marketplace
•
•
•
•
amd apple bbc cellphone chips computer core data debian dell development enterprise fedora free games gentoo gpl graphics hardware ibm install intel kernel laptop linux microsoft mobile news novell open open source operating os patents peripherals red hat security server sony source storage system technology tv ubuntu unix via vista web windows
- Cr4nberry: How to Configure Samba on RedHat Linux (*nix Software)
- How to Configure Samba on RedHat Linux (*nix Software)
Other Threads in the *nix Hardware Configuration Forum
- Previous Thread: Problems with drivers Radeon X1650xt and Ubuntu
- Next Thread: Networking Issues -- CentOS 3 + VMWare + CentOS4 VM



Hybrid Mode