Skip to content

Commit 9f1af72

Browse files
committed
📝 Writing docs.
1 parent f093d37 commit 9f1af72

2 files changed

Lines changed: 41 additions & 15 deletions

File tree

docs/linux/05.Linux用户管理.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,37 +138,37 @@ $ usermod -U newuser1
138138
```sh
139139
# 如果是普通用户执行 passwd 只能修改自己的密码。
140140
# 如果新建用户后,要为新用户创建密码,则用 passwd 用户名,注意要以 root 用户的权限来创建。
141-
[root@localhost ~]# passwd linuxde # 更改或创建linuxde用户的密码;
141+
$ passwd linuxde # 更改或创建linuxde用户的密码;
142142
Changing password for user linuxde.
143143
New UNIX password: # 请输入新密码;
144144
Retype new UNIX password: # 再输入一次;
145145
passwd: all authentication tokens updated successfully. # 成功;
146146

147147
# 普通用户如果想更改自己的密码,直接运行 passwd 即可,比如当前操作的用户是 linuxde。
148-
[linuxde@localhost ~]$ passwd
148+
$ passwd
149149
Changing password for user linuxde. # 更改linuxde用户的密码;
150150
(current) UNIX password: # 请输入当前密码;
151151
New UNIX password: # 请输入新密码;
152152
Retype new UNIX password: # 确认新密码;
153153
passwd: all authentication tokens updated successfully. # 更改成功;
154154

155155
# 比如我们让某个用户不能修改密码,可以用`-l`选项来锁定:
156-
[root@localhost ~]# passwd -l linuxde # 锁定用户linuxde不能更改密码;
156+
$ passwd -l linuxde # 锁定用户linuxde不能更改密码;
157157
Locking password for user linuxde.
158158
passwd: Success # 锁定成功;
159159

160-
[linuxde@localhost ~]# su linuxde # 通过su切换到linuxde用户;
161-
[linuxde@localhost ~]$ passwd # linuxde来更改密码;
160+
$ su linuxde # 通过su切换到linuxde用户;
161+
$ passwd # linuxde来更改密码;
162162
Changing password for user linuxde.
163163
Changing password for linuxde
164164
(current) UNIX password: # 输入linuxde的当前密码;
165165
passwd: Authentication token manipulation error # 失败,不能更改密码;
166166

167-
[root@localhost ~]# passwd -d linuxde # 清除linuxde用户密码;
167+
$ passwd -d linuxde # 清除linuxde用户密码;
168168
Removing password for user linuxde.
169169
passwd: Success # 清除成功;
170170

171-
[root@localhost ~]# passwd -S linuxde # 查询linuxde用户密码状态;
171+
$ passwd -S linuxde # 查询linuxde用户密码状态;
172172
Empty password. # 空密码,也就是没有密码;
173173
```
174174

@@ -182,13 +182,13 @@ Empty password. # 空密码,也就是没有密码;
182182

183183
```sh
184184
# 变更帐号为 root 并在执行 ls 指令后退出变回原使用者:
185-
su -c ls root
185+
$ su -c ls root
186186

187187
# 变更帐号为 root 并传入`-f`选项给新执行的 shell:
188-
su root -f
188+
$ su root -f
189189

190190
# 变更帐号为 test 并改变工作目录至 test 的家目录:
191-
su -test
191+
$ su -test
192192
```
193193

194194
### sudo
@@ -201,9 +201,21 @@ su -test
201201

202202
```sh
203203
# 指定用户执行命令
204-
sudo -u userb ls -l
204+
$ sudo -u userb ls -l
205205
# 列出目前的权限
206-
sudo -l
206+
$ sudo -l
207207
# 显示sudo设置
208-
sudo -L
208+
$ sudo -L
209209
```
210+
211+
#### 给普通用户授权 sudo
212+
213+
假设要给普通用户 mary 配置 sudo 权限:
214+
215+
1. `/etc/sudoers` 文件存放了 sudo 的相关用户,但是默认是没有写权限的,所以需要设为可写:`chmod u+w /etc/sudoers`
216+
2. 在该文件中添加 `mary ALL=(ALL) ALL` ,保存并退出,让 mary 具有 sudo 的所有权限
217+
3. 再将 `/etc/sudoers` 的权限恢复到默认状态:`chmod u-w /etc/sudoers`
218+
219+
#### 免密码授权 sudo
220+
221+
与给普通用户授权 sudo 类似,区别仅在于第 2 步:`mary ALL=(ALL) NOPASSWD: ALL`

docs/linux/samba使用详解.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ tags:
2727
- [1.6. 为 samba 添加防火墙规则](#16-为-samba-添加防火墙规则)
2828
- [1.7. 测试 samba 服务](#17-测试-samba-服务)
2929
- [1.8. 访问 samba 服务共享的目录](#18-访问-samba-服务共享的目录)
30-
- [2. 配置说明](#2-配置说明)
30+
- [2. 配置详解](#2-配置详解)
3131
- [2.1. samba 默认配置](#21-samba-默认配置)
3232
- [2.2. 全局参数 [global]](#22-全局参数-global)
3333
- [2.3. 共享参数 [共享名]](#23-共享参数-共享名)
3434
- [3. 常见问题](#3-常见问题)
3535
- [3.1. 你可能没有权限访问网络资源](#31-你可能没有权限访问网络资源)
36+
- [3.2. window 下对 samba 的清理操作](#32-window-下对-samba-的清理操作)
3637
- [4. 参考资料](#4-参考资料)
3738

3839
<!-- /TOC -->
@@ -132,6 +133,9 @@ Added user root.
132133

133134
根据提示输入 samba 用户的密码。当 samba 服务成功安装、启动后,通过 Windows 系统访问机器共享目录时,就要输入这里配置的用户名、密码。
134135

136+
- 查看 samba 服务器中已拥有哪些用户 - `pdbedit -L`
137+
- 删除 samba 服务中的某个用户 - `smbpasswd -x 用户名`
138+
135139
### 1.5. 启动 samba 服务
136140

137141
CentOS 6
@@ -183,7 +187,7 @@ Mac:
183187

184188
与 Windows 类似,直接在 Finder 中访问 `smb://<你的ip>/<你的共享路径>` 即可。
185189

186-
## 2. 配置说明
190+
## 2. 配置详解
187191

188192
### 2.1. samba 默认配置
189193

@@ -456,8 +460,18 @@ $ sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
456460
$ reboot
457461
```
458462

463+
### 3.2. window 下对 samba 的清理操作
464+
465+
1. windows 清除访问 samba 局域网密码缓存
466+
- 在 dos 窗口中输入 `control userpasswords2` 或者 `control keymgr.dll`,然后【高级】/【密码管理】,删掉保存的该机器密码。
467+
2. windows 清除连接的 linux 的 samba 服务缓存
468+
1. 打开 win 的命令行。
469+
2. 输入 net use,就会打印出当前缓存的连接上列表。
470+
3. 根据列表,一个个删除连接: net use 远程连接名称 /del;或者一次性全部删除:`net use * /del`
471+
459472
## 4. 参考资料
460473

461474
- http://blog.51cto.com/yuanbin/115761
462475
- https://www.jianshu.com/p/750be209a6f0
463476
- https://github.com/judasn/Linux-Tutorial/blob/master/markdown-file/Samba.md
477+
- https://blog.csdn.net/lan120576664/article/details/50396511

0 commit comments

Comments
 (0)