Samba Add a User

by nixcraft on June 23, 2006 · 5 comments

I am using Fedora Linux and I would like to add a user called joe to Samba. How do I add a user SMB share?

The procedure is as follows to add a user to samba server:

[a] First add Linux/UNIX user using useradd/adduser command.

[b] Then use same user name to add to Samba share using smbpasswd command.

Step # 1: Add a user joe to UNIX/Linux system

adduser command adds user to the system according to command line options and configuration information in /etc/adduser.conf. They are friendlier front ends to the low level tools like useradd.

Type any one of the following command:
# useradd joe
# passwd joe

OR
adduser joe

Step # 2: Add a user to samba

Now user joe has account on Linux/UNIX box. Use smbpasswd command to specifies that the username following should be added to the local smbpasswd file:
# smbpasswd -a joe

Step # 3: Add a user to a Samab share

By default user gets access to /home/joe from windows system. Let us say you want to give joe access to /data/accounts (make sure directory /data/accounts exists) directory. Open /etc/samba/smb.conf file and add/modify share called [accounts]:

[accounts]
comment = Accounts data directory
path = /data/accounts
valid users = vivek raj joe
public = no
writable = yes

Save the file.

Step #4: Restart the samba

# service smb restart
OR
# /etc/init.d/smb reload

See also:

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 5 comments… read them below or add one }

1 Juan June 10, 2010

Good info; worked as expected under CentOS 5.5
Thanks!

Reply

2 Vimo February 3, 2011

Dear Nixcraft,
Would you pls tell me how to do this without prompting win users for a password? I have been banging my head on wall over this Gentleman. Following is my smb.conf.
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
security = share
passdb backend = tdbsam
load printers = yes
cups options = raw
[homes]
comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes

[ux_share]
comment = ux_share
writable = yes
path = /home/ux_share/share
guest ok = yes
browseable = yes

I have added a user called ux_share in the system and created the /home/ux_share/share with the right permission. And created the smbuser ux_share too. Now when I try to access the share from a winbox it prompts for the passw. Please help out Nixcraft. This share is likely to access by several winusers and i have no idea about thier workgroup names whatsoever. This is just a simple share im trying to publish just like an annonymous vsftpd account.

Regards
V

Reply

3 Karthigayan March 31, 2011

Good work

Reply

4 manoj October 27, 2011

please reply ,
sir/madam

q) what are the steps to be followed to share a folder in Ubuntu and access it from different machine in the network for different clients (eg ,root ,admin ,student..)

thanking u …

Reply

5 yubaraj January 19, 2012

Samba permission problem

/home can’t be accessed from windows client for samba.
/tmp can be accessed but /home can’t be accessed.

Any solution

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 10 + 13 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: