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-a/etc/skel/home/tuser1/[[email protected] ~]# chmod-r go-rwx/home/tuser1/
2. Edit the/etc/group file and add the group Hadoop.
[Email protected] ~]# echo "hadoop:x:3007:" >>/etc/group
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] ~]# echo "Hadoop:x:3007:3007::/home/hadoop:/sbin/nologin" >>/etc/passwd[[email protected] ~] # ID hadoopuid=3007 (Hadoop) gid=3007 (Hadoop) groups=3007 (Hadoop)
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-a/etc/skel/home/hadoop[[email protected] 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.
[[email protected] hadoop]# chown -r hadoop: HADOOP /HOME/HADOOP[[EMAIL PROTECTED] HADOOP]# LS -ALTOTAL 16DRWX------. 3 hadoop hadoop 74 jun 8 22:35 .drwxr-xr-x. 15  ROOT   ROOT   4096 AUG 28 10:44&NBSP, .... -RW-------. 1 hadoop hadoop 18 nov 20 2015 . BASH_LOGOUT-RW-------. 1 hadoop hadoop 193 nov 20 2015  .BASH_PROFILE-RW-------. 1 hadoop hadoop 231 Nov 20  2015 .BASHRCDRWX------. 4 hadoop hadoop 37 Jun 8 22:34 .mozilla
6 , displays the lines in the/proc/meminfo file that begin with uppercase or lowercase s, in two ways.
[[email protected] hadoop]# grep -i ' ^s ' /proc/meminfo SwapCached: 204 kBSwapTotal: 511996 kBSwapFree: 496060 Kbshmem: 3732 kbslab: 76928 kbsreclaimable: 38064 kBSUnreclaim: 38864 kb[[email protected] hadoop]# grep ' ^[ss] /proc/meminfo swapcached: 204 kbswaptotal: 511996 kBSwapFree: 496060 kbshmem: 3732 kbslab: 76928 kBSReclaimable: 38064 kbsunreclaim: 38864 kb
7. Displays the user whose default shell is non-/sbin/nologin in the/etc/passwd file.
[Email protected] hadoop]# CAT/ETC/PASSWD | Grep-v ":/sbin/nologin$" |cut-d:-F 1rootsyncshutdownhaltyanlibobobdistromandrivatest1mageiaslackwareopenstackuser1user2
8. Displays the user whose default shell is/bin/bash in the/etc/passwd file.
[Email protected] hadoop]# CAT/ETC/PASSWD | grep ":/bin/bash$" |cut-d:-F 1rootyanlibobobdistromandrivatest1mageiaslackwareopenstackuser1user2
9. Find one or two digits in the/etc/passwd file.
[Email protected] ~]# grep-op "\b\d{1,2}\b"/etc/ passwd0011223447506070812110121450999966658181595976323229297575424270708989747438387272
10. Displays the line (CENTOS6) that starts with at least one whitespace character in/boot/grub/grub.conf.
[Email protected] ~]# grgrep-p "^\s+"/boot/grub/grub.confroot (hd0,0) kernel/vmlinuz-2.6.32-642.el6.x86_64 ro root=/ Dev/mapper/vg_centos-lv_root nomodeset Rd_no_luks Lang=en_us. UTF-8 rd_lvm_lv=vg_centos/lv_swap rd_no_md Sysfont=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_centos/lv_root KEYBOARDTYPE=PC keytable=us rd_no_dm RHGB quietinitrd/initramfs-2.6.32-642.el6.x86_64.img
11. Display the/etc/rc.d/rc.sysinit file with # Beginning with at least one white space character followed by at least one non-whitespace character line (CentOS6).
[[email protected] ~]# grep -p ' ^#\s+\s+ ' /etc/rc.d/rc.sysinit# /etc/rc.d/ rc.sysinit - run once at boot time# taken in part from Miquel van smoorenburg ' S bcheckrc.# check selinux status# print a text banner.# only read this once.# initialize hardware# set default affinity# Load other user-defined modules# Load modules (For backward compatibility with vars) # configure kernel parameters# set the hostname.# sync waiting for storage.# device mapper & related initialization# start any md raid arrays that haven ' t been started yet# remount the root filesystem read-write.# clean up selinux labels# if relabeling, relabel mount points.# mount all other filesystems (except for nfs and /proc, which is already# mounted) . contrary to standard usage,# filesystems are not unmounted in single user mode.# The ' No ' applies to all listed Filesystem types. see mount (8) .# check to see if a full relabel is needed# update quotas if necessary# initialize Pseudo-random number generator# configure machine if necessary.# clean out /.# Do we need (w|u) Tmpx files? we don ' T set them up, but the sysadmin might...# clean up /var.# clean up utmp/wtmp# clean up variouS /tmp bits# make ice directory# start up swapping.# set up binfmt_misc# boot time profiles. yes, this should be somewhere else.# Now that we have all of our basic modules Loaded and the kernel going,# let ' s dump the syslog ring somewhere so we can find it later# create the crash indicator flag to warn on crashes, offer fsck with timeout# Let rhgb know that we ' Re leaving rc.sysinit
1 2, the Netstat-tan command execution results in the "LISTEN", followed by or with a blank character end of the line.
[[email protected] ~]# netstat -tan | grep -p "LISTEN\s*$" tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 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:6010 :::* listen
13, add user bash, Testbash, basher, Nologin (this one user's shell is/sbin/nologin), and then find out the current system on its user name and the default shell of the same user information.
[[email protected] ~]# useradd bash[[email protected] ~]# useradd testbash[[email protected] ~]# useradd Basher[[email Pro Tected] ~]# useradd-s/sbin/nologin nologin[[email protected] ~]# grep-p "^ (\w+):. *\1$"/etc/passwdsync:x:5:0:sync:/sbi N:/bin/syncshutdown:x:6:0:shutdown:/sbin:/sbin/shutdownhalt:x:7:0:halt:/sbin:/sbin/haltbash:x:3008:3008::/home /bash:/bin/bashnologin:x:3011:3011::/home/nologin:/sbin/nologin
This article is from "Bo Zi in the Water" blog, declined to reprint!
Linux Basic Knowledge Four