First operation and maintenance

Question 1: display the current time in the format hh: mm: ss and save it to the time.txt file

[kiosk@foudation7 Desktop]$ date +%H:%M:%S >> time.txt

Question 2: show lines 15-18 of the / etc/passwd file

  [kiosk@foudation7 Desktop]$ cat /etc/passwd | head -n 18 | tail -n 3
            systemd-network:x:998:996:systemd Network Management:/:/sbin/nologin
            dbus:x:81:81:System message bus:/:/sbin/nologin
            polkitd:x:997:995:User for polkitd:/:/sbin/nologin

Question 3: display the file containing uppercase letters in / bin, save it to bin ﹣ westos ﹣ file.txt, and count the number to display on the screen

 [kiosk@foudation7 Desktop]$ ls /bin/*[[:upper:]]* | tee bin_westos_file.tex | wc -l

Problem 4: find the passwd file under / etc under the student user to mask the wrong output

 [student@foudation7 Desktop]$ find /etc/ -name passwd 2>/dev/null

Problem 5: find the passwd file under / etc under the student user, save the correct output to / etc/westos.out, and save the error output to / etc/westos.err

 [student@foudation7 Desktop]$ find /etc/ -name passwd 2>/tmp/westos.err >/tmp/wwestos.out

Question 6: find the passwd file under / etc under the student user, display the command output and save it to / tmp/westos.all

[student@foudation7 Desktop]$ find /etc/ -name passwd &>/tmp/westos.all

1 new user group

[kiosk@foudation7 Desktop]$ groupadd shengchan
[kiosk@foudation7 Desktop]$ groupadd jishu
[kiosk@foudation7 Desktop]$ groupadd caiwu

2 requirements for new users are as follows:
1. The initial group of adminsc is shengchan
2. The initial group of adminjs is jishu
3. The initial group of admincw is caiwu
tom is an additional user of production
Harry is an additional user of Finance
Leo is an additional user of Technology

[kiosk@foudation7 Desktop]$ useradd -g adminsc shengchan
[kiosk@foudation7 Desktop]$ useradd -g adminjs jishu
[kiosk@foudation7 Desktop]$ useradd -g admincw caiwu

9[kiosk@foudation7 Desktop]$ useradd -G shengchan tom
[kiosk@foudation7 Desktop]$ useradd -G caiwu harry
[kiosk@foudation7 Desktop]$ useradd -G jishu leo

10[kiosk@foudation7 Desktop]$ useradd admin

3 requirements for new directory are as follows:
1. /cw is the directory of the finance department. The owner of the directory is admincw. The directory is only for the people in the finance department to enter
2. /js is the directory of the technology department. The owner of the directory is adminjs. This directory is only for the personnel of the technology department to enter
3. /sc is the directory of the finance department. The owner of the directory is adminsc. The directory is only entered for the person in the production department
4. admin is the company's big boss, which can create files and delete files freely in the directory.

[kiosk@foudation7 Desktop]$ mkdir /sc
[kiosk@foudation7 Desktop]$ mkdir /js
[kiosk@foudation7 Desktop]$ mkdir /cw
[kiosk@foudation7 Desktop]$ chown admincw /cw
[kiosk@foudation7 Desktop]$ chown adminjs /js
[kiosk@foudation7 Desktop]$ chown adminsc /sc
[kiosk@foudation7 Desktop]$ chmod 755 /sc
[kiosk@foudation7 Desktop]$ chmod 755 /js
[kiosk@foudation7 Desktop]$ chmod 755 /cw
[kiosk@foudation7 Desktop]$ setfacl -m u:admin:rwx /sc
[kiosk@foudation7 Desktop]$ setfacl -m u:admin:rwx /cw
[kiosk@foudation7 Desktop]$ setfacl -m u:admin:rwx /js

Tags: network DBus

Posted on Sun, 03 May 2020 04:23:45 -0700 by broomstick