馬哥教育網絡班第21期+第三周課程作業

1. 列出當前系統上所有已經登錄的用戶的用戶名,注意:同一個用戶登錄多次,則只顯示一次即可。

who | awk  '{print $1}'|uniq

2.列出最后登錄到當前系統的用戶的相關信息

last | head -1

 

3. 讀取當前系統上被用戶當做其默認shell最多的那個shell

cat /etc/passwd | awk -F : '{print $7}' | sort -nr |uniq -cd |head -1

 

 

4、將/etc/passwd中的第三個字段數值最大的后10個用戶的信息全部改為大寫后保存至/tmp/etc.conf文件中

sort -t : -k 3 -n /etc/passwd | tail -10 | tr 'a-z' 'A-Z' > /tmp/etc.conf

 

5. 取出當前主機的ip地址

ifconfig eth0 | head -2 |tail -1 |cut -d: -f2|awk -F' ' '{print $1}'

 

6. 列出/etc目錄下所有以.conf結尾的文件的文件名,并將其名字轉換為大寫后保存至/tmp/etc.conf文件中

ls /etc/*.conf | tr '[:lower:]' '[:upper:]' >> /tmp/etc.conf

 

7. 顯示/var目錄下一級子目錄或文件的總個數。

#ls /var/|wc –l

8. 取出/etc/group文件中第三個字段數值最小的10個組的名字

cut -d: -f1,3 /etc/group | sort -t: -k2 -n | head -10 |cut -d: -f1

9. 將/etc/fstab和/etc/issue文件的內容合并為同一個內容后保存至/tmp/etc.test文件中。

cat /etc/fstab /etc/issue >>/tmp/etc.test

 

10.請總結描述用戶和組管理類命令的使用辦法并完成練習

 

[root@redhat6 ~]# groupadd distro -g 2016

 

[root@redhat6 ~]# useradd mandriva -u 1005 -g distro

 

[root@redhat6 ~]# useradd mageia -u 1100 -d /home/linux

 

[root@redhat6 ~]# echo "mageedu" |passwd –stdin mageia

Changing password for user mageia.

passwd: all authentication tokens updated successfully.

 

 

[root@redhat6 ~]# userdel mandriva

 

[root@redhat6 ~]# groupadd peguin

[root@redhat6 ~]# useradd slackware -u 2002 -g distro -G peguin

 

 [root@redhat6 ~]# usermod  -s /bin/tcsh slackware

 

[root@redhat6 ~]# groupadd admins

[root@redhat6 ~]# usermod -G admins slackware

 

 

[root@redhat6 ~]# passwd -n 3 -x 180 -w 3 slackware

Adjusting aging data for user slackware.

passwd: Success

 

 

 

[root@redhat6 ~]# groupadd clouds

[root@redhat6 ~]# groupadd nova

[root@redhat6 ~]# useradd openstack -u 3003 -g clouds -G peguin -G nova

 

 

[root@redhat6 ~]# useradd mysql -s /sbin/nologin

 

 

[root@redhat6 ~]#  echo 'redhat' | passwd –stdin openstack

Changing password for user openstack.

passwd: all authentication tokens updated successfully.

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

(0)
LionelLionel
上一篇 2016-07-26 16:43
下一篇 2016-07-26 16:52

相關推薦

  • iptables

    iptables Firewall:防火墻 隔離工具;Packets Filter Firewall;工作于主機或網絡的邊緣,對經由的報文根據預先定義的規則(匹配條件)進行檢測,對于能夠被規則匹配到的報文實行某預定義的處理機制的一套組件; 分類: 硬件防火墻:在硬件級別實現部分功能的防火墻;另一個部分功能基于軟件實現; 軟件防火墻:應用軟件處理邏輯運行于通用…

    Linux干貨 2016-11-07
  • LVM組件詳解&創建實驗流程

       前言:根據前面的學習我們知道,一個磁盤一旦分完區并且格式化后,其空間大小是沒有辦法進行調整了。因此推出了LVM(Logical Volume Manager)邏輯卷管理機制,LVM重點在于可以彈性的調整文件系統的容量!并非在于性能和數據保全方面,需要文件的讀寫性能或者數據的可靠性,需要用到RAID。而LVM可以整合多個物理…

    Linux干貨 2016-08-30
  • 文本處理sed

    文本處理sed Sed介紹:          處理文本的工具sed ,Stream EDitor, 行編輯器 sed是一種流編輯器,它一次處理一行內容。處理時,把當前處理的行存儲在臨時緩沖區中,稱為“模式空間”(pattern space),接著用sed命令處理緩沖區中的內容,…

    Linux干貨 2017-05-04
  • 馬哥教育N22期第四周作業

    1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。 root@xuc-virtual-machine:/home/xuc# cp -r /etc/skel/ /home/tuser1 root@xuc-virtual-machine:/…

    Linux干貨 2016-09-06
  • netfilter/iptables 基礎入門

    netfilter/iptables 基礎入門 Firewall防火墻的實現方式 什么是netfilter?        Netfilter是由Linux內核提供的框架,允許以定制處理程序的形式實現各種與網絡相關的操作。Netfilter為包過濾,網絡地址轉換和端口轉換提供各種功能和操作,它們提供了通過網絡…

    2017-06-13
  • Linux文件查找

    什么是文件查找     在文件系統中查找符合條件的文件; 文件查找分為:     實時查找:遍歷所有文件進行條件匹配(find)     非實時查找:根據索引查找(locate) locate ? 查詢系統上預建的文件索引數據庫 …

    Linux干貨 2016-08-15
欧美性久久久久