File system access list:
Facl:filesystem Access Control List
Save additional access control permissions with file extensions
Owner>group>other
Owern>facl,user>group>facl,group>other
Setfacl
-M: Set
U:uid:perm
G:gid:perm
-X: Cancel
U:uid
G:gid
[Email protected] ~]# getfacl/tmp/
Getfacl:removing leading '/' from absolute path names
# file:tmp/
# Owner:root
# Group:root
# Flags:--T
User::rwx
Group::rwx
Other::rwx
[Email protected] backup]# setfacl-m U:HADOOP:RW inittab
[Email protected] backup]# Getfacl Inittab
# File:inittab
# Owner:root
# Group:root
user::rw-
user:hadoop:rw-
group::r--
mask::rw-
other::r--
[Email protected] backup]# setfacl-m G:HIVE:RW inittab
[Email protected] backup]# Getfacl Inittab
# File:inittab
# Owner:root
# Group:root
user::rw-
user:hadoop:rw-
group::r--
group:hive:rw-
mask::rw-
other::r--
[Email protected] backup]# setfacl-m u:hive:rwx inittab
[Email protected] 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--
[Email protected] backup]# setfacl-x g:hive inittab
[Email protected] backup]# Getfacl Inittab
# File:inittab
# Owner:root
# Group:root
user::rw-
user:hadoop:rw-
group::r--
mask::rw-
other::r--
[Email protected] backup]#
WHOAMI: Displays the currently logged on user
[Email protected] backup]# WhoAmI
Root
[Email protected] backup]#
Terminal (terminal, or physical terminal):
is a device, not a program, typically a device that provides a command-line user interface, typically a screen and keyboard, or some other physical terminal.
Virtual Terminal:
Screen and keyboard is only a terminal, may not be enough, and do not want to increase equipment input, resulting in a virtual terminal.
Gnome-terminal,urxvt,mlterm,xterm et cetera:
is a program, the responsibility of the analog terminal, and the difference between the virtual terminal surface is that it appears in the GUI form of the window, the internal program structure and system control structure is different, but essentially similar.
Console:
The terminal that displays the system message is called the console, the Linux default all virtual terminal is the console, can display the system message.
But sometimes it refers to the CLI of the analog terminal equipment, a program, and Gnome-terminal,urxvt,mlterm,xterm, and so on, just the CLI and GUI interface differences. General console has 6, TTY1-6,CTRL+ALT+FN switch. Haven't heard how to change the console.
WHO: Display landing terminal
[Email protected] 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)
[Email protected] backup]#
W: Display user login information, more detailed than who
[Email protected] backup]# W
18:46:50 up 1:07, 3 users, load average:0.03, 0.02, 0.00
USER TTY from [email protected] IDLE jcpu PCPU
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: Show Historical login information
[Email protected] backup]# last
Rhel pts/1 192.168.1.18 Fri Feb 17:42 still logged in
Rhel pts/0 192.168.1.18 Fri Feb 17:40 still logged in
Rhel tty1:0 Fri Feb 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 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 17:54-crash (89+23:45)
Rhel tty1:0 Sat Nov 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 June 22:04-crash (512+20:49)
Rhel PTS/1 10.4.10.236 Thu June 25 21:21-21:21 (00:00)
Rhel PTS/1 10.4.10.236 Thu June 25 21:20-21:20 (00:00)
[Email protected] backup]# Last-n 3
Rhel pts/1 192.168.1.18 Fri Feb 17:42 still logged in
Rhel pts/0 192.168.1.18 Fri Feb 17:40 still logged in
Rhel tty1:0 Fri Feb 17:40 still logged in
Wtmp begins Sun June 21 02:26:29 2015
[Email protected] backup]#
Lastlog: Displays information about the last successful login for all users
[Email protected] backup]# lastlog-u Hadoop
Username Port from Latest
Hadoop **never logged in**
[Email protected] backup]#
[Email protected] backup]# Lastlog
Username Port from Latest
Root PTS/1 10.4.10.226 Thu June 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**
[Email protected] backup]# basename/etc/abc/me
Me
[Email protected] backup]#
[Email protected] backup]# Cat/etc/fstab | Mail-s "How is you?" root
[[Email protected] 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 19:04 32/1406 "How is it?"
& 1
Message 1:
From [email protected] Fri 17 19:04:58 2017
Return-path: <[email protected]>
X-original-to:root
delivered-to: [Email protected]
Date:fri, 2017 19:04:58-0800
To: [Email protected]
Subject:how is you?
User-agent:heirloom MAILX 12.4 7/29/08
Content-type:text/plain; Charset=us-ascii
From: [Email protected] (root)
Status:r
#
#/etc/fstab
# Created by Anaconda on Sun June 21 02:15:00 2015
#
# Accessible filesystems, by reference, is maintained under '/dev/disk '
# See mans 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
[Email protected] backup]#
[Email protected] backup]#
[Email protected] backup]# Mail-s "How is it?" Root </etc/fstab
[[Email protected] 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 19:04 33/1417 "How is it?"
2 root Fri Feb 19:06 33/1417 "How is it?"
3 root Fri Feb 19:06 33/1417 "How is it?"
>n 4 root Fri Feb 19:06 32/1406 "How is it?"
& 4
Message 4:
From [email protected] Fri 17 19:06:45 2017
Return-path: <[email protected]>
X-original-to:root
delivered-to: [Email protected]
Date:fri, 2017 19:06:45-0800
To: [Email protected]
Subject:how is you?
User-agent:heirloom MAILX 12.4 7/29/08
Content-type:text/plain; Charset=us-ascii
From: [Email protected] (root)
Status:r
#
#/etc/fstab
# Created by Anaconda on Sun June 21 02:15:00 2015
#
# Accessible filesystems, by reference, is maintained under '/dev/disk '
# See mans 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
[Email protected] backup]#
[Email protected] backup]# hostname Cxiong
[Email protected] backup]# hostname
Cxiong
[Email protected] backup]# echo $HOSTNAME
localhost
[Email protected] backup]#
Generate random numbers
random:0-32768
Random number generator: Entropy pool
/dev/random: If the entropy pool is empty, the process is blocked
/dev/urandom: If the entropy pool is empty, the process is not blocked
[Email protected] ~]#!bash
Bash random.sh
1:12,418
2:11,349
3:26,745
4:11,226
5:8,126
6:5,194
7:3,741
8:8,878
9:13,050
10:10,280
The Max random is:26745
The min random is:3741
[email protected] ~]# cat random.sh
#!/bin/bash
Declare-i max=0
Declare-i min=0
For i in {1..10};d o
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"
[Email protected] ~]#
Case statement: Select structure
Case switch in (switch is a value)
value1)
Statement
...
;; (The statement ends with a double semicolon)
value2)
Statement
...
;;
*)
Statement
...
;;
ESAC (Esac end)
[email protected] ~]# cat case.sh
#!/bin/bash
Case $ in
[0-9])
echo "digit";;
[A-z])
echo "Zimu";;
*)
echo "Else";;
Esac
[Email protected] ~]#
Linux-facl,whoami,who,w,last,lastlog,basename,mail,hostname, $random, Case statement