Linux Practical Case Jobs (1)

Source: Internet
Author: User
Tags egrep

1, the creation of a 10G file system, the type of EXT4, requires the boot can be automatically mounted to a separate data/data directory; #fdisk   /dev/sda#partx -a /dev/sda#mke2fs  -t ext4  /dev/sda3#mkdir  /data  /dev/sda3  /data ext4  defaults 0 0  2, displays a line with ' LISTEN ' followed by 0, one, or more white-space characters in the ' netstat -tan ' command result;[[email  protected] data]# 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     tcp6       0       0 :::22                    :::*                      LISTEN     tcp6        0      0 ::1:631                  :::*                      LISTEN     tcp6        0      0 ::1:25                   :::*                      listen3, add user Nginx, Zabbix, Tomcat, and Hadoop users (the Nologin user's shell is/sbin/nologin), and then find the row in the/etc/passwd file that has the same user name as its shell name;[[email  Protected] ~]# useradd nginx[[email protected] ~]# useradd zabbix[[email  protected] ~]# useradd tomcat[[email protected] ~]# useradd hadoop[[ Email protected] ~]# useradd -s /sbin/nologin nologin[[email protected]  ~]# grep  ' ^\ (\<[[:alnum:]]\+\>\). *\1$ '  /etc/passwdsync:x:5:0:sync:/sbin:/bin/ Syncshutdown:x:6:0:shutdown:/sbin:/sbin/shUtdownhalt:x:7:0:halt:/sbin:/sbin/haltnologin:x:1005:1005::/home/nologin:/sbin/nologin4, find/etc/rc.d/init.d/ Functions a word in a file (the middle of a word can be underlined) followed by a line of parentheses;[[email protected] ~]# grep  ' \<.\+\> () '  /etc/rc.d/init.d/functionscheckpid ()  {__pids_var_run ()  {__pids_pidof ()  {daemon ()  { Killproc ()  {pidfileofproc ()  {pidofproc ()  {status ()  {echo_success ()  {echo_failure ()  {echo_passed ()  {echo_warning ()  {update_boot_stage ()  {success ()  {failure ()  { Passed ()  {warning ()  {action ()  {strstr ()  {is_ignored_file ()  {is_true ()  {is_false ( )  {apply_sysctl ()  {5, use echo to output a path, and then egrep find its path base name, and further use Egrep to remove its directory name (note that the directory name, not the directory path);[[email  protected] ~]# echo  "/MNT/SDC"   | grep -E -o  "[^/]+/?$"    | cut -d "/"   -f1sdc6, find all files that do not belong to root, bin, or Hadoop under the/usr directory; [[email protected] ~ ]# find /usr/ -not&nbSp;\ ( -user root -o -user bin -o -user hadoop \)  -ls67718147 &NBSP;&NBSP;&NBSP;&NBSP;4&NBSP;DRWX------   2 polkitd  root          4096 12 Month  29 22:01 /usr/share/polkit-1/rules.d67788273    12 -rwsr-sr-x   1 abrt     abrt         11232 3 Month  24  2015 /usr/libexec/ Abrt-action-install-debuginfo-to-abrt-cache7, one day the system was invaded, hackers in your system to leave a Trojan file: Now you need to find the current system is not a master or a group, and the last week has been visited all the files; In addition, you need to find All files that are larger than 20k in the/etc directory and are of the normal file type; [[Email protected] ~]# find /  \ ( -nouser -a  -nogroup \)  -a -atime -7 -lsfind:  '/PROC/4915/TASK/4915/FD/6 ':  No file or directory find:  '/PROC/4915/TASK/4915/FDINFO/6 ':  no that file or directory find:  '/PROC/4915/FD/6 ':  No file or directory find:  '/PROC/4915/FDINFO/6 ': &NBSP; no file or directory find:  '/RUN/USER/1000/GVFS ':  permissions are insufficient [[email protected] ~]# find /etc/  -size +20k -type f  -ls134657631  176 -r--r--r--    1 root     root       179212 12 Month  29 21:54 /etc/pki/ca-trust/extracted/java/cacerts201530249  316 -r--r--r--    1 root     root        321332 12 Month  29 21:54 /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt700354   236 -r--r--r--   1 root     root        240762 12 Month  29 21:54 /etc/pki/ca-trust/extracted/pem/ tls-ca-bundle.pem700355  188 -r--r--r--   1 root      root       191741 12 Month  29 21:54 /etc/pki/ca-trust/extracted/pem/email-ca-bundle.pem700356   188 -r--r--r--   1 root     root        191772 12 Month  29 21:54 /etc/pki/ca-trust/extracted/pem/ objsign-ca-bundle.pem67624879   64 -rw-r--r--   1 root      root        65536 3 Month   6   2015 /etc/pki/nssdb/cert8.db201886591  240 -rw-r--r--   1 root      root       242153 3 Month   6   2015 /etc/ssh/moduli136804649 6228 -r--r--r--   1 root      root      6376691 12 Month  29 22:00 /etc/udev/ Hwdb.bin67752520   60 -rw-r--r--   1 root     root         60408 3 Month   6  2015 /etc/lvm/lvm.conf202817359   52 -rw-r--r--    1 root     root         51272 6 Month  10  2014 /etc/gconf/schemas/nautilus-open-terminal.schemas201327306   656 -rw-r--r--   1 root     root        670293 6 Month   7  2013 /etc/services1608610    28 -rw-r--r--   1 root     root         26134 1 Month  15  2015 /etc/sysconfig/network-scripts/ network-functions-ipv6203120731   72 -rw-r--r--   1 root      root  &Nbsp;     70795 12 Month  29 22:05 /etc/ld.so.cache137359411   360 -rw-r--r--   1 root     root        365229 3 Month   6  2015 /etc/selinux/targeted/contexts/files/ file_contexts137359418   60 -rw-r--r--   1 root      root        58064 3 Month   6  2015 &NBSP;/ETC/SELINUX/TARGETED/MODULES/ACTIVE/BASE.PP137359420&NBSP;&NBSP;360&NBSP;-RW-------   1  root     root       365229 3 month    6  2015 /etc/selinux/targeted/modules/active/file_contexts137359422  368 - RW-------   1 root     root        376757 3 Month &NBSP;&NBSP;6&NBsp; 2015 /etc/selinux/targeted/modules/active/file_contexts.template202914041   24  -rw-r--r--   1 root     root         24383 3 Month   6  2015 /etc/selinux/targeted/modules/active/modules /apache.pp202914221   28 -rw-r--r--   1 root      root        28414 3 Month &NBSP;&NBSP;6&NBSP;&NBSP;2015&NBSP;/ETC /selinux/targeted/modules/active/modules/init.pp202914453   36 -rw-r--r--    1 root     root        33705  March   6  2015 /etc/selinux/targeted/modules/active/modules/staff.pp202914460    44 -rw-r--r--   1 root     root         44655 3 Month   6  2015 /etc/selinux/targeted/modules/active/modules/ sysadm.pp202914484   32 -rw-r--r--   1 root      root        29412 3 Month &NBSP;&NBSP;6&NBSP;&NBSP;2015&NBSP;/ETC /selinux/targeted/modules/active/modules/unprivuser.pp202914497   28 -rw-r--r--    1 root     root        26559  3 Month   6  2015 /etc/selinux/targeted/modules/active/modules/virt.pp202914511    24 -rw-r--r--   1 root     root         21063 3 Month   6  2015 /etc/selinux/targeted/ Modules/active/modules/xguest.pp202914512   28 -rw-r--r--   1 root      root &nBsp;      28639 3 Month   6  2015 /etc/selinux/targeted/ modules/active/modules/xserver.pp5197208 3752 -rw-r--r--   1 root      root      3839718 3 Month   6  2015 / etc/selinux/targeted/policy/policy.29201885278   28 -rw-r--r--   1  Root     root        25213 6 Month  10   2014 /etc/dnsmasq.conf201680462   36 -rw-r--r--   1  Root     root        65536 12 Month  29 &NBSP;21:55&NBSP;/ETC/OPENLDAP/CERTS/CERT8.DB2208809&NBSP;&NBSP;&NBSP;36&NBSP;-RW-------   1  root     root        65536 12 Month  29 21:57 /etc/ipsec.d/cert8.db68048011   52 -rw-r--r--   1 root      root        49286 3 Month   6  2015  /etc/brltty/fr-abrege.ctb68048174  268 -rw-r--r--   1 root      root       273315 3 Month   6   2015 /etc/brltty/ko.ctb68047990   40 -rw-r--r--   1 root      root        37790 3 Month   6   2015 /etc/brltty/de-kurzschrift.ctb68048181   56 -rw-r--r--   1  root     root        54704 3 Month   6  2015 /etc/brltty/letters-latin.tti68047998   24 -rw-r--r--    1 root &Nbsp;   root        20733 3 Month   6   2015 /etc/brltty/en-nabcc.ttb68048000   40 -rw-r--r--   1  Root     root        39633 3 month    6  2015 /etc/brltty/en-us-g2.ctb68048242   56 -rw-r--r--    1 root     root        56542  March   6  2015 /etc/brltty/zh-tw-polyphone.cti68048243  392 -rw-r--r--    1 root     root        400503 3 Month   6  2015 /etc/brltty/zh-tw-ucb.ctb68048244 1336 -rw-r--r--    1 root     root      1367395  3 Month   6  2015 /etc/brltty/zh-tw.ctb202304306   24 -rw-r--r--   1 root      root        21929 3 Month   6   2015 /etc/brltty.conf202901855   24 -rw-r--r--   1 root      root        20876 6 Month  10   2014 /etc/postfix/access202901862   24 -rw-r--r--   1 root      root        21545 6 Month  10   2014 /etc/postfix/header_checks202901863   28 -rw-r--r--   1  root     root        27176 6 Month  10  2014 /etc/postfix/main.cf8, create a directory/test/data, let a group of ordinary users have write permissions to it, and all the files created by the group of directories belong to the groups; Each user can only delete their own files. [[Email protected] ~]# mkdir -p /test/data[[email protected] data]# chmod g+s / test/data[[email protected] data]# chmod g+w /test/data[[email protected]  Data]# chmod o+t /test/data

This article is from the "July" blog, please be sure to keep this source http://927755.blog.51cto.com/917755/1730185

Linux Practical Case Jobs (1)

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.