---
title: "linux 添加用户、权限"
author: "zlr"
date: "2016-11-24T11:26:29Z"
tags: []
categories: ["操作系统"]
slug: "linux"
draft: false
lastmod: "2020-12-17T14:24:58Z"
id: 2340760
url: "https://zlr.iteye.com/blog/2340760"
---

http://www.cnblogs.com/daizhuacai/archive/2013/01/17/2865132.html

adduser abc

passwd abc  //为刚创建的用户设置密码

cd /home/abc
mkdir .ssh

ssh-keygen -t rsa
中途输入：/home/abc/.ssh/id_rsa

cat id_rsa.pub >> authorized_keys

重要：
chown -R abc:abc /home/abc
chmod 700 .ssh
chmod 600 .ssh/authorized_keys

下载id_rsa 到本地，xshell直接使用
或者通过putty其他方式转成ppk，

import key
export private key
https://blog.csdn.net/weixin_44208042/article/details/100661281


===============setfacl/getfacl 管理权限

setfacl -m u:front1:--x /
setfacl -m u:front1:--x /psd
setfacl -m u:front1:--x /psd/abc
setfacl -R -m u:front1:rwx /psd/abc/templates/


只能访问 /psd/imachika/templates/ 目录下的文件夹


================

常见
https://www.jianshu.com/p/2400203bf555

把普通用户增加到 sudo 组 通常使用两种方法:

第一种： 修改 /etc/sudoers 文件

...

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL   //增加属于自己的用户名
#joe ALL=(ALL) NOPASSWD: ALL
..



**第二种：直接执行命令添加用户到 sudo **

usermod -a -G sudo steven    //注意改成你自己的用户名