單純提供一個相對的解答,並不是標準答案!
單純就是個解答的參考,寫完之後再來這邊查查看答案跟你想的一樣不一樣!?
[root@station10-101 ~]# man cut DESCRIPTION Print selected parts of lines from each FILE to standard output. With no FILE, or when FILE is -, read standard input. Mandatory arguments to long options are mandatory for short options too. -b, --bytes=LIST select only these bytes -c, --characters=LIST select only these characters -d, --delimiter=DELIM use DELIM instead of TAB for field delimiter -f, --fields=LIST select only these fields; also print any line that contains no delimiter character, unless the -s option is specified [root@station10-101 ~]# cut -d ':' -f 1,7 /etc/passwd root:/bin/bash bin:/sbin/nologin daemon:/sbin/nologin ....... theuser3:/bin/bash theuser1:/bin/bash
[root@station10-101 ~]# cut -d ':' -f 1,7 /etc/passwd | grep daemon
daemon:/sbin/nologin
是 /sbin/nologin 這個 shell 喔![student@station10-101 ~]$ su - Password: [root@station10-101 ~]# yum install tcsh Last metadata expiration check: 0:06:47 ago on Mon 13 Apr 2020 08:46:53 AM CST. Dependencies resolved. ===================================================================================================== Package Architecture Version Repository Size ===================================================================================================== Installing: tcsh x86_64 6.20.00-9.el8 AppStream 452 k Transaction Summary ===================================================================================================== Install 1 Package Total download size: 452 k Installed size: 1.2 M Is this ok [y/N]: y Downloading Packages: tcsh-6.20.00-9.el8.x86_64.rpm 1.5 MB/s | 452 kB 00:00 ---------------------------------------------------------------------------------------------------- Total 386 kB/s | 452 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : tcsh-6.20.00-9.el8.x86_64 1/1 Running scriptlet: tcsh-6.20.00-9.el8.x86_64 1/1 Verifying : tcsh-6.20.00-9.el8.x86_64 1/1 Installed: tcsh-6.20.00-9.el8.x86_64 Complete! [root@station10-101 ~]# exit logout
[student@station10-101 ~]$ echo $BASH /bin/bash [student@station10-101 ~]$ echo $shell [student@station10-101 ~]$ echo $0 -bash可以看得出來, bash 環境下,會具有 $BASH 以及 $0 的兩個變數,都是指令名稱!
[student@station10-101 ~]$ /bin/csh [student@station10-101 ~]$ echo $BASH BASH: Undefined variable. [student@station10-101 ~]$ echo $shell /usr/bin/tcsh [student@station10-101 ~]$ echo $0 /bin/csh [student@station10-101 ~]$ exit exit [student@station10-101 ~]$ echo $0 -bash可以看到呈現的效果不太一樣~這就是 C shell 囉
[student@station10-101 ~]$ /sbin/nologin
This account is currently not available.
也就是說, /sbin/nologin 其實是一個怪怪的 shell 喔![student@station10-101 ~]$ su - Password: [root@station10-101 ~]# grep student /etc/passwd student:x:1000:1000:student:/home/student:/bin/bash [root@station10-101 ~]# usermod -s /sbin/nologin student [root@station10-101 ~]# grep student /etc/passwd student:x:1000:1000:student:/home/student:/sbin/nologin可以看到使用者 student 的 shell 變成 nologin 了!
[root@station10-101 ~]# usermod -s /bin/bash student [root@station10-101 ~]# grep student /etc/passwd student:x:1000:1000:student:/home/student:/bin/bash
[root@station10-101 ~]# id bin uid=1(bin) gid=1(bin) groups=1(bin) [root@station10-101 ~]# id student uid=1000(student) gid=1000(student) groups=1000(student)可以看到兩者的 UID 號碼差異很大!一般來說,小於 1000 以下的 uid,通常是保留給系統使用的,因此, bin 這個帳號, 應該就是所謂的『系統帳號』,這種帳號是不能登入才對的!
[root@station10-101 ~]# su - bin This account is currently not available. [root@station10-101 ~]# grep '^bin' /etc/passwd bin:x:1:1:bin:/bin:/sbin/nologin不能切換成為 bin 這個用戶,因為他的 shell 是 /sbin/nologin!
[root@station10-101 ~]# useradd -s /sbin/nologin puser1 [root@station10-101 ~]# echo MyPuser1 | passwd --stdin puser1 更改使用者 puser1 的密碼。 passwd:所有核對代符都已成功更新。 [root@station10-101 ~]# grep puser1 /etc/passwd puser1:x:1007:1009::/home/puser1:/sbin/nologin這樣就具有無法取得互動 shell 的帳號!要注意,這種帳號雖然無法取得 shell,但是依舊可以使用 ftp / email / web service 等功能! 所以還是得注意其密碼狀態喔!
# A. 設定變數 [root@station10-101 ~]# myname=peter pan <==這是錯誤的,不能直接有空白 bash: pan: 找不到指令... [root@station10-101 ~]# myname="peter pan" <==加上雙引號/單引號就可以! # B. 呼叫變數內容 [root@station10-101 ~]# echo $myname peter pan [root@station10-101 ~]# echo ${myname} peter pan # 兩種方法都可以呼叫順利! # C. 測試數字開頭的變數 [root@station10-101 ~]# 2myname="peter pan" bash: 2myname=peter pan: 找不到指令... # 不行喔!變數名稱不能以數字開頭! # D. 這個在測試單引號與雙引號的用途! [root@station10-101 ~]# varsymbo="$myname" [root@station10-101 ~]# echo $varsymbo peter pan [root@station10-101 ~]# varsymbo='$myname' [root@station10-101 ~]# echo $varsymbo $myname # 雙引號會保留 $var 變數的內容,而單引號會將 $ 視為純文字來處理~ # E. 使用雙引號處理變數內容的疊代 [root@station10-101 ~]# hero="I am $myname" [root@station10-101 ~]# echo ${hero} I am peter pan # 這個例子就得要使用雙引號才合理了! # F. 核心版本呼叫方式 [root@station10-101 ~]# uname -r 4.18.0-147.el8.x86_64 # G. 變數內藏著指令的協助 [root@station10-101 ~]# kver="my kernel version is uname -r" [root@station10-101 ~]# echo $kver my kernel version is uname -r [root@station10-101 ~]# kver="my kernel version is $(uname -r)" [root@station10-101 ~]# echo $kver my kernel version is 4.18.0-147.el8.x86_64 # 可以將 $() 想成四則運算的括號,要先做的意思~
[root@station10-101 ~]# man find ...... -perm mode File's permission bits are exactly mode (octal or symbolic). # 權限要剛剛好,例如 -perm 755,就是找出權限一定是 755 -perm -mode All of the permission bits mode are set for the file. # 權限必須包含全部,例如 -perm -644 時,連 755 也會被抓出來! -perm /mode Any of the permission bits mode are set for the file. # 權限可以是任何一個,例如 -perm /755 代表 rwxr-xr-x 當中任一個出現都行!
[root@station10-101 ~]# find /usr/bin /usr/sbin -perm /6000
/usr/bin/fusermount
/usr/bin/chage
/usr/bin/gpasswd
......
/usr/sbin/lockdev
/usr/sbin/mount.nfs
[root@station10-101 ~]# ls -l $(find /usr/bin /usr/sbin -perm /6000)
-rwsr-xr-x. 1 root root 61688 5月 11 2019 /usr/bin/at
-rwsr-xr-x. 1 root root 133928 11月 9 07:05 /usr/bin/chage
-rws--x--x. 1 root root 48896 11月 9 07:28 /usr/bin/chfn
......
-rwsr-xr-x. 1 root root 13376 5月 11 2019 /usr/sbin/pam_timestamp_check
-rwsr-xr-x. 1 root root 40080 5月 11 2019 /usr/sbin/unix_chkpwd
-rws--x--x. 1 root root 47424 5月 11 2019 /usr/sbin/userhelper
你可以看到每個指令都有 s 出現在權限的旗標裡面!# A. 找出適當的檔名: [root@station10-101 ~]# ll $(find /usr/sbin /usr/bin -perm 4755) -rwsr-xr-x. 1 root root 61688 5月 11 2019 /usr/bin/at -rwsr-xr-x. 1 root root 133928 11月 9 07:05 /usr/bin/chage ...... -rwsr-xr-x. 1 root root 13376 5月 11 2019 /usr/sbin/pam_timestamp_check -rwsr-xr-x. 1 root root 40080 5月 11 2019 /usr/sbin/unix_chkpwd # 確實每一個都是 4755 的權限資料! # B.C. 建立目錄後,將檔案複製過去 [root@station10-101 ~]# mkdir /root/findfile [root@station10-101 ~]# cp -a $(find /usr/sbin /usr/bin -perm 4755) /root/findfile/ [root@station10-101 ~]# ll /root/findfile/ 總計 1036 -rwsr-xr-x. 1 root root 61688 5月 11 2019 at -rwsr-xr-x. 1 root root 133928 11月 9 07:05 chage ...... -rwsr-xr-x. 1 root root 40728 11月 9 07:28 umount -rwsr-xr-x. 1 root root 40080 5月 11 2019 unix_chkpwd
# a. 印出 PATH 變數內容 [root@station10-101 ~]# echo ${PATH} /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin # 使用冒號分隔,每個間隔都是指令搜尋的路徑,先找到就先執行! # b. 將原有的設定先備份下來之意: [root@station10-101 ~]# oldpath=${PATH} [root@station10-101 ~]# echo ${oldpath} /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin # c. 這題在假設 PATH 設定錯誤的情況,要注意,至少含有 /bin 才行! [root@station10-101 ~]# PATH=/bin [root@station10-101 ~]# echo ${PATH} /bin # d. 開始執行管理員的專用指令,亦即放置到 /sbin 底下的指令: [root@station10-101 ~]# useradd --help bash: useradd: 找不到指令... 相似指令為: 'useradd' [root@station10-101 ~]# usermod --help bash: usermod: 找不到指令... 是否要安裝「shadow-utils」軟體包以提供「usermod」指令? [N/y] n # 反正,就是讓你無法順利執行位於 /sbin 底下的指令!所以, PATH 真是好重要! # e. 開始使用絕對路徑來執行,不要使用 PATH 的功能,就寫絕對路徑吧! [root@station10-101 ~]# /sbin/usermod --help Usage: usermod [options] LOGIN Options: -c, --comment COMMENT new value of the GECOS field ...... # f. 測試完畢之後,請力即將 PATH 改回來,不然會出問題喔! [root@station10-101 ~]# PATH=${oldpath} [root@station10-101 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@station10-101 ~]# useradd --help Usage: useradd [options] LOGIN useradd -D useradd -D [options] ......這個題目在告訴我們,PATH 就是所有指令的來源!它相當重要啊!而如果你要使用某個指令, 若不想被 PATH 所制約,那麼使用絕對路徑,大概是你唯一可以做的事情!很重要!很重要!
# a. 建立 student 的個人化專用目錄 [student@station10-101 ~]$ mkdir cmd [student@station10-101 ~]$ cp /bin/cat cmd/scat [student@station10-101 ~]$ ll cmd total 52 -rwxr-xr-x. 1 student student 51856 Apr 15 08:34 scat # 這個動作其實在模仿自己建立一隻指令在 ~/cmd/scat 的意思而已!我們使用 cat 為例! # b. 測試執行指令是正常的,就用絕對路徑/相對路徑檔名吧! [student@station10-101 ~]$ ./cmd/scat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 # 確定指令可以正常輸出喔! # c. 測試 scat 是否可以通過預設 PATH 的搜尋找到? [student@station10-101 ~]$ scat /etc/hosts bash: scat: command not found... Similar commands are:: 'zcat' 'cat' # d. 重點來了!累加 PATH 的功能在這裡!很重要! [student@station10-101 ~]$ PATH=${PATH}:~/cmd [student@station10-101 ~]$ echo $PATH /home/student/.local/bin:/home/student/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/student/cmd [student@station10-101 ~]$ scat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6你就知道 PATH 真是很重要了!
[student@station10-101 ~]$ echo $PS1
[\u@\h \W]\$
你可以發現,命令提示字元『 [student@station10-101 ~]$ 』與 PS1 『 [\u@\h \W]\$ 』格式幾乎一模一樣!沒錯,
因為提示字元就是由 PS1 所設定的!
[student@station10-101 ~]$ man bash
......
\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue May 26")
\D{format}
the format is passed to strftime(3) and the result is inserted into the prompt string;
an empty format results in a locale-specific time representation. The braces are required
\e an ASCII escape character (033)
\h the hostname up to the first `.'
\H the hostname
\j the number of jobs currently managed by the shell
\l the basename of the shell's terminal device name
\n newline
\r carriage return
\s the name of the shell, the basename of $0 (the portion following the final slash)
\t the current time in 24-hour HH:MM:SS format
\T the current time in 12-hour HH:MM:SS format
\@ the current time in 12-hour am/pm format
\A the current time in 24-hour HH:MM format
\u the username of the current user
\v the version of bash (e.g., 2.00)
\V the release of bash, version + patch level (e.g., 2.00.0)
\w the current working directory, with $HOME abbreviated with a tilde (uses the value of the PROMPT_DIRTRIM variable)
\W the basename of the current working directory, with $HOME abbreviated with a tilde
\! the history number of this command
\# the command number of this command
\$ if the effective UID is 0, a #, otherwise a $
\nnn the character corresponding to the octal number nnn
\\ a backslash
\[ begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
\] end a sequence of non-printing characters
......
[student@station10-101 ~]$ PS1="[\u@\h \# \W]\$" [student@station10-101 13 ~]$
# a. 列出變數來搜尋特定內容 [student@station10-101 17 ~]$ set | grep mypp [student@station10-101 18 ~]$ env | grep mypp [student@station10-101 19 ~]$ export | grep mypp # set 可以列出全部變數 (區域、全域), env / export 只能列出全域變數 # b. 設定變數 [student@station10-101 20 ~]$ mypp="from_ppid" [student@station10-101 21 ~]$ echo ${mypp} from_ppid # c. 檢測是區域還是全域變數? [student@station10-101 22 ~]$ set | grep mypp mypp=from_ppid [student@station10-101 23 ~]$ env | grep mypp [student@station10-101 24 ~]$ export | grep mypp所以這個變數 mypp 目前是『區域變數』的意思!
# a.b. 進入子程序,並查看 mypp 是否存在? [student@station10-101 25 ~]$ bash [student@station10-101 ~]$ set | grep mypp [student@station10-101 ~]$ env | grep mypp [student@station10-101 ~]$ export | grep mypp # 其實,只有全域變數的值才會繼承給子程序!所以剛剛的 mypp 這個區域變數,不會傳給子程序 # c.d. 建立子程序內的變數,並且回到父程序 [student@station10-101 ~]$ mypp2="from_cpid" [student@station10-101 ~]$ echo ${mypp2} from_cpid [student@station10-101 ~]$ exit exit [student@station10-101 26 ~]$區域變數沒有辦法傳給子程序的!
# a. 一定找不到子程序所設定的變數!因為是不同的程序啊! [student@station10-101 27 ~]$ echo $mypp2 # b. 將區域變數改成全域變數!很簡單,使用 export 即可! [student@station10-101 28 ~]$ export mypp [student@station10-101 29 ~]$ export | grep mypp declare -x mypp="from_ppid" [student@station10-101 30 ~]$ set | grep mypp mypp=from_ppid [student@station10-101 31 ~]$ env | grep mypp mypp=from_ppid基本上, set 列出所有變數,包括區域與全域,env 與 export 只列出全域變數!
[student@station10-101 32 ~]$ bash [student@station10-101 ~]$ env | grep mypp mypp=from_ppid [student@station10-101 ~]$ echo ${mypp} from_ppid [student@station10-101 ~]$ exit exit [student@station10-101 33 ~]$許多程式都有所謂的區域/全域變數的設定概念,當你某個變數要讓整體程式庫全部都使用時,就得要在父程序設定成為全域變數, 然後子程序才有辦法繼承的意思!
# A.B. 將 vim 指令丟到背景,並查看 job number 與 pid [student@station10-101 43 ~]$ vim checking.txt abc [ctrl]+z [1]+ Stopped vim checking.txt [student@station10-101 44 ~]$ jobs -l [1]+ 14289 Stopped vim checking.txt # C. 嘗試『正常刪除』該程序 [student@station10-101 45 ~]$ kill 14289 [student@station10-101 46 ~]$ jobs -l [1]+ 14289 Stopped vim checking.txt [student@station10-101 47 ~]$ kill %1 [1]+ Stopped vim checking.txt [student@station10-101 48 ~]$ jobs -l [1]+ 14289 Stopped (tty output) vim checking.txt # 使用 kill 可以刪除 PID (不加 %),或加上 %n 去刪除 n 號工作! # 然後,正常情況下,使用 -15 這個正常訊號,是無法結束背景中的 vim 的! # D. 嘗試使用強迫刪除 [student@station10-101 49 ~]$ kill -9 %1 [1]+ Stopped vim checking.txt [student@station10-101 50 ~]$ jobs -l [1]+ 14289 Killed vim checking.txt # E. 再次編輯看看: [student@station10-101 52 ~]$ vim checking.txt E325: ATTENTION Found a swap file by the name ".checking.txt.swp" <==這裡!!! owned by: student dated: Wed Apr 15 09:24:37 2020 file name: ~student/checking.txt modified: YES user name: student host name: station10-101.gocloud.vm process ID: 14289 While opening file "checking.txt" (1) Another program may be editing the same file. If this is the case, be careful not to end up with two different instances of the same file when making changes. Quit, or continue with caution. (2) An edit session for this file crashed. If this is the case, use ":recover" or "vim -r checking.txt" to recover the changes (see ":help recovery"). If you did this already, delete the swap file ".checking.txt.swp" to avoid this message. Swap file ".checking.txt.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: R abc # 然後不儲存強制離開! :q! [student@station10-101 71 ~]$ ll -a .checking.txt.swp -rw-------. 1 student student 12288 Apr 15 09:24 .checking.txt.swp [student@station10-101 72 ~]$ rm .checking.txt.swp事實上, vim 會建立很多編輯過程中的暫存檔,如果曾經編輯檔案到一半當掉,可以透過 r 來復原,否則就按 d 結束掉該檔案即可!
[student@station10-101 74 ~]$ cat ~/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
事實上,只有讀取家目錄的 .bashrc 而已!在來看 .bashrc 的內容:
if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific environment PATH="$HOME/.local/bin:$HOME/bin:$PATH" export PATH額外去呼叫 /etc/bashrc 這個檔案,這個檔案如果你用 vim 去看,裡面還有這一段:
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
又讀入不少設定檔,大多在 /etc/profile.d 目錄內的設定檔!這就是每個用戶登入時,都會去處理的整體流程![student@station10-101 78 ~]$ vim ~/.bashrc HISTSIZE=10000 alias cp="cp -i" alias rm="rm -i" alias mv="mv -i" PATH=${PATH}:~/cmd kver=$( uname -r ) export LANG=zh_TW.utf8 PS1="[\u@\h \A \# \W]$ " h_start=$( wc -l ~/.bash_history | awk '{print $1}' ) [student@station10-101 78 ~]$ source ~/.bashrc [student@station10-101 10:03 84 ~]$ echo $h_start 555 [student@station10-101 10:04 85 ~]$ echo $HISTSIZE 10000 [student@station10-101 10:04 86 ~]$ echo $PATH /home/student/.local/bin:/home/student/bin:/home/student/.local/bin:/home/student/bin: /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/student/cmd:/home/student/cmd [student@station10-101 10:04 87 ~]$ echo $kver 4.18.0-147.el8.x86_64
[student@station10-101 10:04 88 ~]$ vim .bash_logout date +%Y/%m/%d" "%H:%M >> ~/history.log h_end=$( history | wc -l ) h_now=$(( $h_end - $h_start +1 )) history $h_now >&tt; ~/history.log [root@station10-101 ~]# su - student [student@station10-101 10:10 1 ~]$ cat .bash_logout [student@station10-101 10:11 2 ~]$ echo $kver [student@station10-101 10:11 3 ~]$ exit [root@station10-101 ~]# cat ~student/history.log 2020/04/15 10:11 643 exit 644 cat .bash_logout 645 echo $kver 646 exit每次登入 student 的 login shell 環境下,這個 history.log 的檔案都會長大喔!
# a. 合法的 shell 都在 /etc/shells 當中,所以可以這樣做: [root@station10-101 ~]# vim /etc/shells ...... /usr/bin/csh /usr/bin/tcsh /sbin/nologin /bin/false /bin/true [root@station10-101 ~]# chsh -l ...... /sbin/nologin /bin/false /bin/true # b. 就是找到最後面出現 /bin/bash 的那個帳號即可 [root@station10-101 ~]# grep '/bin/bash' /etc/passwd root:x:0:0:root:/root:/bin/bash student:x:1000:1000:student:/home/student:/bin/bash prouser1:x:1001:1002::/home/prouser1:/bin/bash ...... # c. 全域變數可用 env 或 export 查閱 [root@station10-101 ~]# export declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/0/bus" declare -x HISTCONTROL="ignoredups" declare -x HISTSIZE="1000" ...... # d.e. 呼叫出 PS1 變數,然後修改 [root@station10-101 ~]# echo $PS1 [\u@\h \W]\$ [root@station10-101 ~]# PS1='C:\\win> ' C:\win> C:\win> PS1='[\u@\h \W]\$ ' [root@station10-101 ~]# # f.g. 延伸 PATH 的內容 [root@station10-101 ~]# echo ${PATH} /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@station10-101 ~]# PATH=${PATH}:/opt/bin [root@station10-101 ~]# echo ${PATH} /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/bin # h. 以子指令設定好變數內容 [root@station10-101 ~]# kver=$( uname -r ) [root@station10-101 ~]# echo $kver 4.18.0-147.el8.x86_64 # i. 設定 kver 為全域變數 [root@station10-101 ~]# export | grep kver [root@station10-101 ~]# export kver [root@station10-101 ~]# export | grep kver declare -x kver="4.18.0-147.el8.x86_64" # j. 查詢 signal [root@station10-101 ~]# man 7 signal ...... Signal Value Action Comment ─────────────────────────────────── SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process SIGINT 2 Term Interrupt from keyboard SIGQUIT 3 Core Quit from keyboard SIGILL 4 Core Illegal Instruction SIGABRT 6 Core Abort signal from abort(3) SIGFPE 8 Core Floating-point exception SIGKILL 9 Term Kill signal SIGSEGV 11 Core Invalid memory reference SIGPIPE 13 Term Broken pipe: write to pipe with no readers; see pipe(7) SIGALRM 14 Term Timer signal from alarm(2) SIGTERM 15 Term Termination signal SIGUSR1 30,10,16 Term User-defined signal 1 SIGUSR2 31,12,17 Term User-defined signal 2 SIGCHLD 20,17,18 Ign Child stopped or terminated SIGCONT 19,18,25 Cont Continue if stopped SIGSTOP 17,19,23 Stop Stop process SIGTSTP 18,20,24 Stop Stop typed at terminal SIGTTIN 21,21,26 Stop Terminal input for background process SIGTTOU 22,22,27 Stop Terminal output for background process ...... # 這功能有點類似重新載入 (reload) 的感覺! # k. 手動變更 PID 的 hangup (reload) 功能 [root@station10-101 ~]# ps aux | grep rsyslog root 1247 0.0 0.3 208752 6236 ? Ssl 10:50 0:00 /usr/sbin/rsyslogd -n root 3241 0.0 0.0 12108 1084 pts/0 S+ 11:47 0:00 grep --color=auto rsyslog [root@station10-101 ~]# date 三 4月 15 11:47:42 CST 2020 [root@station10-101 ~]# kill -1 1247 [root@station10-101 ~]# ps aux | grep rsyslog root 1247 0.0 0.3 208752 6236 ? Ssl 10:50 0:00 /usr/sbin/rsyslogd -n root 3244 0.0 0.0 12108 984 pts/0 S+ 11:47 0:00 grep --color=auto rsyslog # PID 號碼沒改變,所以依舊是原本那隻 PID!只是可能狀態被改變而已! # l. 查看登錄檔資訊 [root@station10-101 ~]# tail -n 2 /var/log/messages Apr 15 11:47:51 station10-101 rsyslogd[1247]: [origin software="rsyslogd" swVersion="8.37.0-13.el8" x-pid="1247" x-info="http://www.rsyslog.com"] rsyslogd was HUPed # m.n.o. 直接開另一個視窗並啟用 vim 軟體,假設完成後,查閱該軟體之後處理 [root@station10-101 ~]# ps aux | grep vim root 3283 0.1 0.4 48188 8288 tty2 S+ 11:51 0:00 vim root 3285 0.0 0.0 12108 1072 pts/0 S+ 11:51 0:00 grep --color=auto vim [root@station10-101 ~]# kill -19 3283 [root@station10-101 ~]# ps aux | grep vim root 3283 0.0 0.4 48188 8288 tty2 T 11:51 0:00 vim root 3288 0.0 0.0 12108 980 pts/0 S+ 11:51 0:00 grep --color=auto vim # p. 使用 bash 計算整數! [root@station10-101 ~]# echo $(( 60*60*24 )) 86400