Diff for "How to Create a Network Share Via Samba Via CLI (Command-line interface/Linux Terminal) - Uncomplicated, Simple and Brief Way!"


Differences between revisions 16 and 17
Revision 16 as of 2015-10-06 20:46:34
Size: 3694
Editor: 97e64b0f
Comment: removed "public = yes" line from suggested config because it has potentially unsafe security implications that aren't 100% obvious
Revision 17 as of 2024-05-05 20:26:14
Size: 726
Editor: ahasenack
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= About This Guide =
||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<BR>><<TableOfContents(2)>>||
= This page has been deprecated in favor of the Ubuntu Server Guide at https://ubuntu.com/server/docs =
Line 4: Line 3:
In this text, I teach how to create a network share via Samba using the CLI (Command-line interface/Linux Terminal) in an uncomplicated, simple and brief way targeting Windows users. Specifically about samba, we have:
Line 6: Line 5:
= Procedures =

All commands must be done as root (precede each command with 'sudo' or use 'sudo su').

      * Install Samba
            '''{{{
sudo apt-get update
sudo apt-get install samba
            }}}'''
      
      * Set a password for your user in Samba
            '''{{{
sudo smbpasswd -a <user_name>
            }}}'''
                  {{{
Note: Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you'll need to create a Samba password for yourself. This tutorial implies that you will use your own user and it does not cover situations involving other users passwords, groups, etc...
                  }}}
                  {{{
Tip1: Use the password for your own user to facilitate.
                  }}}
                  {{{
Tip2: Remember that your user must have permission to write and edit the folder you want to share.
Eg.:
sudo chown <user_name> /var/opt/blah/blahblah
sudo chown :<user_name> /var/opt/blah/blahblah
                  }}}
                  {{{
Tip3: If you're using another user than your own, it needs to exist in your system beforehand, you can create it without a shell access using the following command :
sudo useradd USERNAME --shell /bin/false

You can also hide the user on the login screen by adjusting lightdm's configuration, in /etc/lightdm/users.conf add the newly created user to the line :
hidden-users=
                  }}}
 

      * Create a directory to be shared
      '''{{{
mkdir /home/<user_name>/<folder_name>
      }}}'''
      
      * Make a safe backup copy of the original smb.conf file to your home folder, in case you make an error
      '''{{{
sudo cp /etc/samba/smb.conf ~
      }}}'''
      
      * Edit the file "/etc/samba/smb.conf"
      '''{{{
sudo nano /etc/samba/smb.conf
      }}}'''
            {{{
Once "smb.conf" has loaded, add this to the very end of the file:

[<folder_name>]
path = /home/<user_name>/<folder_name>
valid users = <user_name>
read only = no
            }}}
            {{{
Tip: There Should be in the spaces between the lines, and note que also there should be a single space both before and after each of the equal signs.
            }}}

      * Restart the samba:
      '''{{{
sudo service smbd restart
      }}}'''
      
      * Once Samba has restarted, use this command to check your smb.conf for any syntax errors
      '''{{{
testparm
      }}}'''
      * To access your network share

      '''{{{
      sudo apt-get install smbclient
      # List all shares:
      smbclient -L //<HOST_IP_OR_NAME>/<folder_name> -U <user>
      # connect:
      smbclient //<HOST_IP_OR_NAME>/<folder_name> -U <user>
      }}}'''

      To access your network share use your username (<user_name>) and password through the path "smb://<HOST_IP_OR_NAME>/<folder_name>/" (Linux users) or "\\<HOST_IP_OR_NAME>\<folder_name>\" (Windows users). Note that "<folder_name>" value is passed in "[<folder_name>]", in other words, the share name you entered in "/etc/samba/smb.conf".

            {{{
Note: The default user group of samba is "WORKGROUP".
            }}}

= Source =

 *http://www.hardcode.nl/archives_147/article_548-samba-quick-setup-on-ubuntu-1004.htm
  * Under https://ubuntu.com/server/docs/how-to:
    * How-to guides -> Networking -> Samba: file server, print server, share access controls, and more.
    * How-to guides -> Active Directory integration with winbind: preparing to join a domain, rid and autorid identity mapping backends, simple domains and forests.
  * Under https://ubuntu.com/server/docs/explanation:
    * Explanation -> Active Directory integration: choosing an identity mapping backend, what are SIDs, which idmap backends to pick under which circumstances, details about the rid and autorid backends.

This page has been deprecated in favor of the Ubuntu Server Guide at https://ubuntu.com/server/docs

Specifically about samba, we have:

  • Under https://ubuntu.com/server/docs/how-to:

    • How-to guides -> Networking -> Samba: file server, print server, share access controls, and more.

    • How-to guides -> Active Directory integration with winbind: preparing to join a domain, rid and autorid identity mapping backends, simple domains and forests.

  • Under https://ubuntu.com/server/docs/explanation:

    • Explanation -> Active Directory integration: choosing an identity mapping backend, what are SIDs, which idmap backends to pick under which circumstances, details about the rid and autorid backends.

How to Create a Network Share Via Samba Via CLI (Command-line interface/Linux Terminal) - Uncomplicated, Simple and Brief Way! (last edited 2024-05-05 20:26:14 by ahasenack)