Linux创建用户如何指定shell,有啥权限

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux创建用户如何指定shell,有啥权限相关的知识,希望对你有一定的参考价值。

用法如下示useradd
username
-s
/bin/楼主想指定的shell例如useradd
username
-s
/bin/bash注:/bin/false,如果指定该参数,那么该用户就无法登录系统(该用户无shell)。-s
/bin/bash
或者
-s
/bin/csh用户通过shell
与计算机沟通bash

csh
是两个类型的shell.指定不同的shell
用户可以使用的命令有些就不一样简单的说就是选择一种语言供用户使用,每种语言对应的命令有些区别,默认bash也可以指定
参考技术A -s
后面填写此用户登录后使用的shell种类的路径,shell在/bin目录下一般有/bin/sh

/bin/bash

/bin/ksh
、/bin/tcsh、/bin/zsh

权限这个东西跟shell没有关系,shell只是用户与系统沟通的接口,各种不同的shell只是命令语法不用,语法不同而已。

linux 新建用户和权限分配

1.创建新用户:testuser

命令:#useradd 选项 用户名

选项:

-c comment 指定一段注释性描述。

-d 目录 指定用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。

-g 用户组 指定用户所属的用户组。

-G 用户组,用户组 指定用户所属的附加组。

-s Shell文件 指定用户的登录Shell。

-u 用户号 指定用户的用户号,如果同时有-o选项,则可以重复使用其他用户的标识号。

示例:

  [[email protected] /]#  useradd testuser 

2.删除testuser用户

命令:#userdel 选项 用户名

选项:

  -r 它的作用是把用户的主目录一起删除。

示例:

[[email protected] /]#  userdel  testuser 

[[email protected] /]#  cd /home

[[email protected] /]#  rm -rf testuser

3.修改用户

命令:#usermod 选项 用户名

选项:

 -c, --comment COMMENT         new value of the GECOS field

  -d, --home HOME_DIR           new home directory for the user account

  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE

  -f, --inactive INACTIVE       set password inactive after expiration  to INACTIVE

  -g, --gid GROUP               force use GROUP as new primary group

  -G, --groups GROUPS           new list of supplementary GROUPS

  -a, --append                  append the user to the supplemental GROUPS   mentioned by the -G option without removing  him/her from other groups

  -h, --help                    display this help message and exit

  -l, --login NEW_LOGIN         new value of the login name

  -L, --lock                    lock the user account

  -m, --move-home               move contents of the home directory to the   new location (use only with -d)

  -o, --non-unique              allow using duplicate (non-unique) UID

  -p, --password PASSWORD       use encrypted password for the new password

  -s, --shell SHELL             new login shell for the user account

  -u, --uid UID                 new UID for the user account

  -U, --unlock                  unlock the user account

  -Z, --selinux-user            new SELinux user mapping for the user account

 

示例:

      //用户组改为developer。

  # usermod  –g developer sam

4.用户口令(密码)管理:

用户管理的一项重要内容是用户口令的管理。用户账号刚创建时没有口令,但是被系统锁定,无法使用,必须为其指定口令后才可以使用,即使是指定空口令。

命令:#passwd 选项 用户名

选项:

-l 锁定口令,即禁用账号。

-u 口令解锁。

-d 使账号无口令。

-f 强迫用户下次登录时修改口令。

示例:

[[email protected] /]#  passwd sam

New password:*******

Re-enter new password:*******

 

5.添加组:

命令:#groupadd 选项 用户组

选项:

-g GID 指定新用户组的组标识号(GID)。

-o 一般与-g选项同时使用,表示新用户组的GID可以与系统已有用户组的GID相同。

示例:

  [[email protected] /]#  groupadd group1

6.删除组:

命令:#groupdel 用户组

选项:

示例:

  [[email protected] /]#  groupdel group1

7.删除组:

命令:#groupmod 选项 用户组

选项:

-g GID 为用户组指定新的组标识号。

-o 与-g选项同时使用,用户组的新GID可以与系统已有用户组的GID相同。

-n新用户组 将用户组的名字改为新名字

示例:

//此命令将组group2的标识号改为10000,组名修改为group3。

  [[email protected] /]# groupmod –g 10000 -n group3 group2

8. 新建用户的独立性 

修改目录权限,使得Linux 每个账户只能查看自己的根目录,无法查看其它账户的目录。 首先要进入Linux系统下所有用户所在的文件夹

  [[email protected] /]# cd /home/testuser 

 

//这就是说设置testuser 这个目录只有lili可以查看,Linux下的其它账户无法查看。

  [[email protected] /]#  chmod go-rw  testuser 

 

 

9.其他命令:

[[email protected] /]# cat /etc/passwd 可以查看用户的pass

[[email protected] /]# cat /etc/shadow 可以查看用户名

[[email protected] /]# cat /etc/group  可以查看 组

以上是关于Linux创建用户如何指定shell,有啥权限的主要内容,如果未能解决你的问题,请参考以下文章

Linux创建用户配置sudo权限

sudo -i和sudo -s有啥区别

Linux的用户与用户组(权限管理)

linux下创建用户和用户组

linux 新建用户和权限分配

linux ftp 添加用户及权限管理