8.1作業

創建用戶gentoo,附加組為bin和root,默認shell為/bin/csh,注釋信息為“Gentoo Distribution”

[root@localhost wang]# useradd -G bin,root -s /bin/csh -c "Gentoo distribution" gentoo
[root@localhost wang]# getent passwd gentoo
gentoo:x:2004:2004:Gentoo distribution:/home/gentoo:/bin/csh

創建下面的用戶、組和組成員關系

名字為admins的組

用戶natasha,使用admins 作為附屬組

用戶harry,也使用admins作為附屬組

用戶sarah,不可交互登錄系統,且不是admins的成員

natasha,harry,sarah密碼都是centos

[root@localhost wang]# groupadd admins
[root@localhost wang]# useradd -G admins natasha
[root@localhost wang]# useradd -G admins harry
[root@localhost wang]# useradd -s /sbin/nologin sarah
[root@localhost wang]# echo "centos" | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root@localhost wang]# echo "centos" | passwd --stdin harry 
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root@localhost wang]# echo "centos" | passwd --stdin sarah 
Changing password for user sarah.
passwd: all authentication tokens updated successfully.
[root@localhost wang]#

一次創建多個用戶并配置密碼

[root@localhost ~]# vi user.txt

linux1:x:2001:2001::/home/linux1:/bin/bash
linux2:x:2002:2002::/home/linux2:/bin/bash
linux3:x:2003:2003::/home/linux3:/bin/bash
~                                                                                     
~                                                                                     
~
[root@localhost ~]# newusers user.txt
[root@localhost ~]# ls /home
gentoo  harry  linux1  linux2  linux3  mageedu  natasha  sarah
[root@localhost ~]# cat /etc/passwd    
...
...
...  
linux1:x:2001:2001::/home/linux1:/bin/bash
linux2:x:2002:2002::/home/linux2:/bin/bash
linux3:x:2003:2003::/home/linux3:/bin/bash
[root@localhost ~]# vi passwd.txt

linxu1:123456
linux2:234567
linux3:345678
~                                                                                     
~                                                                                     
~                                                                                     
~                                                                                     
[root@localhost ~]# cat passwd.txt | chpasswd  
[root@localhost ~]# cp /etc/skel/.[^.]* /home/linux1

創建testuser  uid:1234  主組:bin 輔助組:root,ftp shell:/bin/csh home:/testdir/testuser

[root@localhost /]# useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser -m testuser
[root@localhost /]# id  testuser
uid=1234(testuser) gid=1(bin) groups=1(bin),0(root),50(ftp)
[root@localhost /]# groups testuser 
testuser : bin root ftp

修改testuser uid:4321 主組:root 輔助組:nobody loginname:test home:/home/test 家數據遷移

[root@localhost /]# usermod -u 4321 -g root -G nobody -l test -d /home/test -m testuser 
[root@localhost /]# id test
uid=4321(test) gid=0(root) groups=0(root),99(nobody)
[root@localhost /]# groups test 
test : root nobody

批量創建帳號 user1-user10 uid:3000-3009 shell:/bin/csh home:testdir/user 密碼:user1pass

[root@localhost /]# vi user.txt

user1:x:3000:3000::/testdir/user1:/bin/csh
user2:x:3001:3001::/testdir/user2:/bin/csh
user3:x:3002:3002::/testdir/user3:/bin/csh
user4:x:3003:3003::/testdir/user4:/bin/csh
user5:x:3004:3004::/testdir/user5:/bin/csh
user6:x:3005:3005::/testdir/user6:/bin/csh
user7:x:3006:3006::/testdir/user7:/bin/csh
user8:x:3007:3007::/testdir/user8:/bin/csh
user9:x:3008:3008::/testdir/user9:/bin/csh
user10:x:3009:3009::/testdir/user10:/bin/csh
~                                                                                     
~                                                                                     
[root@localhost /]# newusers user.txt  
[root@localhost /]# vi passwd.txt

user1:user1pass
user2:user2pass
user3:user3pass
user4:user4pass
user5:user5pass
user6:user6pass
user7:user7pass
user8:user8pass
user9:user9pass
user10:user10pass
~                                                                                     
~                   
[root@localhost /]# cat passwd.txt | chpasswd   
[root@localhost ~]# cp /etc/skel/.[^.]* /testdir/user1
cp: omitting directory ‘/etc/skel/.mozilla’
[root@localhost ~]# su - user1
[user1@localhost ~]$ exit
logout
[root@localhost ~]#

原創文章,作者:DYW,如若轉載,請注明出處:http://www.www58058.com/27361

(0)
DYWDYW
上一篇 2016-08-02
下一篇 2016-08-02

相關推薦

  • Linux中正則表達式和grep的使用

    正則表達式在Linux經常配合grep,sed和awk等用于搜尋關鍵字。正則表達式分為正則表達式和擴展正則表達式: 一、正則表達式 1.1 元字符: .:匹配任意字符    []:匹配[]中的任意一個字符 [^]:匹配[]以外的任意字符 [:alpha:]大小寫英文字母 [:digit:]:十進制數字 [:xdigit…

    Linux干貨 2017-04-08
  • 八大排序算法

    概述 排序有內部排序和外部排序,內部排序是數據記錄在內存中進行排序,而外部排序是因排序的數據很大,一次不能容納全部的排序記錄,在排序過程中需要訪問外存。 我們這里說說八大排序就是內部排序。     當n較大,則應采用時間復雜度為O(nlog2n)的排序方法:快速排序、堆排序或歸并排序序。    快速…

    Linux干貨 2015-04-07
  • 進程管理之進程基礎及操作命令

    進程管理 今天我們開始講進程管理的相關知識,進程是學習LInux系統的重要一節內容,不僅能更幫助我們了解LInux系統的原理組成,又能方便我們在平常運維工作中的管理工作,幫助我們故障排查.希望大家牢固的掌握進程知識. 以下是我們分享的內容: 概論 進程控制 進程管理工具 概論 程序執行: 多道程序的執行分為順序執行和并發執行 程序順序執行時的特征: &nbs…

    Linux干貨 2016-09-07
  • ?HA專題: Corosync+Pacemaker+drbd實現MySQL高可用

    HA專題: Corosync+Pacemaker+drbd實現MySQL高可用 前言 實驗拓撲 實驗環境 實驗步驟 安裝前準備工作 配置DRBD 配置MySQL 配置Corosync+Pacemaker 測試 我遇到的問題 總結 前言 上篇文章我們介紹了drbd的相關原理、編譯安裝、簡單的實現. drbd雖然可以保證數據的可靠性但是我們上次的實現還…

    Linux干貨 2016-04-13
  • httpd服務

             練習:        (1)基于主機名實現三個虛擬主機              …

    Linux干貨 2016-11-11
  • CentOS 7和CentOS 6 使用gpg工具實現公鑰加密和解密

    運行環境: [root@Shining ~]# uname -a Linux Shining.ACG 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x…

    Linux干貨 2016-12-01
欧美性久久久久