22 C
Jaipur
Saturday, October 31, 2020

How to Add a Samba User in Linux

Must read

toyota: Toyota to invest $500 million in KDDI to deepen ties for “connected car” – Latest News

Toyota Motor Corp and KDDI Corp said on Friday that Japan's biggest automaker would invest 52.2 billion yen ($500 million) in the mobile carrier...

This $299 laptop is one of the best Black Friday deals we’ve seen yet – but it ends tomorrow

Granted, we're only just getting started in this year's Black Friday laptop deals, but Best Buy's offerings this weekend are looking particularly sharp. One...

Can the Honor Watch ES smartwatch give a lazy person a six-pack? I found out

Many smartwatches come with a wide range of fitness modes, helping the wearer stay fit and active; however, for all the clever tech in...

This is how online shopping may ‘look like’ this holiday season, as per Adobe

Adobe has released its online shopping predictions for the 2020 holiday season. Based on Adobe Analytics data, the company analyzed over one trillion...

Samba is a free and open-source networking service that functions in a client/server networking model. It allows for file sharing across both Windows and Linux/Unix operating systems and leverages the SMB (Server Messaging Block) and the CIFS (Common Internet File system) protocols to seamlessly share resources in a network. Samba sharing is considered one of the most efficient and cost-effective way of sharing resources in a local area network – LAN.

A file share in Samba in referred to as a samba share. A samba share could be anything from a file, a directory, or even a printer. In a network setup, the client sends a request to the Samba server for a file, directory, or a shared printer. In turn, the Samba server responds to these requests by denying or granting the client access to the shared resources requested.

A new user needs to be added as a samba user in Linux to be able to access the samba share. The samba user can then connect to the Samba server using a samba password and access the shared resources. In this tutorial, we will walk you the procedure of adding a samba user

Add a user

Now let’s focus on how to add a new user to Samba. First, create a new user account just as you would in any Linux system. In this example, we will create a new user account for a user called ‘joe‘.

$ adduser joe

Next, add samba user by assigning a samba password to the new user using the ‘smbpasswd’ command as shown:

$ sudo smbpasswd -a joe

You will be prompted to provide a new samba password and later confirm it as shown in the output below

New SMB password:
Retype new SMB password:
added user joe.

Once you have created the samba user, you need to add them to the samba share by editing the samba smb.conf file which is Samba’s configuration file. Scroll and locate the samba share, in this case, ‘documents’, and append the user to the list of valid users as shown in the 4th line in the configuration block below.

[documents]
comment = Departmental documents share
path = /srv/documents
valid users = joe
public = no
writable = yes
browsable = yes

Now save the changes and exit the configuration file. For the changes to persist, restart Samba daemon as shown.

$ sudo systemctl restart smb

Add existing local user to samba

If you already have an existing user on your system, then adding the user to samba is quite straightforward. Simply use the ‘smbpasswd‘ command as shown:

$ sudo smbpasswd -a existing_user

Then modify the configuration file and add the existing user to the list of valid samba users as shown earlier.

valid users = existing_user

A point on Adding users to Samba version 4.x

From Samba version 4.x and later, Samba has the ability to run as an AD Domain Controller. You don’t need to have a standard Linux or Unix user in Linux for every Samba user that is created. To add users into Samba Active directory, use the command shown:

samba-tool user add username

Delete samba user

If you want to delete or remove a Samba user from your system, use the ‘smbpasswd‘ command with -x option followed by the username.

$ sudo smbpasswd -x joe

If you so desire, you can remove the user completely along with the home directory using the userdel command as shown:

$ sudo userdel -r joe

Conclusion

We have covered how you can add and delete a Samba user on a Linux system. As stated earlier, the Samba version 4.x now supports authentication via the Active directory unlike the earlier versions of Samba.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

toyota: Toyota to invest $500 million in KDDI to deepen ties for “connected car” – Latest News

Toyota Motor Corp and KDDI Corp said on Friday that Japan's biggest automaker would invest 52.2 billion yen ($500 million) in the mobile carrier...

This $299 laptop is one of the best Black Friday deals we’ve seen yet – but it ends tomorrow

Granted, we're only just getting started in this year's Black Friday laptop deals, but Best Buy's offerings this weekend are looking particularly sharp. One...

Can the Honor Watch ES smartwatch give a lazy person a six-pack? I found out

Many smartwatches come with a wide range of fitness modes, helping the wearer stay fit and active; however, for all the clever tech in...

This is how online shopping may ‘look like’ this holiday season, as per Adobe

Adobe has released its online shopping predictions for the 2020 holiday season. Based on Adobe Analytics data, the company analyzed over one trillion...

Advanced Copy – Add Progress Bar To cp And mv Commands In Linux

The GNU cp and GNU mv tools are used to copy and move files and directories in GNU/Linux operating system. One missing feature in these two utilities is...