【Ubuntu服务器】Ubuntu服务器用户添加及samba用户配置

前言

本文章描述ubuutu服务器上用户添加方式、sudo权限配置及samba用户配置

用户添加

用户添加

该操作是需要 root账户 或者 有sudo权限的普通账户 操作。
例如,添加名为test的用户。

root@anon:~# adduser test
Adding user 'test' ...
Adding new group 'test' (1003) ...
Adding new user 'test' (1003) with group 'test' ...
Creating home directory '/home/test' ...
Copy files from '/etc/skel' ...
Entry new UNIX password:
Retry new UNIX password:
passwd: password updated successfully
Changing the user information for test
Entry the new value, or press ENTER for the defauly
    Full Name []:
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n] y
root@anon:~# 

查看用户

root@anon:~# cat /etc/group
root:x:0:
test:x:1003:
root@anon:~# 

删除用户

root@anon:~# userdel test
root@anon:~# 

并删除用户文件夹

root@anon:/home# rm -rf test
root@anon:/home# 

普通用户添加sudo权限

Linux默认是没有将用户添加到sudoers列表中的,需要root手动将账户添加到sudoers列表中,才能让普通账户执行sudo命令。
如果用户不在sudoers列表中,将会得到以下提示。

test@anon:~$ sudo vi /etc/sudoers
linux is not in the sudoers file.  This incident will be reported.

所以,该操作是需要 root账户 或者 有sudo权限的普通账户 操作。
编辑 /etc/sudoers 文件,将 test ALL=(ALL:ALL) ALL 添加到文件中,即可为test用户添加sudo权限。

root@anon:~# vi /etc/sudoers
# User privilege specification
root	ALL=(ALL:ALL) ALL
test ALL=(ALL:ALL) ALL

samba用户配置

该操作是需要 root账户 或者 有sudo权限的普通账户 操作。
修改samba配置文件:将test用户的相关配置写入/etc/samba/smb.conf文件中

root@anon:~# vi /etc/samba/smb.conf
[test]
   comment = Share for test
   path = /home/test
   available = yes
   public = yes
   writable = yes
   browseable = yes
   valid users = test
   create mask = 0644
   directory mask = 0755
root@anon:~# 

添加samba用户

root@anon:~# smbpasswd -a test
root@anon:~# 

重启samba服务

root@anon:~# /etc/init.d/samba restart
root@anon:~# 

此时windows可以通过 映射网络驱动器 通过用户test,连接ubuntu服务器。
映射网络驱动器
在windows下,查看用户test的文件夹及文件。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值