File search commands and search commands

Source: Internet
Author: User

File search commands and search commands

1. Copy the/etc/skel directory to/home/tuser1. The owner group of/home/tuser1 and its internal files and other users do not have any access permissions.

 1 [root@bogon home]# cp -r /etc/skel /home/tuser1 2 [root@bogon home]# chmod -R go= /home/tuser1 3 [root@bogon home]# ll -d tuser1 4 drwx------. 3 root root 74 Mar 20 00:03 tuser1 5 [root@bogon home]# ll -A tuser1 6 total 12 7 -rw-------. 1 root root  18 Mar 20 00:03 .bash_logout 8 -rw-------. 1 root root 193 Mar 20 00:03 .bash_profile 9 -rw-------. 1 root root 231 Mar 20 00:03 .bashrc10 drwx------. 4 root root  37 Mar 20 00:03 .mozilla

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

1 [root@bogon home]# vim /etc/group2 [root@bogon home]# tail -1 /etc/group3 hadoop:x:5004:

3. manually edit the/etc/passwd file and add a new row to add the user hadoop. The basic group ID is the ID of the hadoop group, and its home directory is/home/hadoop.

1 [root@bogon home]# vim /etc/passwd2 [root@bogon home]# tail -1 /etc/passwd3 hadoop:x:2003:5004:hadoop:/home/hadoop:/bin/bash

4. Copy the/etc/skel directory to/home/hadoop. Modify the group of the hadoop directory and other users without any access permissions.

 1 [root@bogon home]# cp -a /etc/skel /home/hadoop 2 [root@bogon home]# chmod go= /home/hadoop 3 [root@bogon home]# ll -d /home/hadoop 4 drwx------. 3 hadoop hadoop 74 Feb 28 23:10 /home/hadoop 5 [root@bogon home]# ll -A /home/hadoop/ 6 total 12 7 -rw-r--r--. 1 hadoop hadoop  18 Nov 19  2015 .bash_logout 8 -rw-r--r--. 1 hadoop hadoop 193 Nov 19  2015 .bash_profile 9 -rw-r--r--. 1 hadoop hadoop 231 Nov 19  2015 .bashrc10 drwxr-xr-x. 4 hadoop hadoop  37 Feb 28 23:09 .mozilla

5. Modify the/home/hadoop directory and all its internal files to hadoop, and the group to hadoop.

 1 [root@bogon home]# chown -R hadoop:hadoop /home/hadoop 2 [root@bogon home]# ll 3 total 8 4 drwx------.  3 hadoop    hadoop   74 Feb 28 23:10 hadoop 5 drwx------.  5 mageia    mageia 4096 Mar 16 00:47 linux 6 drwx------.  3      1005 distro   74 Mar 16 00:39 mandriva 7 drwx------.  3 slackware distro   74 Mar 16 00:51 slackware 8 drwx------.  3 root      root     74 Mar 20 00:03 tuser1 9 drwx------. 14 walter    walter 4096 Mar 19 19:32 walter10 [root@bogon home]# ll -A /home/hadoop11 total 1212 -rw-r--r--. 1 hadoop hadoop  18 Nov 19  2015 .bash_logout13 -rw-r--r--. 1 hadoop hadoop 193 Nov 19  2015 .bash_profile14 -rw-r--r--. 1 hadoop hadoop 231 Nov 19  2015 .bashrc15 drwxr-xr-x. 4 hadoop hadoop  37 Feb 28 23:09 .mozilla

6. Display rows starting with uppercase or lowercase S in the/proc/meminfo file;

1 grep-E "^ [Ss]"/pro/meminfo2 or 3 grep-I "^ s"/pro/meminfo4 or 5 grep-E "^ S | ^ s "/ pro/meminfo

7. The default shell in the/etc/passwd file is displayed as a non-/sbin/nologin user;

1 grep -v "/sbin/nologin$" /etc/passwd

8. display users whose default shell is/bin/bash in the/etc/passwd file;

1 grep "/bin/bash$" /etc/passwd

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

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

10. Display rows starting with at least one blank character in/boot/grub2/grub. cfg;

1 grep -E "^[[:space:]]+" /boot/grub2/grub2.cfg

11. The/etc/rc. d/init. d/functions file starts with #, followed by at least one blank character, and then contains at least one non-blank line;

1 grep -E "^#[[:space:]]+[^[:space:]]+" /etc/rc.d/init.d/functions

12. Execute the netstat-tan command with 'listen' in the execution result or a line ending with a blank character;

1 netstat -tan | grep -E "LISTEN[[:space:]]*$"

13. Add the user bash, testbash, basher, and nologin (the user's shell is/sbin/nologin), and find out the information of the user whose username is the same as the default shell on the current system;

 1 [root@bogon data]# useradd -s /sbin/nologin nologin 2 [root@bogon data]# useradd bash 3 [root@bogon data]# useradd testbash 4 [root@bogon data]# useradd basher 5 [root@bogon data]# grep -E "^\<([^:]+\>).*\1$" /etc/passwd 6 sync:x:5:0:sync:/sbin:/bin/sync 7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown 8 halt:x:7:0:halt:/sbin:/sbin/halt 9 nologin:x:4005:4005::/home/nologin:/sbin/nologin10 bash:x:4006:4006::/home/bash:/bin/bash

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.