馬哥linux 0801作業

  1. 將/etc/issue文件中的內容轉換為大寫后保存至/tmp/issue.out文件中1.png

    2.將當前系統登錄用戶的信息轉換為大寫后保存至/tmp/who.out文件中2.png

  2. 3.一個linux用戶給root發郵件,要求郵件標題為"help",郵件正文如下:

  3. Hello,I am 用戶名,the system version is here,please help me to check it,thanks!

  4. 操作系統版本信息

    3.png

    4.將/root/下文件列表,顯示成一行,并文件名之間用空格隔開

    4.png

5.file1文件的內容為:"1 2 3 4 5 6 7 8 9 10"計算出所有數字的總和5.png

6.刪除Windows文本中的'^M'字符6.png

7.處理字符串"xt.,l 1 jr#!$mn2 c*/fe3 uz4”,",只保留其中的數字和空格7.png

8.將PATH變量每個目錄顯示在獨立的一行8.png

9.刪除指定文件的空行

9.png

10.將文件中每個單詞(字母)顯示在獨立的一行.并無空行10.png

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


[root@centos6 ~]# useradd -G bin,root -s /bin/csh -c "Genttoo Distribution" gentoo  

[root@centos6 ~]# id gentoo

uid=501(gentoo) gid=501(gentoo) groups=501(gentoo),0(root),1(bin)

[root@centos6 ~]# finger gentoo

Login: gentoo                           Name: Genttoo Distribution

Directory: /home/gentoo                 Shell: /bin/csh

Never logged in.

No mail.

No Plan.



12.創建下面的用戶,組和組成員的關系

名字為admins的組

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

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

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

natasha,harry,sarah密碼都是centos



[root@centos6 ~]# groupadd admins

[root@centos6 ~]# useradd -G admins natasha

[root@centos6 ~]# useradd -G admins harry

[root@centos6 ~]# useradd -s /sbin/nologin sarah 

[root@centos6 ~]# echo "centos" | passwd –stdin natasha

Changing password for user natasha.

passwd: all authentication tokens updated successfully.

[root@centos6 ~]# echo "centos" | passwd –stdin harry

Changing password for user harry.

passwd: all authentication tokens updated successfully.

[root@centos6 ~]# echo "centos" | passwd –stdin sarah

Changing password for user sarah.

passwd: all authentication tokens updated successfully.

[root@centos6 ~]# getent group admins  

admins:x:502:natasha,harry



13.批量創建用戶,修改密碼


"user.txt" [New File]                                                           0,0-1         All

mage1:x:2501:2501::/home/mage1:/bin/bash

mage2:x:2502:2502::/home/mage2:/bin/bash

mage3:x:2503:2503::/home/mage3:/bin/bash

mage4:x:2504:2504::/home/mage4:/bin/bash

mage5:x:2505:2505::/home/mage5:/bin/bash

mage6:x:2506:2506::/home/mage6:/bin/bash

mage7:x:2507:2507::/home/mage7:/bin/bash

~                                               

"user.txt" [New] 7L, 287C written                                               

[root@localhost ~]# newusers user.txt

[root@localhost ~]# vim pass.txt

"pass.txt" [New File]                                                           0,0-1         All


mage1:centos

mage2:centos

mage3:centos

mage4:centos

mage5:centos

mage6:centos

mage7:centos

"pass.txt" [New] 7L, 91C written                                                

[root@localhost ~]# cat pass.txt|chpasswd


[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage1

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage2

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage3

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage4

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage5

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage6

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage7

[root@localhost ~]# su – mage1

Last login: Tue Aug  2 21:19:43 CST 2016 on pts/1

[mage1@localhost ~]$ 


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


[root@localhost ~]# useradd testuser -u 123 -g bin -G root,ftp -s /bin/csh -b /testdir/testuser   useradd: cannot create directory /testdir/testuser/testuser

[root@localhost ~]# id testuser

uid=123(testuser) gid=1(bin) groups=1(bin),0(root),50(ftp)

[root@localhost ~]# finger testuser

Login: testuser                         Name: 

Directory: /testdir/testuser/testuser   Shell: /bin/csh

Never logged in.

No mail.

No Plan.


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


[root@localhost ~]# groupadd testuser

[root@localhost ~]# usermod -u 4321 -g root -G nobody,testuser -d /home/test testuser

[root@localhost ~]# finger testuser

Login: testuser                         Name: 

Directory: /home/test                   Shell: /bin/csh

Never logged in.

No mail.

No Plan.

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/test

[root@localhost ~]# su – testuser

[testuser@localhost ~]$ 


16.

6、批量創建帳號:user1…user10

uid:3000-3009,shell:/bin/csh,home:/testdir/username

passwd:usernamepass

注意家目錄相關配置,使用戶正常登錄


[root@localhost ~]# vim user.txt

"user.txt" [New File]                                                           0,0-1         All

user1:x:3000:3000::/testdir/user1:/bin/csh

user2:x:3001:3001::/testdir/user2:/bin/csh

user3:x:3002:3002::/testdir/user3:/bin/csh

  er4:x:3003:3003::/testdir/user4:/bin/csh

▽er5: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

"user.txt" [New] 10L, 432C written                                              

[root@localhost ~]# newusers user.txt

[root@localhost ~]# vim pass.txt

"pass.txt" [New File]                                                           0,0-1         All

user1:user1pass

user2:user2pass

user3:user3pass

user4:user4pass

user5:user5pass

user6:user6pass

user7:user7pass

user8:user8pass

user9:user9pass

user10:user10pass

"pass.txt" [New] 10L, 162C written                                              

[root@localhost ~]# cat pass.txt|chpasswd

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user1

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user2

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user3

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user4

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user5

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user6

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user7

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user8

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user9

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user10

[root@localhost ~]# su – user1

[root@localhost ~]# grtent passwd

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

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

(0)
KartikKartik
上一篇 2016-08-04
下一篇 2016-08-04

相關推薦

  • 網絡21期第十周博客作業

    網絡21期第十周博客作業 1、請詳細描述CentOS系統的啟動流程(詳細到每個過程系統做了哪些事情) Centos6啟動流程:       POST加電自檢 —> BOOT Sequence —> 加載內核啟動系統  &…

    Linux干貨 2016-09-15
  • 第六周作業

    1、復制/etc/rc.d/rc.sysinit文件至/tmp目錄,將/tmp/rc.sysinit文件中的以至少一個空白字符開頭的行的行首加#;          cp/etc/rc.d/rc.sysinit /tmp/     &nbs…

    2017-09-04
  • 操作系統圖形界面發展史(1981-2009)

    注意,本文這羅列了從1981年以來有重大意義的操作系統的圖形界面。 首先,先介紹兩個網站: http://www.guidebookgallery.org/ 如果你比較關注圖形化UI的設計, 可以上這個網站上看看。 http://toastytech.com/guis/index.html 這是一個操作系統圖形界面收集的網站,上面幾科包括…

    Linux干貨 2016-05-17
  • Linux的用戶組和權限(一)

    導讀:本章主要內容如下       1.解釋Linux的安全模型      2.解釋用戶賬號和組群賬號的目的      3.用戶和組管理命令      4.理解并設置文件權限 &n…

    Linux干貨 2016-08-04
  • 面授20-1班 0805課間練習與課后作業

    課間練習 第一階段 新學的命令文本命令cat tac rev more less head tail cut paste wc sort dif patch 1 、找出ifconfig 命令結果中本機的所有IPv4 地址 [root@IP70-CentOS7 ~]# >>ifconfig | tr&nbsp…

    Linux干貨 2016-08-07
  • LVM邏輯卷管理

    一、簡述 什么是邏輯卷?LVM(Logical Volume Manager)利用Linux內核device-mapper實現存儲系統的虛擬化。通過LVM,把底層存儲硬件抽象化成存儲邏輯塊,再將這些邏輯塊集合構成存儲池,從存儲池空間劃分分區,可以簡單地擴大或縮小分區,而不用擔心硬盤沒有足夠的連續空間。 使用邏輯卷分區有什么用?使用邏輯卷分區重點在于可以彈性地…

    Linux干貨 2016-09-06
欧美性久久久久