设为首页 加入收藏

TOP

linux命令练习:通过修改用户文档手动添加用户
2019-05-04 00:45:53 】 浏览:115
Tags:linux 命令 练习 通过 修改 用户 文档 手动 添加

手动添加用户hive,基本组为hive(5000),附加组为mygroup

1、vim /etc/group 手动在组配置文档中添加hive组信息,并把mygroup作为hive用户的附加组

mygroup:x:5001:hive 把hive添加到mygroup组信息后面,作为附加组

hive:x:5000: 添加hive组信息

2、vim /etc/gshadow 手动在组密码配置文档中添加hive组信息

hive:!:: 添加hive组密码信息

3、vim /etc/passwd 手动在用户配置文档中添加hive用户信息

hive:x:5000:5000:HIVE:/home/hive:/bin/bash 添加hive用户信息

4、vim /etc/shadow 手动在用户密码配置文档中添加hive用户信息

hive:!!:17088:0:99999:7::: 此处17088的计算方法下面有说明

附:如何把最后一次密码修改日期变成天数方法如下

[root@xuelinux ~]# date +%s 先把当天日期以秒数显示出来

1476431406

[root@xuelinux ~]# bc 计算器命令

bc 1.06.95

Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.

This is free software with ABSOLUTELY NO WARRANTY.

For details type `warranty'.

1476431406/86400 用当天的日期的秒数除以一天的秒数,一天24*3600秒=86400秒

17088 计算出当天日期距离1970年的天数为17088

5、cp -R /etc/skel /home/hive 建立hive用户的家目录

[root@xuelinux test]# cp -R /etc/skel /home/hive

[root@xuelinux test]# ls -l /home

drwx------. 3 donggen donggen 4096 9月 13 23:26 donggen

drwxr-xr-x. 3 root root 4096 10月 14 15:56 hive hive家目录已经建好

6、chown -R hive.hive /home/hive 把hive家目录及其内的内容的用户和组都修改为hive

[root@xuelinux test]# chown -R hive.hive /home/hive

[root@xuelinux test]# ls -la /home/hive

drwxr-xr-x. 3 hive hive 4096 10月 14 15:56 .

drwxr-xr-x. 7 root root 4096 10月 14 15:56 ..

-rw-r--r--. 1 hive hive 18 10月 14 15:56 .bash_logout

-rw-r--r--. 1 hive hive 176 10月 14 15:56 .bash_profile

-rw-r--r--. 1 hive hive 124 10月 14 15:56 .bashrc

drwxr-xr-x. 2 hive hive 4096 10月 14 15:56 .gnome2

7、chmod -R go= /home/hive 把hive家目录的组和其他人的权限设置为空

[root@xuelinux test]# chmod -R go= /home/hive

[root@xuelinux test]# ls -al /home/hive

drwx------. 3 hive hive 4096 10月 14 15:56 .

drwxr-xr-x. 7 root root 4096 10月 14 15:56 ..

-rw-------. 1 hive hive 18 10月 14 15:56 .bash_logout

-rw-------. 1 hive hive 176 10月 14 15:56 .bash_profile

-rw-------. 1 hive hive 124 10月 14 15:56 .bashrc

drwx------. 2 hive hive 4096 10月 14 15:56 .gnome2

至此hive用户就手动添加成功,但是此时还无法通过终端登录hive用户,需给hive设置密码

可以通过passwd设置,这里说下如何通过手动添加密码到shadow文档中。

8、手动添加hive密码信息到shadow用户密码配置文档中

先通过openssl passwd -1 -salt 先通过openssl命令生成密码加密字符串-1此处为数字1

openss1 passwd -l -salt

[root@xuelinux test]# openssl passwd -1 -salt '12345678'

Password:

$1$12345678$0ME5N6oDyoEAwUp7b5UDM/

[root@xuelinux test]# vim /etc/shadow

hive:$1$12345678$0ME5N6oDyoEAwUp7b5UDM/:17088:0:99999:7:::

把生成的密码加密字符串复制到用户密码配置文档中


至此完整的hive用户就手动添加成功,并能通过远程登录。













本文转自wang650108151CTO博客,原文链接:http://blog.51cto.com/woyaoxuelinux/1861960,如需转载请自行联系原作者


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇hive:Access denied for user .. 下一篇hive:Access denied for user ..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目