Linux Experiment 3

1. When querying with the /etc/passwd command, I encounter the problem of Permission denied

  可以进入root用户便于操作:
 ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502224144760-964469164.png)

  输入密码并回车后,输入命令: chmod 777 /etc/passwd ,然后再输入命令:/etc/passwd

  ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502224301537-1736286366.png)

  紧接着,... ( |=_=| ) 如下:
  ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502224444419-1959594722.png)

  以上就是043查到的内容了;显然,/etc/passwd 中存放的是用户的信息;相较而言,/etc/shadow 中存放的是

User login information, and the format of the /etc/shadow file is similar to that of the /etc/passwd file. It also consists of several fields, and the fields are separated by ":".
The /etc/group file contains information about the group; /etc/gshadow is the encrypted information file of /etc/group, such as the user group (Group) management
password is stored in this file.

2. The distinction between id \id -u\id -u root\id -u xjx:
1) id: The id command can display the real and effective user ID (UID) and group ID (GID)

   2)id -u:显示用户ID
  
   3)id -u root:显示用户root的ID

   4)id -u xjx:显示用户xjx的ID  
   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502224641039-687841128.png)

3. Write the corresponding shell commands according to the requirements:
1) Search for the existence of the signal.h file in the directory /usr/include? 043 does it :)

   2)在/usr/include目录下的所有文件中查找包含BUFSIZ的行,并显示所在行号。
   (要求:屏幕上只显示查找到的结果,并过滤错误信息)
   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502181428523-2068257792.png)
   
   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502181926413-1228602898.png)

   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502182030886-373230692.png)

   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502223738032-1007676128.png)


   043能说这个乍一看我不会吗? 我不敢,怎么破(?@_@?)

   3)在用户名密码文件/etc/passwd中查找登录shell为bash的用户信息记录,并显示行号
   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502182346493-1848477682.png)

   4)从/etc/group 文件中截取第 1 列(组名)和第 3 列(组 id),并按照组 id 号的数值大小由小到大排序。
   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502182654790-1778883385.png)

   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502182721681-746566459.png)

   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502182806114-1521673124.png)

   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502182840590-2110754491.png)

   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502182918044-2001768143.png)

4. (1) For the following ex1.sh file:

   执行:
   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502213432065-676917567.png)

   结果疑似报了错:
   fail to backup: 
   tar: Cowardly refusing to create an empty archive

   吓得043赶紧看了一下源码,然后重度怀疑error_info这个文件有鬼,果然:
   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502214649980-619856325.png)

   这调皮的小妖精!

(2) Look at the ex2,sh file again:

   运行一下:
   ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502215337445-7235823.png)

   043发现,在输入完学号第11位的时候,瞬间就跳出了之后的信息,这让043想要按enter宝贝的手一抖,
心想:宝贝你别闹了!043心脏不好啊(=_=!)
   
   为了回应程序兄弟的热情,043给出如下答案:
      1)line3中的read命令选项-n11功能:一旦接收到11个字符就退出[就是你吓得043手抖!.gif]
      2)line 14中 grep $code $filename > t1 && read x major < t1 :功能:搜索code、filename重定向到t1,然后输
出到major。
   

5. Supplement: interesting program

     运行后:
     ![](https://images2018.cnblogs.com/blog/1351329/201805/1351329-20180502222249320-254038107.png)

    果然是a a fire(一把把火)
    /*其实043想说:这什么鬼命令?& What does this mean?(? ?* _ * ??)*/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325198609&siteId=291194637