Marco Linux after-school assignment 4

Source: Internet
Author: User
Tags gopher uuid egrep

1, the Replication/etc/skel directory is/home/tuser1, requires/home/tuser1 and its internal files belong to the group and other users do not have any access rights.

[Email protected] home]# cp-r/etc/skel//home/tuser1

[Email protected] home]# chmod-r u-r,o-r tuser1/

[email protected] home]# LL

Total 40

DRWX------. 2 bash bash 4096 12:01 bash

DRWX------. 2 basher basher 4096 12:01 basher

DRWX------. 2 Mageia mageia 4096 01:14 Linux

DRWX------. 2 1005 distro 4096 01:12 Mandriva

DRWX------. 2 nologin nologin 4096 12:01 Nologin

DRWX------. 2 OpenStack clouds 4096 01:50 OpenStack

DRWX------. 2 Slackware distro 4096 01:24 Slackware

DRWX------. 2 Testbash testbash 4096 12:01 Testbash

D-wxr-x--x. 2 root root 4096 13:58 Tuser1

DRWX------. 2 Zengzy zengzy 4096 08:28 Zengzy

[email protected] home]# su Zengzy

[Email protected] home]$ cd/home/tuser1/

[[email protected] tuser1]$ ls

Ls:cannot Open Directory.: Permission denied


2. Edit the/etc/group file and add the group Hadoop.

[Email protected] home]# Vim/etc/group

[Email protected] home]# tail-n 5/etc/group

Admins:x:2018:slackware

CLOUDS:X:2019:

Nova:x:2020:openstack

mysql:x:498:

hadoop:x:499:


[Email protected] home]# echo ' hadoop1:x:505: ' >>/etc/group

[Email protected] home]# tail-n 1/etc/group

hadoop1:x:505:




3. Manually edit the/etc/passwd file to add a new line, adding user Hadoop, whose basic group ID is the Hadoop group ID number; its home directory is/home/hadoop.

[Email protected] home]# VIM/ETC/PASSWD

Hadoop:x:505:499::/home/hadoop:/bin/bash

[[email protected] home]# ID Hadoop

uid=505 (Hadoop) gid=499 (Hadoop) groups=499 (Hadoop)


[[email protected] home]# echo ' Hadoop1:x:506:505::/home/hadpood1:/bin/bash ' >>/etc/passwd

[[email protected] home]# ID HADOOP1

uid=506 (HADOOP1) gid=505 (HADOOP1) groups=505 (HADOOP1)



4. Copy the/etc/skel directory as/home/hadoop, which requires that the genus Group and other users of the Hadoop directory be modified without any access rights.

[Email protected] home]# cp-r/etc/skel/home/hadoop

[email protected] home]# LL

Total 44

DRWX------. 2 bash bash 4096 12:01 bash

DRWX------. 2 basher basher 4096 12:01 basher

Drwxr-xr-x. 2 root root 4096 14:22 Hadoop

DRWX------. 2 Mageia mageia 4096 01:14 Linux

DRWX------. 2 1005 distro 4096 01:12 Mandriva

DRWX------. 2 nologin nologin 4096 12:01 Nologin

DRWX------. 2 OpenStack clouds 4096 01:50 OpenStack

DRWX------. 2 Slackware distro 4096 01:24 Slackware

DRWX------. 2 Testbash testbash 4096 12:01 Testbash

D-wxr-x--x. 2 root root 4096 13:58 Tuser1

DRWX------. 2 Zengzy zengzy 4096 08:28 Zengzy

[Email protected] home]# chmod g-r,o-r hadoop/

[email protected] home]# LL

Total 44

DRWX------. 2 bash bash 4096 12:01 bash

DRWX------. 2 basher basher 4096 12:01 basher

Drwx--x--x. 2 root root 4096 14:22 Hadoop

DRWX------. 2 Mageia mageia 4096 01:14 Linux

DRWX------. 2 1005 distro 4096 01:12 Mandriva

DRWX------. 2 nologin nologin 4096 12:01 Nologin

DRWX------. 2 OpenStack clouds 4096 01:50 OpenStack

DRWX------. 2 Slackware distro 4096 01:24 Slackware

DRWX------. 2 Testbash testbash 4096 12:01 Testbash

D-wxr-x--x. 2 root root 4096 13:58 Tuser1

DRWX------. 2 Zengzy zengzy 4096 08:28 Zengzy


5, modify the/home/hadoop directory and all the internal files of the owner of Hadoop, belong to Hadoop group.

[email protected] home]# LL

Total 44

DRWX------. 2 bash bash 4096 12:01 bash

DRWX------. 2 basher basher 4096 12:01 basher

Drwx--x--x. 2 root root 4096 14:22 Hadoop

DRWX------. 2 Mageia mageia 4096 01:14 Linux

DRWX------. 2 1005 distro 4096 01:12 Mandriva

DRWX------. 2 nologin nologin 4096 12:01 Nologin

DRWX------. 2 OpenStack clouds 4096 01:50 OpenStack

DRWX------. 2 Slackware distro 4096 01:24 Slackware

DRWX------. 2 Testbash testbash 4096 12:01 Testbash

D-wxr-x--x. 2 root root 4096 13:58 Tuser1

DRWX------. 2 Zengzy zengzy 4096 08:28 Zengzy

[Email protected] home]# chown-r hadoop:hadoop hadoop/

[email protected] home]# LL

Total 44

DRWX------. 2 bash bash 4096 12:01 bash

DRWX------. 2 basher basher 4096 12:01 basher

Drwx--x--x. 2 Hadoop hadoop 4096 14:22 Hadoop

DRWX------. 2 Mageia mageia 4096 01:14 Linux

DRWX------. 2 1005 distro 4096 01:12 Mandriva

DRWX------. 2 nologin nologin 4096 12:01 Nologin

DRWX------. 2 OpenStack clouds 4096 01:50 OpenStack

DRWX------. 2 Slackware distro 4096 01:24 Slackware

DRWX------. 2 Testbash testbash 4096 12:01 Testbash

D-wxr-x--x. 2 root root 4096 13:58 Tuser1

DRWX------. 2 Zengzy zengzy 4096 08:28 Zengzy


6. Display the lines in the/proc/meminfo file beginning with uppercase or lowercase s, in two ways;

[Email protected] home]# Cat/proc/meminfo | grep "^[ss]"

swapcached:0 KB

swaptotal:2097148 KB

swapfree:2097148 KB

shmem:236 KB

slab:106148 KB

sreclaimable:46064 KB

sunreclaim:60084 KB


[Email protected] home]# Cat/proc/meminfo | Grep-i "^s"

swapcached:0 KB

swaptotal:2097148 KB

swapfree:2097148 KB

shmem:236 KB

slab:106144 KB

sreclaimable:46060 KB

sunreclaim:60084 KB


7. Display/ETC/PASSW D file whose default shell is non-/sbin/nologin user;

[Email protected] home]# CAT/ETC/PASSWD | Grep-v "/sbin/nologin$" | Cut-d:-f1

Root

Sync

Shutdown

Halt

Zengzy

Bash

Basher

Testbash

Mageia

Slackware

OpenStack

Hadoop

Hadoop1


8. Display the user whose default shell is/bin/bash in/ETC/PASSW D file;

[Email protected] home]# CAT/ETC/PASSWD | grep "/bin/bash$" | Cut-d:-f1

Root

Zengzy

Bash

Basher

Testbash

Mageia

OpenStack

Hadoop

Hadoop1


9. Find out one or two digits in/ETC/PASSW D file;

[Email protected] home]# egrep "\<[0-9]{1,2}\>"/etc/passwd

Root:x:0:0:root:/root:/bin/bash

Bin:x:1:1:bin:/bin:/sbin/nologin

Daemon:x:2:2:daemon:/sbin:/sbin/nologin

Adm:x:3:4:adm:/var/adm:/sbin/nologin

Lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

Sync:x:5:0:sync:/sbin:/bin/sync

Shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

Halt:x:7:0:halt:/sbin:/sbin/halt

Mail:x:8:12:mail:/var/spool/mail:/sbin/nologin

Uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin

Operator:x:11:0:operator:/root:/sbin/nologin

Games:x:12:100:games:/usr/games:/sbin/nologin

Gopher:x:13:30:gopher:/var/gopher:/sbin/nologin

Ftp:x:14:50:ftp User:/var/ftp:/sbin/nologin

Nobody:x:99:99:nobody:/:/sbin/nologin

Vcsa:x:69:69:virtual Console Memory Owner:/dev:/sbin/nologin

SASLAUTH:X:499:76:SASLAUTHD User:/var/empty/saslauth:/sbin/nologin

Postfix:x:89:89::/var/spool/postfix:/sbin/nologin

Sshd:x:74:74:privilege-separated Ssh:/var/empty/sshd:/sbin/nologin


[[email protected] home]# grep--color=auto "\<[0-9]\{1,2\}\>"/etc/passwd

Root:x:0:0:root:/root:/bin/bash

Bin:x:1:1:bin:/bin:/sbin/nologin

Daemon:x:2:2:daemon:/sbin:/sbin/nologin

Adm:x:3:4:adm:/var/adm:/sbin/nologin

Lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

Sync:x:5:0:sync:/sbin:/bin/sync

Shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

Halt:x:7:0:halt:/sbin:/sbin/halt

Mail:x:8:12:mail:/var/spool/mail:/sbin/nologin

Uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin

Operator:x:11:0:operator:/root:/sbin/nologin

Games:x:12:100:games:/usr/games:/sbin/nologin

Gopher:x:13:30:gopher:/var/gopher:/sbin/nologin

Ftp:x:14:50:ftp User:/var/ftp:/sbin/nologin

Nobody:x:99:99:nobody:/:/sbin/nologin

Vcsa:x:69:69:virtual Console Memory Owner:/dev:/sbin/nologin

SASLAUTH:X:499:76:SASLAUTHD User:/var/empty/saslauth:/sbin/nologin

Postfix:x:89:89::/var/spool/postfix:/sbin/nologin

Sshd:x:74:74:privilege-separated Ssh:/var/empty/sshd:/sbin/nologin


10. Display the line beginning with at least one blank character in/boot/grub/grub.conf;

[[email protected] home]# grep "^[[:space:]]\+"/boot/grub/grub.conf

Root (hd0,0)

kernel/vmlinuz-2.6.32-642.4.2.el6.x86_64 ro Root=uuid=b175aee5-62ee-4625-8aac-f3c455133efa Rd_NO_LUKS Rd_NO_LVM Lang=en_us. UTF-8 rd_no_md sysfont=latarcyrheb-sun16 crashkernel=auto keyboardtype=pc keytable=us Rd_NO_DM rhgb quiet

Initrd/initramfs-2.6.32-642.4.2.el6.x86_64.img

Root (hd0,0)

kernel/vmlinuz-2.6.32-642.el6.x86_64 ro Root=uuid=b175aee5-62ee-4625-8aac-f3c455133efa Rd_NO_LUKS rd_NO_LVM LANG=en _us. UTF-8 rd_no_md sysfont=latarcyrheb-sun16 crashkernel=auto keyboardtype=pc keytable=us Rd_NO_DM rhgb quiet

Initrd/initramfs-2.6.32-642.el6.x86_64.img


11, the display/etc/rc.d/rc.sysinit file with the beginning of #, followed by at least one white space character, and then have at least one non-whitespace character line;

[[email protected] home]# grep "^#[[:space:]]\+[^[:space:]]\+"/etc/rc.d/rc.sysinit


12, the Netstat-tan command execution results in the "LISTEN", followed by or with a blank character end of the line;

[Email protected] home]# Netstat-tan | Egrep "listten| [[: space:]]$]

Proto recv-q send-q Local address Foreign address state

TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN

TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN

TCP 0 192.168.2.105:22 192.168.2.106:12341 established

TCP 0 0 192.168.2.105:22 192.168.2.106:3099 established

TCP 0 0::: $:::* LISTEN

TCP 0 0:: 1:25:::* LISTEN


13, add user bash, Testbash, basher, Nologin (this one user's shell is/sbin/nologin), and then find the current system on its user name and the default shell of the same user information;

[Email protected] home]# Useradd bash

[Email protected] home]# Useradd Tetstbash

[Email protected] home]# Useradd basher

[Email protected] home]# useradd-s/sbin/nologin nologin

[[email protected] home]# grep--color=auto "^\ ([[: alnum:]]\+\>\). *\1$"/etc/passwd

sync: x:5:0:sync:/sbin:/bin/sync

shutdown: x:6:0:shutdown:/sbin:/sbin/shutdown

halt: x:7:0:halt:/sbin:/sbin/Halt

bash: x:501:501::/home/bash:/bin/bash

nologin: x:504:504::/home/nologin:/sbin/nologin



This article comes from the "Recharge yourself" blog, so be sure to keep this source http://zengzeyang.blog.51cto.com/6129531/1842811

Marco Linux after-school assignment 4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.