.tar
打包:tar cvf FileName.tar DirName
解包: tar xvf FileName.tar
.gz
壓縮:gzip FileName
解壓1:gunzip FileName.gz
解壓2:gzip -d FileName.gz
.tar.gz
壓縮:tar zcvf FileName.tar.gz DirName
解壓:tar zxvf FileName.tar.gz
.bz2
壓縮: bzip2 -z FileName
解壓1:bzip2 -d FileName.bz2
解壓2:bunzip2 FileName.bz2
.tar.bz2
壓縮:tar jcvf FileName.tar.bz2 DirName
解壓:tar jxvf FileName.tar.bz2
.bz
壓縮:unkown
解壓1:bzip2 -d FileName.bz
解壓2:bunzip2 FileName.bz
.tar.bz
壓縮:unkown
解壓:tar jxvf FileName.tar.bz
.Z
壓縮:compress FileName
解壓:uncompress FileName.Z
.tar.Z
壓縮:tar Zcvf FileName.tar.Z DirName
解壓:tar Zxvf FileName.tar.Z
.tgz
壓縮:unkown
解壓:tar zxvf FileName.tgz
.tar.tgz
壓縮:tar zcvf FileName.tar.tgz FileName
解壓:tar zxvf FileName.tar.tgz
.zip
壓縮:zip FileName.zip DirName
解壓:unzip FileName.zip
.rar
壓縮:rar e FileName.rar rar a FileName.rar
解壓:rar a FileName.rar rar e FileName.rar
.lha
壓縮:lha -a FileName.lha FileName
解壓:lha -e FileName.lha資料來源:
★EvoTalk - Unix下常用壓縮格式的壓縮與解壓縮方法
凍仁幫各個社團開帳號時,除了關閉 ssh 服務之外,還想限制各帳號的磁碟空間,以免被資源被濫用。在鳥哥得知有 quota 可限制空間,可凍仁卻有那麼點不懂,索性跟老闆借了 Novell Suse Linux Enterprise Server 9 管理手冊 一書才搞定。其中 usrquota 為單獨使用者;grpquota 為針對使用者群組設定配額。By the way, quota 除了限制磁碟空間大小之外,還可限制建立檔案的inode(數量)。
實作磁碟配額步驟:
1. 安裝 quota 套件。jonny@ubuntu:~$ sudo apt-get install quota
2. 修改 /etc/fstab 檔案並選擇預設定 Quota 的檔案系統。jonny@ubuntu:~$ sudo vi /etc/fstab
#裝置 掛載點 檔案系統格式 mount選項
/dev/sda7 /home ext3 defaults,usrquota,grpquota
3. 重新掛載檔案系統:加入 usrquota 與 grpquota 後,需重新掛載才有效。jonny@ubuntu:~$ sudo mount -o remount /home
4. 初始化 Quota 資料庫:quota 會藉由 Database(資料庫) 紀錄使用者或群組的使用情況,首先得使用 quotacheck 檢查配額的檔案系統及建立磁碟用量表格。(下方以 home 為例)jonny@ubuntu:~$ sudo qoutacheck -cmug /home
# c:建立 quota 資料庫 | u:檢查使用者配額 | g:檢查群組配額
執行完會產生 aquota.user(使用者 Quota 資料庫)、aquota.qroup(群組 Quota 資料庫)。jonny@ubuntu:~$ /home$ ls -l /home/aquota.*
-rw------- 1 root root 8192 2008-03-26 18:46 /home/aquota.group
-rw------- 1 root root 7168 2008-03-26 18:46 /home/aquota.user
5. 啟動 Quota Deamon:jonny@ubuntu:~$ sudo quotaon -av
6. 編輯使用者或群組 Quota 規則# 設定使用者磁碟配額
jonny@ubuntu:~$ sudo edquota -u UserName
# 設定群組磁碟配額
jonny@ubuntu:~$ sudo edquota -g GroupName
接著會進入 quota 編輯模式.. GNU nano 2.0.6 檔案: /tmp//EdP.aD0puo9
Disk quotas for user spa (uid 1004):
Filesystem blocks soft hard inodes soft hard
/dev/sda7 24 100000 102400 7 0 0
^G 求助 ^O 寫入 ^R 讀檔 ^Y 上頁 ^K 剪下文字 ^C 游標位置
^X 離開 ^J 對齊 ^W 搜尋 ^V 下頁 ^U UnCut Text^T 拼字檢查
第1欄(Filesystem):啟用 quota 的檔案系統名增
第2欄(blocks):使用者已使用的區塊數量
第3欄(soft):非強制性的磁碟空間限制 /* 單位:k */
第4欄(hard):強制性的磁碟空間限制 /* 單位:k */
第5欄(inodes):使用者已使用的檔案數目
第6欄(soft):非強制性的 inode 限制
第7欄(hard):強制性的 inode 限制
★ 套用某個使用者的規則jonny@ubuntu:~$ sudo edquota -p <被參考的使用者> user1,user2 ..
★確認使用者配額jonny@ubuntu:~$ sudo quota UserName
★確認群組配額jonny@ubuntu:~$ sudo quota -g GroupName
★檢視單一目錄磁碟配額報告jonny@ubuntu:~$ sudo repquota /home
★檢視所有配額中的磁碟用量報告jonny@ubuntu:~$ sudo repquota -aug
延伸閱讀:
★【Quota】修改寬限時間(grace time)
資料來源:
★Novell Suse Linux Enterprise Server 9 管理手冊 - ch7.6
★鳥哥 - Linux 磁碟配額 (Quota)
凍仁管 B2D Linux Server 時發現裡面內建的 vim 設定檔做的很棒。如懶的自行設定的玩家不妨用用 B2D 的設定唄。
2008-04-19
凍仁在 Ubuntu 7.10 實作中遇到些問題,並不是直接下載完放進家目錄底下就可用囉,以下是凍仁的 vi 改造筆記
- 安裝 vim
jonny@ubuntu:~$ sudo apt-get install vim
- 切換至家目錄下
jonny@ubuntu:~$ cd ~
- 下載 B2D 的 vim 設定檔 .vimrc
jonny@ubuntu:~$ wget http://140.127.138.72/jonny/download/config/.vimrc
- 將環境改為 utf8 格式 /* B2D 預設為 big5 */
32 set enc=
big5utf8 - 最後補上凍仁之前愛用的設定 → 【Editer】vimrc - vi 環境設定
2008-04-21
如要在 Trixbox 使用請先安裝 vim。注意!請依照 Server 種類安裝(以下為PC i386)
jonny@centos:~$ sudo yum install vim-X11.i386
jonny@ubuntu:~$ vi .vimrc
" Configuration file for vim
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " Use Vim defaults instead of 100% vi compatibility
set backspace=indent,eol,start " more powerful backspacing
" Now we set some defaults for the editor
set autoindent " always set autoindenting on
set textwidth=0 " Don't wrap words by default
set nobackup " Don't keep a backup file
set backupcopy=no " KNOPPIX: Overwrite files/links with w!
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
" 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
" We know xterm-debian is a color terminal
if &term; =~ "xterm-debian" || &term; =~ "xterm-xfree86"
set t_Co=16
set t_Sf=^[[3%dm
set t_Sb=^[[4%dm
endif
" Make p in Visual mode replace the selected text with the "" register.
vnoremap p :let current_reg = @"gvdi=current_reg
set enc=big5
imap :wi
imap :wq
imap :q!
map :w
map :wq
map :q!
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
" Debian uses compressed helpfiles. We must inform vim that the main
" helpfiles is compressed. Other helpfiles are stated in the tags-file.
set helpfile=$VIMRUNTIME/doc/help.txt.gz
if has("autocmd")
" Enabled file type detection
" Use the default filetype settings. If you also want to load indent files
" to automatically do language-dependent indenting add 'indent' as well.
filetype plugin on
endif " has ("autocmd")
" Some Debian-specific things
augroup filetype
au BufRead reportbug.* set ft=mail
au BufRead reportbug-* set ft=mail
augroup END
" The following are commented out as they cause vim to behave a lot
" different from regular vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make相關連結:
★B2D Linux Server - vimrc
1.將資料由本機上傳到遠端主機
jonny@ubuntu:~$ scp FileName jonny@localhost:/home/jonny/
jonny@localhost's password: /* 輸入密碼 */
FileName 100% 0 0.0KB/s 00:00FileName → 檔案名稱
jonny → 遠端主機上的使用者名稱
localhost:/home/jonny/ → 目的資料夾位址
2. 由遠端主機下載資料
jonny@ubuntu:~$ scp jonny@localhost:~/.bashrc ..bashrc → 在 Linux 的世界裡 . 為隱藏檔ps: 要使用 scp 之前記得先在本地安裝 ssh-client,遠端則是 ssh-server 喔XD
資料來源:
★鳥哥的 Linux 私房菜 - SSH 伺服器 - 4.3 ssh 用戶端連線 - scp
寒假時凍仁看那系上的專題生在 Fdora 上那邊打 rpm.. make.. 在那裝了半天都搞不定,索性叫他直接換 Ubuntu Desktop,點幾下就輕輕鬆鬆裝起來啦:P
Wireshark (前身為 Ethereal) - 網路封包分析軟體的功能是擷取網路封包, 並儘可能顯示出最為詳細的網路封包資料。在過去,網路封包分析軟體是非常昂貴,或是專門屬於營利用的軟體。Ethereal的出現改變了這一切。在GNU GPL通用許可證的保障範圍底下,使用者可以以免費的代價取得軟體與其程式碼,並擁有針對其原始碼修改及客製化的權利。Ethereal是目前全世界最廣泛的網路封包分析軟體之一。
安裝方法:
1. 命令達人組jonny@ubuntu:~$ sudo apt-get install wireshark
2.GUI愛好者應用程式 → 新增/刪除 → 搜尋 wireshark → 安裝
延伸閱讀:
★Wireshark
相關連結:
★Wireshark官網
新增完 n 筆帳號後,接下來就是要改密碼啦,同樣使用 passwd users 一筆一筆敲是很笨的方法,接下來會使用 chpasswd 來修改大量密碼.. 下命令前真的要想好!不然一次要砍300筆帳號可不是好玩的,手好酸.. Orz
1. 利用 OpenOffice.org Spreadsheet 建立帳號檔(newpwd_list)並存成 .csv,請依以下格式 key in ..stu001:密碼
stu002:密碼
stu003:密碼
stu004:密碼
stu005:密碼
stu006:密碼
/* 記得數字累加的部分一樣獨立出來.. */
2. 使用 gedit or 文字編輯器 將分隔的符號取代掉
3. 修改密碼jonny@ubuntu:~$ chpasswd < new_plist
4. 將 /etc/shadow 內的密碼欄資料寫回 /etc/passwd 當中, 並刪除 /etc/shadow 檔案jonny@ubuntu:~$ sudo pwunconv
jonny@ubuntu:~$ sudo pwconv延伸閱讀:
★【Ubuntu】newusers - 新增 n 筆帳號
資料來源:
★OLS3 - RedHat 6.0 大量建帳號的方法
相關連結:
★OLS3 - 大量建帳號工具程式 cmpwd 1.0.0 RHS (教育版)
在 Ubuntu Server 裡沒有 GUI 的介面來設定網路IP,再加上每次重開後使用 ifconfig 更改完的 IP 又會自動被 DHCP 覆蓋過去。這對凍仁這個小網管來說是個很頭痛的問題。
1. 編輯 ip 設定檔jonny@ubuntu:~$ sudo vi /etc/network/interfaces
2. 更改 eth0 設定,將 auto eth0
iface eth0 inet dhcp
改為auto eth0
iface eth0 inet static
address 140.127.˙˙˙.˙˙˙
netmask 255.255.255.0
gateway 140.127.˙˙˙.˙˙˙
3. 重新連線並測試有無成功 # 中斷連線
jonny@ubuntu:~$ sudo ifconfig eth0 down
# 啟用網路
jonny@ubuntu:~$ sudo ifconfig eth0 up相關連結:
★Ubuntu正體中文wiki - Ubuntu6.10LAMPServer - 11.2設定網路
這幾天一直沒啥空寫 blog,不是 mlms 要鎖IP,就是要在粘老師的學生練習機上面新增300筆帳號,300多筆.. 一筆一筆 key 可是會死人的.. 索性開始自學囉..
開始前先複習一下 /etc/passwdjonny:$1$eb30c0TU$r4ZosogN/Aev83kMS/erq0:1000:1000:Deva-Jonny,,,:/home/jonny:/bin/bash
jonny → 使用者登入名稱(Login name)
$1$eb30c0TU$r4ZosogN/Aev83kMS/erq0 → 加密後的密碼(Password)
1000 → 使用者識別碼(User Identifier)
1000 → 所屬群組識別碼(Group Identifier)
Deva-Jonny,,, → 註解
/home/jonny → 使用者家目錄(Home directory)
/bin/bash → 登入 Shell 名稱
1. 利用 OpenOffice.org Spreadsheet 建立帳號檔(newuser_list)並存成 .csv,需按照以下格式輸入..stu001::600:600:stu:/home/stu001:/bin/bash
stu002::601:601:stu:/home/stu002:/bin/bash
stu003::602:602:stu:/home/stu003:/bin/bash
stu004::603:603:stu:/home/stu004:/bin/bash
/* 建議使用 1100 以後的 uid,不然會像凍仁一樣發生練習帳號具有 admin, ssh.. 的權限Orz */
/* 在 Spreadsheet 裡遇到需要累加的部分可以獨立出來讓他累加,就像上圖一樣.. */
2. 使用 gedit 將分隔的符號取代掉,分隔符號可能為 ", 空格。開啟 gedit 後按 Ctrl + H 開啟取代視窗,注意!縮排的代號為 \t..
3. 建立帳號jonny@ubuntu:~$ sudo newusers < newuser_list
4. 將 /etc/shadow 內的密碼欄資料寫回 /etc/passwd 當中, 並刪除 /etc/shadow 檔案jonny@ubuntu:~$ sudo pwunconv
延伸閱讀:
★ 【Ubuntu】chpasswd - 修改 n 筆密碼
資料來源:
★OLS3 - RedHat 6.0 大量建帳號的方法
相關連結:
★OLS3 - 大量建帳號工具程式 cmpwd 1.0.0 RHS (教育版)
★鳥哥 - pwunconv
在架完 Apache Server 時,預設找不到 link(連結) 時會列出該連結下所有的目錄。有時列出所有的檔案及目錄是不安全的。像凍仁剛架起來的 web 會顯示下圖這樣的訊息.. 這樣不管放啥東西在上面都會被看光光啦XD
1. 刪除 /etc/apache2/sites-available/default 中的 Indexes 來停用目錄列表之功能 1 NameVirtualHost *
2 <VirtualHost *>
3 ServerAdmin webmaster@localhost
4 DocumentRoot /var/www/
5 <Directory />
6 Options FollowSymLinks
7 AllowOverride None
8 </Directory>
9 <Directory /var/www/>
10 Options Indexes FollowSymLinks MultiViews
11 AllowOverride None
12 Order allow,deny
13 allow from all
14 # This directive allows us to have apache2's default start page
15 # in /apache2-default/, but still have / go to the right place
16 #RedirectMatch ^/$ /apache2-default/
17 </Directory>
18
19 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
20 <Directory "/usr/lib/cgi-bin">
21 AllowOverride None
22 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
23 Order allow,deny
24 Allow from all
25 </Directory>
26
27 ErrorLog /var/log/apache2/error.log
28
29 # Possible values include: debug, info, notice, warn, error, crit,
30 # alert, emerg.
31 LogLevel warn
32
33 CustomLog /var/log/apache2/access.log combined
34 ServerSignature On
35
36 Alias /doc/ "/usr/share/doc/"
37 <Directory "/usr/share/doc/">
38 Options Indexes MultiViews FollowSymLinks
39 AllowOverride None
40 Order deny,allow
41 Deny from all
42 Allow from 127.0.0.0/255.0.0.0 ::1/128
43 </Directory>
44
45 </VirtualHost>
2. 重新啟動 apache2jonny@ubuntu:~$ sudo /etc/init.d/apache2 restart

相關連結:
★紅.攝.情.感. Red maple’s note - Apache 如何關閉目錄列表
★鳥哥 - httpd.conf 的基本設定
凍仁在系學會的 Server 遇到個問題,今天只想提供 apache2, php, mysql 及 ftp 服務給個社團放網頁。想到關閉 ssh 服務一法,這樣就算他們密碼設再爛.. 也只能透過 ftp,這樣在安全性上也更有保障...XD
這邊為鳥哥大人在 詳細設定 sshd 伺服器 中講述的一部分# 4.6 關於使用者抵擋的設定項目:
DenyUsers *
# 設定受抵擋的使用者名稱,如果是全部的使用者,那就是全部擋吧!
# 若是部分使用者,可以將該帳號填入!例如下列!
DenyUsers test
DenyGroups test
# 與 DenyUsers 相同!僅抵擋幾個群組而已!
凍仁小筆記:
1. 新增 www-no-ssh 群組(用來阻擋使用者之群組)jonny@ubuntu:~$ sudo groupadd www-no-ssh
2. 將預阻擋的使用者加入此群組jonny@ubuntu:~$ sudo vi /etc/group
www-no-ssh:x:1015:Orz,QQ,123goTaiwan
3. 在 sshd_conf 裡新增 DenyGroups 來阻擋以上使用者jonny@ubuntu:~$ sudo vi /etc/ssh/sshd_config
DenyGroups www-no-ssh
4. 重新啟動 sshjonny@ubuntu:~$ # sudo /etc/init.d/ssh restart
資料來源:
★鳥哥 - 詳細設定 sshd 伺服器
當 user 超過 soft 時,寬限時間就會開始倒數。在寬限時間到期之前 user 還可使用剩下的空間直到 hard。不過要是在時間內沒降到 soft 以下,那麼 user 就無法新增檔案及使用剩下的空間。jonny@ubuntu:~$ edquota -t
接下來進入編輯模式 GNU nano 2.0.6 檔案: /tmp//EdP.ae5PD58
Grace period before enforcing soft limits for users:
Time units may be: days, hours, minutes, or seconds
Filesystem Block grace period Inode grace period
/dev/sda7 7days 7days
^G 求助 ^O 寫入 ^R 讀檔 ^Y 上頁 ^K 剪下文字 ^C 游標位置
^X 離開 ^J 對齊 ^W 搜尋 ^V 下頁 ^U UnCut Text^T 拼字檢查延伸閱讀:
★【Quota】磁碟配額(Disk Quota)
資料來源:
★Novell Suse Linux Enterprise Server 9 管理手冊 - ch7.6
【adduser】
adduser 除了新增帳號外,還會自動新增 /home/XXX(家目錄) 並將 /etc/skel 複製預設的檔案至使用者家目錄。Enter 後得輸入密碼及相關資訊..等等,其中這些資訊當放在 /etc/passwd 裡。
# sudo adduser albert
Adding user `albert' ...
Adding new group `albert' (1005) ...
Adding new user `albert' (1005) with group `albert' ...
Creating home directory `/home/albert' ...
Copying files from `/etc/skel' ...
輸入新的 UNIX 密碼:
再次輸入新的 UNIX 密碼:
passwd:密碼已成功地變更
正在改變 albert 的使用者訊息
請輸入新值,或直接按 ENTER 鍵以使用預設值
全名 []: Albert3537
房間號碼 []: 201
工作電話 []: 07-7310606#49311106
家庭電話 []: Orz
其它 []: qq
以上的資訊都正確嗎?[y/N] y要是想讓新增的使用者具有管理權限,則輸入
# adduser XXX admin
Adding user XXX to group admin...
Done.可使用 grep 做確認。想刪除可用 deluser。
# grep admin /etc/group
grep admin /etc/group
lpadmin:x:108:albert
admin:x:110:albert資料來源:
★添加用戶 adduser 和 useradd 的用法為什麼會不同啊?
★ChinaUnix Wiki - adduser
相關連結:
★OSWikiHK - 新增使用者恢復方法:
1.使用光碟開機 → 出現選單後先按F2選擇繁體中文 → 啟動或安裝 Ubuntu (S)
2.進入live界面後,點application → 附屬應用程式 → 終端機
3.輸入sudo -so,以root用戶操作
4.輸入grub,進入gru配置界面
5.輸入root (hdx,y) ####注意!這裡的(hdx,y)是你的Ubuntu的安裝位置!如果你不知道的話,輸入find /boot/grub/stage1 可以顯示出來
6.輸入setup (hd0),將grub寫入硬碟
7.輸入quit,退出,重啟,GRUB選單就會出現囉
資料來源:
★賽迪網 - sixth - 恢復Ubuntu系統下GRUB引導的最簡單辦法方法有兩種
1.修改 /boot/grub/menu.lst 中的 timeout
16 ## timeout sec
17 # Set a timeout, in SEC seconds, before automatically booting the default entry
18 # (normally the first entry defined).
19 timeout 102.使用 StartUp Manager 套件
延伸閱讀:
★【Ubuntu】Grub - 隱藏開機選單
★【Ubuntu】Grub - 更改預設的開機作業系統
資料來源:
★Ubuntu 正體中文站 - 請問開機選單可不可以改成不要倒數讀秒?在終端機輸入以下指令
# sudo vi /boot/grub/menu.ls之後將 #hiddenmenu 的 # 刪除即可。 21 ## hiddenmenu
22 # Hides the menu by default (press ESC to see the menu)
23 #hiddenmenu延伸閱讀
★【Ubuntu】Grub - 更改預設的開機作業系統
★【Ubuntu】Grub - 縮短開機選單讀秒時間
★【Ubuntu】StartUpManager - Grup管理套件
資料來源:
★Ubuntu 正體中文站 - 請問開機選單可不可以改成不要倒數讀秒?在終端機輸入以下指令
# sudo vi /boot/grub/menu.lst之後在06 ## default num
07 # Set the default entry to the entry number NUM. Numbering starts from 0, and
08 # the entry number 0 is the default if the command is not used.
09 #
10 # You can specify 'saved' instead of a number. In this case, the default entry
11 # is the entry saved with the command 'savedefault'.
12 # WARNING: If you are using dmraid do not use 'savedefault' or your
13 # array will desync and will not let you boot your system.
14 default 0找到 default,並修改後面的數字為其餘 OS 的代號。延伸閱讀:
★【Ubuntu】Grub - 縮短開機選單讀秒時間
★【Ubuntu】Grub - 隱藏開機選單
★【Ubuntu】StartUpManager - Grup管理套件
資料來源:
★Ubuntu 正體中文站 - 請問開機選單可不可以改成不要倒數讀秒?1. 切到想建立 捷徑 的目錄底下
2. 輸入以下指令建立捷徑
# sudo ln -s /home/jonny/web/jonny/ jonnyps: 如果是當作 web 提供服務.. 這類的檔案及目錄,記得改權限(最好另開群組 + 移除寫入權限),小心被別人拿去玩了:P
延伸閱讀:
★鳥哥的 Linux 私房菜 - 連結檔的介紹: ln