Linux管理用户和组、正则
ฅ'ω'ฅ♪

Linux管理用户和组、正则

复制/etc/skel目录为/home/tuser1,

要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。

[root@localhost home]# chmod -R 700 tuser1/
[root@localhost home]# ls -ld tuser1/
drwx------. 2 gentoo gentoo 4096 Sep  6 16:53 tuser1/
[root@localhost home]# ls -R tuser1/
tuser1/:
test1
[root@localhost home]# 

编辑/etc/group文件,添加组hadoop。

[root@localhost ~]# tail -1 /etc/gshadow && tail -1 /etc/group
hadoop:!::
hadoop:x:5003:

手动编辑/etc/passwd文件新增一行,添加用户hadoop,其基本组ID为hadoop组的id号;其家目录 为/home/hadoop。

[root@localhost ~]# echo "hadoop:x:600:5004::/home/hadoop:/bin/bash" >> /etc/passwd
[root@localhost ~]# echo "hadoop:hadoop:17772:0:99999:7:::" >> /etc/shadow
[root@localhost ~]# id hadoop
uid=600(hadoop) gid=5004(hadoop) groups=5004(hadoop)

复制/etc/skel目录为/home/hadoop,

要求修改hadoop目录的属组和其它用户没有任何访问权限。

[root@localhost ~]# cp -r /etc/skel /home/hadoop && chown -R hadoop:hadoop -R /home/hadoop
[root@localhost ~]# ls -ld /home/hadoop/
drwxr-xr-x. 4 hadoop hadoop 4096 Sep  6 17:25 /home/hadoop/
[root@localhost ~]# chmod 700 /home/hadoop/      
[root@localhost ~]# ls -ld /home/hadoop/      
drwx------. 4 hadoop hadoop 4096 Sep  6 17:25 /home/hadoop/

修改/home/hadoop目录及其内部所有文件的属主为hadoop,属组为hadoop。

[root@localhost ~]# chown -R hadoop:hadoop /home/hadoop/
[root@localhost ~]# ls -la /home/hadoop/                
total 28
drwx------. 4 hadoop hadoop 4096 Sep  6 17:25 .
drwxr-xr-x. 9 root   root   4096 Sep  6 17:25 ..
-rwx------. 1 hadoop hadoop   18 Sep  6 17:25 .bash_logout
-rwx------. 1 hadoop hadoop  176 Sep  6 17:25 .bash_profile
-rwx------. 1 hadoop hadoop  124 Sep  6 17:25 .bashrc
drwx------. 2 hadoop hadoop 4096 Sep  6 17:25 .gnome2
drwx------. 4 hadoop hadoop 4096 Sep  6 17:25 .mozilla

显示/proc/meminfo文件中以大写或小写S开头的行;

[root@localhost ~]# grep -i "^s" /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       4095992 kB
SwapFree:        4095992 kB
Shmem:              3268 kB
Slab:             111268 kB
SReclaimable:      51960 kB
SUnreclaim:        59308 kB
[root@localhost ~]# grep -E "^(s|S)" /proc/meminfo 
SwapCached:            0 kB
SwapTotal:       4095992 kB
SwapFree:        4095992 kB
Shmem:              3268 kB
Slab:             111248 kB
SReclaimable:      51956 kB
SUnreclaim:        59292 kB

显示/etc/passwd文件中其默认shell为/bin/bash的用户;

[root@localhost ~]# grep "/bin/bash$" /etc/passwd  
root:x:0:0:root:/root:/bin/bash
mike:x:500:500:mike_pang:/home/mike:/bin/bash
tom:x:501:502::/home/tom:/bin/bash
bhps:x:502:503:test:/home/bhps/:/bin/bash
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
jerry:x:503:504::/home/jerry:/bin/bash
weblogic:x:504:505::/home/weblogic:/bin/bash
gentoo:x:505:5001::/users/gentoo:/bin/bash
hadoop:x:600:5004::/home/hadoop:/bin/bash

 

显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行;

[root@localhost ~]# grep -E "^#[[:space:]]+[^[:space:]]+" /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).
# Update quotas if necessary
# Check to see if a full relabel is needed
# 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

打出netstat -tan命令执行结果中以‘LISTEN’,后或跟空白字符结尾的行;

[root@localhost ~]# netstat -tan |grep -E "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 :::22                       :::*                        LISTEN      
tcp        0      0 ::1:631                     :::*                        LISTEN      
tcp        0      0 ::1:25                      :::*   
CANCEL

-评论-

Here you can post what you want to say, if you have more information please contact me by the following way.

-昵称-
-QQ-
-邮箱-
想说些什么?
-SUBMIT-

-电联 Phone-

+86 18520664652

-邮箱 Email-

boogieLing_o@163.com

boogieLing_o@qq.com

Your name. OS platform Browser model

What do you want to say?

created time

游說萬乘苦不早,著鞭跨馬涉遠道。

阿凌的貓爬架

幸會,

激活Ubuntu

转到“设置”以激活Ubuntu。

R0's board.