認識SHELL
alias 顯示當前所有的命令別名 alias lm="ls -al" 命令別名 unalias lm 取消命令別名
type 類似which
exprot 設定或顯示環境變數
exprot PATH="$PATH":/sbin 添加/sbin入PATH路徑
echo $PATH 顯示PATH路徑
bash 進入子程式
name=yang 設定變數
unset name 取消變數
echo $name 顯示變數的內容
myname="$name its me" & myname='$name its me' 單引號時$name失去變數內容
ciw=/etc/sysconfig/network-scripts/ 設定路徑
env 列出所有環境變數
echo $RANDOM 顯示隨意產生的數
set 設定SHELL
PS1='[\u@\h \w \A #\#]\$ ' 提示字元的設定
[root@linux ~]# read [-pt] variable -----------讀取鍵盤輸入的變數
參數:
-p :後面可以接提示字元!
-t :後面可以接等待的『秒數!』
declare 聲明 shell 變數
ulimit -a 顯示所有限制資料
ls /tmp/yang && echo "exist" || echo "not exist"
意思是說,當 ls /tmp/yang 執行後,若正確,就執行echo "exist" ,若有問題,就執行echo "not exist"
echo $PATH | cut -d ':' -f 5 以:為分隔字元,讀取第5段內容
export | cut -c 10-20 讀取第10到20個位元組的內容
last | grep 'root' 搜尋有root的一行,加[-v]反向搜尋
cat /etc/passwd | sort 排序顯示
cat /etc/passwd | wc 顯示『行、字數、位元組數』
正規標記法
[root@test root]# grep [-acinv] '搜尋字串' filename
參數說明:
-a :將 binary 檔案以 text 檔案的方式搜尋資料
-c :計算找到 '搜尋字串' 的次數
-i :忽略大小寫不同,所以大小寫視為相同
-n :順便輸出行號
-v :反向選擇,亦即顯示出沒有 '搜尋字串' 內容的那一行!
grep -n 'the' 123.txt 搜尋the字元 -----------搜尋特定字串
grep -n 't[ea]st' 123.txt 搜尋test或taste兩個字元---------利用 [] 來搜尋集合字元
grep -n '[^g]oo' 123.txt 搜尋前面不為g的oo-----------向選擇 [^]
grep -n '[0-9]' 123.txt 搜尋有0-9的數字
grep -n '^the' 123.txt 搜尋以the為行首-----------行首搜尋^
grep -n '^[^a-zA-Z]' 123.txt 搜尋不以英文字母開頭
grep -n '[a-z]$' 123.txt 搜尋以a-z結尾的行---------- 行尾搜尋$
grep -n 'g..d' 123.txt 搜尋開頭g結尾d字元----------任意一個字元 .
grep -n 'ooo*' 123.txt 搜尋至少有兩個oo的字元---------重複字元 *
sed 文字資料流編輯器 利用指令碼命令來處理文字檔
awd 模式掃描和處理語言
nl 123.txt | sed '2,5d' 刪除第二到第五行的內容
diff 比較檔案的差異
cmp 比較兩個檔案是否有差異
patch 修補檔案
pr 要列印的檔案格式化
帳號管理
/etc/passwd 系統帳號資訊
/etc/shadow 帳號密碼資訊 經MD5 32位加密
在密碼欄前面加『 * 』『 ! 』禁止使用某帳號
/etc/group 系統群組資訊
/etc/gshadow
newgrp 改變登陸組
useradd & adduser 建立新使用者 ---------> useradd -m test 自動建立使用者的登入目錄
useradd -m -g pgroup test --------->指定所屬級
/etc/default/useradd 相關設定
/etc/login.defs UID/GID 有關的設定
passwd 更改密碼 -----------> passwd test
usermod 修改使用者帳號
userdel 刪除帳號 ----------->userdel -r test
chsh 更換登陸系統時使用的SHELL [-l]顯示可用的SHELL;[-s]修改自己的SHELL
chfn 改變finger指令顯示的資訊
finger 尋找並顯示使用者資訊
id 顯示使用者的ID -----------> id test
groupadd 添加組
groupmod 與usermod類似
groupdel 刪除群組
su test 更改使用者 su - 進入root,且使用root的環境變數
sudo 以其它身份來執行指令
visudo 編輯/etc/sudoers 加入一行『 test ALL=(ALL) ALL 』
%wheel ALL = (ALL) ALL 系統裡所有wheel群組的使用者都可用sudo
%wheel ALL = (ALL) NOPASSWD: ALL wheel群組所有使用者都不用密碼NOPASSWD
User_Alias ADMPW = vbird, dmtsai, vbird1, vbird3 加入ADMPW組
ADMPW ALL = NOPASSWD: !/usr/bin/passwd, /usr/bin/passwd [A-Za-z]*, \
!/usr/bin/passwd root 可以更改使用者密碼,但不能更改root密碼 (在指令前面加入 ! 代表不可)
PAM (Pluggable Authentication Modules, 嵌入式模組)
who & w 看誰線上
last 最近登陸主機的資訊
lastlog 最近登入的時間 讀取 /var/log/lastlog
talk 與其它使用者交談
write 發送資訊 write test [ctrl]+d 發送
mesg 設定終端機的寫入許可權 mesg n 禁止接收 mesg y
wall 向所有使用者發送資訊 wall this is q test
mail 寫mail
/etc/default/useradd 家目錄預設設定
quota 顯示磁碟已使用的空間與限制 quota -guvs ----->秀出目前 root 自己的 quota 限制值
quota -vu 查詢
quotacheck 檢查磁碟的使用空間與限制 quotacheck -avug ----->將所有的在 /etc/mtab 內,含有 quota 支援的
partition 進行掃瞄
[-m] 強制掃描
quota一定要是獨立的分區,要有quota.user和quota.group兩件檔案,在/etc/fstab添加一句:
/dev/hda3 /home ext3 defaults,usrquota,grpquota 1 2
chmod 600 quota* 設定完成,重啟生效
edquota 編輯使用者或群組的quota [u]使用者,[g]群組,[p]複製,[t]設定寬限期限
edquota -a yang edquota -p yang -u young ----->複製
quotaon 開啟磁碟空間限制 quotaon -auvg -------->啟動所有的具有 quota 的 filesystem
quotaoff 關閉磁碟空間限制 quotaoff -a -------->關閉了 quota 的限制
repquota -av 查閱系統內所有的具有 quota 的 filesystem 的限值狀態
Quota 從開始準備 filesystem 的支援到整個設定結束的主要的步驟大概是:
1、設定 partition 的 filesystem 支援 quota 參數:
由於 quota 必須要讓 partition 上面的 filesystem 支援才行,一般來說, 支援度最好的是 ext2/ext3 ,
其它的 filesystem 類型鳥哥我是沒有試過啦! 啟動 filesystem 支援 quota 最簡單就是編輯 /etc/fstab ,
使得準備要開放的 quota 磁碟可以支援 quota 囉;
2、建立 quota 記錄檔案:
剛剛前面講過,整個 quota 進行磁碟限制值記錄的檔案是 aquota.user/aquota.group,
要建立這兩個檔案就必須要先利用 quotacheck 掃瞄才行喔!
3、編輯 quota 限制值資料:
再來就是使用 edquota 來編輯每個使用者或群組的可使用空間囉;
4、重新掃瞄與啟動 quota :
設定好 quota 之後,建議可以再進行一次 quotacheck ,然後再以 quotaon 來啟動吧!
開機流程簡介
1、載入 BIOS 的硬體資訊,並取得第一個開機裝置的代號;
2、讀取第一個開機裝置的 MBR 的 boot Loader (亦即是 lilo, grub, spfdisk 等等) 的開機資訊;
3、載入 Kernel 作業系統核心資訊, Kernel 開始解壓縮,並且嘗試驅動所有硬體裝置;
4、Kernel 執行 init 程式並取得 run-level 資訊;
5、init 執行 /etc/rc.d/rc.sysinit 檔案;
6、啟動核心的外掛模組 (/etc/modprobe.conf);
7、init 執行 run-level 的各個批次檔( Scripts );
8、init 執行 /etc/rc.d/rc.local 檔案;
9、執行 /bin/login 程式,並等待使用者登入;
10、登入之後開始以 Shell 控管主機。
在/etc/rc.d/rc3.d內,以S開頭的為開機啟動,以K開頭的為關閉,接著的數字代表執行順序
GRUB vga設定
彩度\解析度 640x480 800x600 1024x768 1280x1024 bit
256 769 771 773 775 8 bit
32768 784 787 790 793 15 bit
65536 785 788 791 794 16 bit
16.8M 786 789 792 795 32 bit
./configure 檢查系統資訊 ./configure --help | more 協助資訊
make clean 清除之前留下的檔案
make 編譯
make install 安裝
rpm -q ----->查詢是否安裝 rpm -ql ------>查詢該套件所有的目錄
rpm -qi ----->查詢套件的說明資料 rpm -qc[d] ----->設定檔與說明檔
rpm -ivh ---->安裝 rpm -V -------->查看套件有否更動過
rpm -e ------>刪除 rpm -Uvh ------->升級安裝
--nodeps ----->強行安裝 --test ----->測試安裝