Linux Random entry

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.
[Email protected]/]# cp-r/etc/skel/home/tuser1 && chmod 700-r/home/tuser1 [[email protected]/]# echo $?0[ [Email protected] home]# ll-al/home/tuser1/total dosage 12drwx------. 3 root root 74 November 13:14. Drwxr-xr-x. 4 root root 30 November 30 13:14.. -RWX------. 1 root root 18 November 13:14. bash_logout-rwx------. 1 root root 193 November 13:14. bash_profile-rwx------. 1 root root 231 November 13:14. bashrcdrwx------. 4 root root 37 November 13:14 Mozilla
2. Edit the/etc/group file and add the group Hadoop.
[[email protected]/] #echo "hadoop:x:1001" >>/etc/group [[email protected]/]# Cat/etc/group |grep Hadoop had oop:x:1001 [[Email protected]/]#
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]# echo "Hadoop:x:1001:1001:hadoop:/home/hadoop:/bin/bash" >>/etc/passwd && Tail -N 2/etc/passwd User:x:1000:1000:user:/home/user:/bin/bash Hadoop:x:1001:1001:hadoop:/home/hadoop:/bin/bash
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] /]# cp -r /etc/skel /home/hadoop  && chmod 700 -r /home/hadoop && ll -al /home/ hadoop/     Total dosage  12    drwx------.  3 root root   74 11 Month  30 13:54 .    drwxr-xr-x. 5 root root   43 11 month  30 13:54      -rwx------.  1 root root  18 11 Month  30 13:54  . bash_logout    -rwx------.  1 root root 193 11 Month  30  13:54 .BASH_PROFILE    -RWX------.  1 root root 231 11 Month   30 13:54 .BASHRC    DRWX------.  4 root root  37  November  30 13:54 .mozilla    [[email protected] /]# 
5, modify the/home/hadoop directory and all the internal files of the owner of Hadoop, belong to Hadoop group.
    [[email protected] /]# chown -r hadoop:hadoop /home/ Total dosage of hadoop/ && ll -al /home/hadoop/      12     drwx------.  3 hadoop hadoop  74 11 Month  30 13:54 .     drwxr-xr-x. 5 root   root    43 11 month   30 13:54&NBSP, ....     -rwx------.  1 hadoop hadoop  18 11 Month  30 13:54  .bash_logout    -rwx------.  1 hadoop hadoop 193 11 Month  30  13:54 .BASH_PROFILE    -RWX------.  1 hadoop hadoop 231  11 month  30 13:54 .bashrc    drwx------.  4 hadoop hadoop   37 11 Month  30 13:54 .mozilla    [[email protected] / ]#
6. Display the lines in the/proc/meminfo file beginning with uppercase or lowercase s, in two ways;
    [[email protected] /]# grep -i  "^s"  /proc/meminfo     swapcached:            0 kb     SwapTotal:       1023996 kB     swapfree:        1023996 kb    shmem:               9636 kB     slab:             171236 kb     SReclaimable:      99660 kB     sunreclaim:        71576 kb    [[email  protected] /]# grep -i  "^[ss"  /proc/meminfo    SwapCached:             0 kB    SwapTotal:        1023996 kB    SwapFree:         1023996 kB    Shmem:               9636 kB    Slab:              171236 kB    SReclaimable:       99660 kB    SUnreclaim:         71576 kb    [[email protected] /]#
7. Display the default shell of the/etc/passwd file as a non-/sbin/nologin user;
    [[email protected] /]# grep -v  "/sbin/nologin"  /etc/ passwd    root:x:0:0:root:/root:/bin/bash    sync:x:5:0:sync:/sbin:/ bin/sync    shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown    halt:x:7:0 : Halt:/sbin:/sbin/halt    amandabackup:x:33:6:amanda user:/var/lib/amanda:/bin/bash     USER:X:1000:1000:USER:/HOME/USER:/BIN/BASH    HADOOP:X:1001:1001: hadoop:/home/hadoop:/bin/bash    [[email protected] /]#      cut, beautiful     [[email protected] /]# grep -v  "/sbin/nologin"  /etc/passwd | cut -d ":"  -f1    root    sync     shutdown    halt    amandabackup     user    hadoop    [[email protected] /]# 
8. Display the user whose default shell is/bin/bash in/etc/passwd file;
[[email protected]/]# grep "/bin/bash"/etc/passwd root:x:0:0:root:/root:/bin/bash Amandabackup:x:33:6:amanda User :/var/lib/amanda:/bin/bash User:x:1000:1000:user:/home/user:/bin/bash hadoop:x:1001:1001:hadoop:/home/hadoop:/ Bin/bash cut, beautiful [[email protected]/]# grep "/bin/bash"/etc/passwd |cut-d ":"-f1 root amandabackup Use R Hadoop [[email protected]/]#
9. Find out one or two digits in the/etc/passwd file;
grep "\<[0-9]\{1,2\}\>"/etc/passwd

650) this.width=650; "src=" Http://i.imgur.com/PZkXS4z.png "style=" margin-top:0px;margin-right:0px;margin-bottom:0 px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px; border-right-width:0px;border-bottom-width:0px;border-left-width:0px; "alt=" Pzkxs4z.png "/>

10. Display the line beginning with at least one blank character in/boot/grub/grub.conf;
    [[email protected] ~]# grep  "^[[:space:]]\+"  /boot/grub/ grub.conf        root  (hd0,0)          kernel /vmlinuz-2.6.32-642.3.1.el6.x86_64 ro root=/dev/mapper/vg_centos-lv_root  rd_no_luks rd_lvm_lv=vg_centos/lv_swap rd_no_md lang=zh_cn. Utf-8 rd_lvm_lv=vg_centos/lv_root  keyboardtype=pc keytable=us rd_no_dm rhgb  quiet crashkernel=auto        initrd / initramfs-2.6.32-642.3.1.el6.x86_64.img        root  (hd0,0)          kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/ Mapper/vg_centos-lv_root rd_no_luks rd_lvm_lv=vg_centos/lv_swap rd_no_md lang=zh_cn. Utf-8 rd_lvm_lv=vg_centos/lv_root  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;
grep "^#[[:space:]]\+[^[:space:]]\+"/etc/rc.d/rc.sysinit
12. Find the line ending with ' LISTEN ' followed by 0, 1, or more whitespace characters in the result of the "Netstat-tan" command;
    [[email protected] /]# netstat -tan | grep   " listen[[:space:]]*$ "    tcp        0       0 0.0.0.0:22               0.0.0.0:*                LISTEN         tcp         0      0 127.0.0.1:631            0.0.0.0:*                LISTEN         tcp         0      0 127.0.0.1:25             0.0.0.0:*                LISTEN         tcp         0      0 127.0.0.1:6010           0.0.0.0:*                LISTEN         tcp6        0      0 :::22                    :::*                      LISTEN          tcp6       0       0 ::1:631                 :::*                       Listen         tcp6       0       0 ::1:25                   :::*                      LISTEN          tcp6       0      0 : : 1:6010                :::*                      LISTEN         [[email protected] /]# 
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-d/home/bash-s/bin/bash-m bash useradd-d/home/testbash-s/bin/bash-m testbash useradd-d/home/bashe R-s/bin/bash-m basher useradd-d/home/nologin-s/sbin/nologin-m nologin [[email protected]/]# CAT/ETC/PASSW D | grep "^\<bash\>" bash:x:1002:1002::/home/bash:/bin/bash [[email protected]/]#


Linux scrambling

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.