文件系统访问列表:
FACL:Filesystem Access Control List
利用文件扩展保存额外的访问控制权限
owner>group>other
Owern>facl,user>group>facl,group>other
setfacl
-m: 设定
u:UID:perm
g:GID:perm
-x:取消
u:UID
g:GID
[root@localhost ~]# getfacl /tmp/
getfacl: Removing leading ‘/‘ from absolute path names
# file: tmp/
# owner: root
# group: root
# flags: --t
user::rwx
group::rwx
other::rwx
[root@localhost backup]# setfacl -m u:hadoop:rw inittab
[root@localhost backup]# getfacl inittab
# file: inittab
# owner: root
# group: root
user::rw-
user:hadoop:rw-
group::r--
mask::rw-
other::r--
[root@localhost backup]# setfacl -m g:hive:rw inittab
[root@localhost backup]# getfacl inittab
# file: inittab
# owner: root
# group: root
user::rw-
user:hadoop:rw-
group::r--
group:hive:rw-
mask::rw-
other::r--
[root@localhost backup]# setfacl -m u:hive:rwx inittab
[root@localhost backup]# getfacl inittab
# file: inittab
# owner: root
# group: root
user::rw-
user:hadoop:rw-
user:hive:rwx
group::r--
group:hive:rw-
mask::rwx
other::r--
[root@localhost backup]# setfacl -x g:hive inittab
[root@localhost backup]# getfacl inittab
# file: inittab
# owner: root
# group: root
user::rw-
user:hadoop:rw-
group::r--
mask::rw-
other::r--
[root@localhost backup]#
whoami:显示当前登录用户
[root@localhost backup]# whoami
root
[root@localhost backup]#
终端(terminal,或者叫物理终端):
是一种设备,不是一个程序,一般说的就是能提供命令行用户界面的设备,典型的是屏幕和键盘,或其他的一些物理终端。
虚拟终端:
屏幕和键盘只是一个终端,可能不够用,又不想增加设备投入,就产生了虚拟终端。
gnome-terminal,urxvt,mlterm,xterm等等:
是一个程序,职责是模拟终端设备,和虚拟终端的区别表面上在于它以 GUI 形式的窗口出现,内部则是程序结构和系统控制结构有所不同,但本质上差不多。
控制台(console):
显示系统消息的终端就叫控制台,Linux 默认所有虚拟终端都是控制台,都能显示系统消息。
但有时专指CLI下的模拟终端设备的一个程序,和gnome-terminal,urxvt,mlterm,xterm等相同,只是CLI和GUI界面的区别。一般console有6个,tty1-6,CTRL+ALT+fn切换。还没听说过怎么换console
who:显示登陆终端
[root@localhost backup]# who -H
NAME LINE TIME COMMENT
rhel tty1 2017-02-17 17:40 (:0)
rhel pts/0 2017-02-17 17:40 (192.168.1.18)
rhel pts/1 2017-02-17 17:42 (192.168.1.18)
[root@localhost backup]#
w:显示用户登录信息,比who更详细
[root@localhost backup]# w
18:46:50 up 1:07, 3 users, load average: 0.03, 0.02, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
rhel tty1 :0 17:40 1:07m 1.71s 0.16s pam: gdm-password
rhel pts/0 192.168.1.18 17:40 0.00s 0.21s 0.17s sshd: rhel [priv]
rhel pts/1 192.168.1.18 17:42 22.00s 0.02s 0.15s sshd: rhel [priv]
last:显示历史登陆信息
[root@localhost backup]# last
rhel pts/1 192.168.1.18 Fri Feb 17 17:42 still logged in
rhel pts/0 192.168.1.18 Fri Feb 17 17:40 still logged in
rhel tty1 :0 Fri Feb 17 17:40 still logged in
reboot system boot 2.6.32-504.el6.x Fri Feb 17 17:39 - 18:48 (01:08)
rhel pts/2 192.168.1.18 Sat Nov 19 22:13 - crash (89+19:26)
rhel pts/1 192.168.1.18 Sat Nov 19 21:31 - 00:13 (02:42)
rhel pts/0 192.168.1.18 Sat Nov 19 18:17 - 23:30 (05:12)
rhel tty2 Sat Nov 19 17:54 - crash (89+23:45)
rhel tty1 :0 Sat Nov 19 17:54 - crash (89+23:45)
reboot system boot 2.6.32-504.el6.x Sat Nov 19 17:54 - 18:48 (90+00:53)
rhel tty6 Thu Jun 25 22:04 - crash (512+20:49)
rhel pts/1 10.4.10.236 Thu Jun 25 21:21 - 21:21 (00:00)
rhel pts/1 10.4.10.236 Thu Jun 25 21:20 - 21:20 (00:00)
[root@localhost backup]# last -n 3
rhel pts/1 192.168.1.18 Fri Feb 17 17:42 still logged in
rhel pts/0 192.168.1.18 Fri Feb 17 17:40 still logged in
rhel tty1 :0 Fri Feb 17 17:40 still logged in
wtmp begins Sun Jun 21 02:26:29 2015
[root@localhost backup]#
lastlog:显示所有用户最近一次成功登陆的信息
[root@localhost backup]# lastlog -u hadoop
Username Port From Latest
hadoop **Never logged in**
[root@localhost backup]#
[root@localhost backup]# lastlog
Username Port From Latest
root pts/1 10.4.10.226 Thu Jun 25 14:24:23 -0700 2015
bin **Never logged in**
daemon **Never logged in**
adm **Never logged in**
lp **Never logged in**
sync **Never logged in**
shutdown **Never logged in**
halt **Never logged in**
[root@localhost backup]# basename /etc/abc/me
me
[root@localhost backup]#
[root@localhost backup]# cat /etc/fstab | mail -s "how are you?" root
[root@localhost backup]# mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root Fri Feb 17 19:04 32/1406 "how are you?"
& 1
Message 1:
From root@localhost.localdomain Fri Feb 17 19:04:58 2017
Return-Path: <root@localhost.localdomain>
X-Original-To: root
Delivered-To: root@localhost.localdomain
Date: Fri, 17 Feb 2017 19:04:58 -0800
To: root@localhost.localdomain
Subject: how are you?
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
From: root@localhost.localdomain (root)
Status: R
#
# /etc/fstab
# Created by anaconda on Sun Jun 21 02:15:00 2015
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=57d85756-7680-4c7c-9125-6ad67dae2c45 / ext4 defaults 1 1
UUID=2622a4b4-ddc9-47a3-aa2b-f06bc9bec085 /boot ext4 defaults 1 2
UUID=33d94759-fa01-4c4f-b4ac-bf3a1fe5e84f swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
& q
Held 1 message in /var/spool/mail/root
[root@localhost backup]#
[root@localhost backup]#
[root@localhost backup]# mail -s "how are you?" root < /etc/fstab
[root@localhost backup]# mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/root": 4 messages 1 new
1 root Fri Feb 17 19:04 33/1417 "how are you?"
2 root Fri Feb 17 19:06 33/1417 "how are you?"
3 root Fri Feb 17 19:06 33/1417 "how are you?"
>N 4 root Fri Feb 17 19:06 32/1406 "how are you?"
& 4
Message 4:
From root@localhost.localdomain Fri Feb 17 19:06:45 2017
Return-Path: <root@localhost.localdomain>
X-Original-To: root
Delivered-To: root@localhost.localdomain
Date: Fri, 17 Feb 2017 19:06:45 -0800
To: root@localhost.localdomain
Subject: how are you?
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
From: root@localhost.localdomain (root)
Status: R
#
# /etc/fstab
# Created by anaconda on Sun Jun 21 02:15:00 2015
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=57d85756-7680-4c7c-9125-6ad67dae2c45 / ext4 defaults 1 1
UUID=2622a4b4-ddc9-47a3-aa2b-f06bc9bec085 /boot ext4 defaults 1 2
UUID=33d94759-fa01-4c4f-b4ac-bf3a1fe5e84f swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
& q
Held 4 messages in /var/spool/mail/root
[root@localhost backup]#
[root@localhost backup]# hostname cxiong
[root@localhost backup]# hostname
cxiong
[root@localhost backup]# echo $HOSTNAME
localhost
[root@localhost backup]#
生成随机数
RANDOM: 0-32768
随机数生成器:熵池
/dev/random:如果熵池为空,则会阻塞进程
/dev/urandom:如果熵池为空,则不会阻塞进程
[root@localhost ~]# !bash
bash random.sh
1:12418
2:11349
3:26745
4:11226
5:8126
6:5194
7:3741
8:8878
9:13050
10:10280
the max random is:26745
the min random is:3741
[root@localhost ~]# cat random.sh
#!/bin/bash
declare -i max=0
declare -i min=0
for i in {1..10};do
tmp=`echo "$RANDOM"`
echo "$i:$tmp"
if [ $i -eq 1 ];then
min=$tmp
max=$tmp
else
if [ $tmp -gt $max ];then
max=$tmp
elif [ $tmp -lt $min ];then
min=$tmp
fi
fi
done
echo "the max random is:$max"
echo "the min random is:$min"
[root@localhost ~]#
case语句:选择结构
case SWITCH in (SWITCH为值)
value1)
statement
...
;; (语句以双分号结尾)
value2)
statement
...
;;
*)
statement
...
;;
esac (esac结尾)
[root@localhost ~]# cat case.sh
#!/bin/bash
case $1 in
[0-9] )
echo "digit";;
[a-Z] )
echo "zimu";;
*)
echo "else";;
esac
[root@localhost ~]#
linux-facl,whoami,who,w,last,lastlog,basename,mail,hostname,$random,case语句
原文地址:http://f1yinsky.blog.51cto.com/12568071/1900396