linux samba configure

  • 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".

 

https://help.ubuntu.com/community/How%20to%20Create%20a%20Network%20Share%20Via%20Samba%20Via%20CLI%20%28Command-line%20interface/Linux%20Terminal%29%20-%20Uncomplicated%2C%20Simple%20and%20Brief%20Way%21

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值