Initial knowledge of vim and regular expressions

Source: Internet
Author: User

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.

~]# mkdir /home/tuser1~]# cp -r /etc/skel /home/tuesr1~]# chmod -R go-rwx /home/tuser1

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

~]# vim /etc/group    # i键进入编辑模式~]# hadoop:x:1000:    # esc 退出编辑状态~]# :wq 保存提出

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.

~]# vim /etc/passwd    # i键进入编辑模式~]# hadoop:x:1001:1000::/home/hadoop:/bin/bash    # esc 退出编辑状态~]# :wq 保存提出

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.

~]# cp -r /etc/skel /home/hadoop~]# chmod -R go-rwx /home/hadoop

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

~]# chown -R hadoop /home/hadoop~]# chgrp -R hadoop /home/hadoop

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

~]# grep -i "^s" /proc/meminfo~]# grep "^[sS]" /proc/meminfo~]# grep -E "^(s|S)" proc/meminfo

7. Display the default shell of the/etc/passwd file as a non-/sbin/nologin user;

~]# grep -v "/sbin/nologin$" /etc/passwd | cut -d ‘:‘ -f1

8. Display the user whose default shell is/bin/bash in/etc/passwd file;

~]# grep "/bin/bash$" /etc/passwd | cut -d ‘:‘ -f1

9. Find out one or two digits in the/etc/passwd file;

~]# grep "\<[0-9]\{1,2\}\>" /etc/passwd

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

~]# grep "^[[:space:]]" /boot/grub/grub.conf

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;

~]# grep "^#[[:space:]]\+[[:alnum:]]" /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;

~]# netstat -tan | grep "^LISTEN[[:space:]]*$"

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;

~]# useradd bash~]# useradd testbash ~]# useradd bahser~]# useradd -s /sbin/nologin nologin~]# grep  -E  "^([^:]+\>).*\1$"  /etc/passwd

Initial knowledge of vim and regular expressions

Related Article

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.