Posts

Showing posts from January, 2007

Linux - Console Language

Change console language: shell> LANG=en shell> LANGUAGE=en shell> LC_ALL=en shell> LC_CTYPE=en shell> LC_TIME=en Or shell> vi /etc/sysconfig/i18n LANG="zh_TW.Big5" LC_TIME=en_US:en SUPPORTED="zh_HK.UTF-8:zh_HK:zh:zh_CN.UTF-8:zh_CN:zh:zh_TW.UTF-8:zh_TW:zh:en_US.UTF-8:en_US:en" SYSFONT="latarcyrheb-sun16"

Linux - 如何將man轉存為文本文件?

以ls的man為例 man ls |col -b >ls.txt 將info變成文本,以make為例 info make -o make.txt -s

Linux - 如何將將 man page 轉成 HTML 格式?

使用 man2html 這個指令,就可以將 man page 轉成 HTML 格式了。用法是: man2html filename > htmlfile.html

Linux - 如何在GNOME和KDE之間切換?

以ls的man為例 $ switchdesk gnome or $ switchdesk kde $ startx

Linux - 如何瀏覽.iso光碟鏡像文件?

建一個目錄,如:mkdir a 把iso文件挂載到該目錄上:mount -o loop xxxx.iso a

Linux - AntiVirus for Linux

Avast http://www.avast.com/ 免費版為Home版,可以用在LINUX、WINDOWS,下載地址如下: Windows: http://www.avast.com/eng/download-avast-home.html Linux: http://www.avast.com/eng/download-avast-for-linux-edition.html 另外兩個系統的免費版本都需要免費申請安裝key,申請一次可以用一年,可連續申請。 申請地址: http://www.avast.com/i_kat_207.php?lang=ENG F-prot http://www.f-prot.com/ 免費版為Home版,Linux版免費,windows收費,下載地址: Linux: http://www.f-prot.com/download/home_user/download_fplinux.html 填寫資料後才能下載,下載後,安裝過程中不會要求輸入序列號等。 F-secure http://www.f-secure.com/ 沒有免費版本,只有一個月試用版本。可以使用其線上殺毒功能: http://support.f-secure.com/enu/home/ols.shtml For example, avast 設置病毒庫自動更新在GUI介面中進行 殺毒在無介面的終端中進行,該軟體有GUI介面模式: 啟動GUI:avastgui 啟動終端下命令:avast 查毒命令:avast 具體目錄 查殺命令:avast -c -p=1 具體目錄

Linux - Enter into Single User Mode in GRUB

1 .During the boot stage - GRUB, sleect the corresponding kernal 2. press [e] root (hd0,0) kernel /boot/vmlinuz-2.4.19 root=/dev/hda1 3. edit as follows: root (hd0,0) kernel /boot/vmlinuz-2.4.19 root=/dev/hda1 single 4. press [Enter] > [b]

Linux - Redhat SELinux & Apache

SELinux Target Policy allows httpd_sys_content_t for httpd # To display SELinux file attribute shell> ls -laZ # To change SELinux file attribute for httpd shell> chcon -t httpd_sys_content_t [dirname/filename]

Solaris - Disk Formating

1. Login as root user 2. configure the /devices directory shell> drvconfig 3. creates /dev entries for hard disks attached to the system shell> disks 4. fdisk shell> fdisks /dev/rdsk/c0d0p0 No fdisk table exists. The default partition for the disk is: ? a 100% “SOLARIS System” partition Type “y” to accept the default partition, otherwise type “n” to edit the partition table. y 5. format shell> format Searching for disks…done AVAILABLE DISK SELECTIONS: 0. c0d0 /pci@0,0/pci-ide@7,1/ide@0/cmdk@0,0 1. c1t6d0 /pci@0,0/pci9004,8178@f/sd@6,0 Specify disk (enter its number): 0 selecting c0d0 Controller working list found [disk formatted, defect list found] FORMAT MENU: disk - select a disk type - select (define) a disk type partition - select (define) a partition table current - describe the current disk format - format and analyze the disk fdisk - run the fdisk program repair - repair a defective sector show - translate a disk address label - write label to the disk analyze - su

MySQL Daily Backup Script

Quoted from http://www.jscud.com/ 本文是在linux下,mysql 4.1.14版本下測試的,經過適當修改可能適合mysql 4.0,5.0及其其他版本. 本文適合於沒有啟動複製功能的mysql,如果啟動了複製,可能不需要採取這種備份策略或者需要修改相關參數. 每個人的備份策略都可能不同,所以請根據實際情況修改,做到舉一反三,不要照搬照抄,可能會造成不必要的損失. 希望你明白這個腳本要幹什麼工作! 腳本描述 每7天備份一次所有數據,每天備份binlog,也就是增量備份. (如果數據少,每天備份一次完整數據即可,可能沒必要做增量備份) 作者對shell腳本不太熟悉,所以很多地方寫的很笨. 開啟 bin log 在mysql 4.1版本中,默認只有錯誤日誌,沒有其他日誌.可以通過修改配置打開bin log.方法很多,其中一個是在/etc/my.cnf中的mysqld部分加入: [mysqld] log-bin 這個日誌的主要作用是增量備份或者複製(可能還有其他用途). 如果想增量備份,必須打開這個日誌. 對於數據庫操作頻繁的mysql,這個日誌會變得很大,而且可能會有多個. 在數據庫中flush-logs,或者使用mysqladmin,mysqldump調用flush-logs後並且使用參數delete-master -logs,這些日誌文件會消失,並產生新的日誌文件(開始是空的). 所以如果從來不備份,開啟日誌可能沒有必要. 完整備份的同時可以調用flush-logs,增量備份之前flush-logs,以便備份最新的數據. 完整備份腳本 如果數據庫數據比較多,我們一般是幾天或者一週備份一次數據,以免影響應用運行,如果數據量比較小,那麼一天備份一次也無所謂了. 下載假設我們的數據量比較大,備份腳本如下:(參考過網路上一個mysql備份腳本,致謝 :)) #!/bin/sh # mysql data backup script # by scud http://www.jscud.com # 2005-10-30 # # use mysqldump –help,get more detail. # BakDir=/backup/mysql LogFile=/backup/mysql/mysqlbak.log DAT

MySQL Backup & Copy

重要的是在表丟失和毀壞時備份數據庫。如果系統發生崩潰,您就能夠將表恢復到崩潰時刻的狀態,並盡可能不丟失數據。同樣,錯發DROP DATABASE 或DROP TABLE 命令的用戶可能會向您請求進行數據恢復。有時,這是由MySQL管理員引起的破壞,管理員試圖通過使用像vi 或emacs 這樣的編輯器直接編輯表文件而毀壞了它們。這樣做對表來說肯定是幹了壞事。 備份數據庫的兩種主要方法是使用mysqldump 程式或直接拷貝數據庫文件(如便用cp、tar 或cpio)。每種方法都有自己的優點和缺點: mysqldump 與MySQL伺服器聯合進行操作。直接拷貝方法與伺服器相脫離,因此必須採取措施確保在進行拷貝時沒有客戶機在修改這些表。這個問題與利用文件系統備份來備份數據庫的問題相同:如果數據庫表在文件系統備份時進行更新,則進行備份的表文件處於非一致的狀態,並且對於今後恢復該表沒有意義。文件系統備份和直接拷貝文件的區別是:對於後者,您具有控製備份進度的權利,因此可以採取措施確保伺服器使表處於靜止狀態。 mysqldump比直接拷貝技術要慢 mysqldump 產生可移植到其他機器、甚至具有不同硬體結構的機器上的文本文件。直接拷貝文件不能夠移植到其他機器上,除非要拷貝的表使用MyISAM存儲格式。ISAM 表只能在具有相同硬體結構的機器之間進行拷貝。例如,將文件從SPARC 的Solaris 機器拷貝到Intel的Solaris 機器(或者相反)是行不通的。由MySQL3.23 引進的MyISAM表存儲格式可以解決這個問題,因為該格式與機器獨立。因此,如果以下兩個條件都滿足的話,直接拷貝文件可以移植到具有不同硬體結構的機器上:即另一台機器上也必須運行MySQL3.23以上的版本,並且文件必須表示成MyISAM 表,而不是ISAM 表。 不論選擇哪種備份方法,都有某些原則,您必須堅持這些原則,才能確保在需要恢複數據庫內容時得到最好的結果: 定期執行備份。設置一個時間表並堅持使用它。告訴伺服器運行更新日誌。更新日誌在您需要恢復崩潰後的數據庫時給予幫助。在使用備份文件將數據庫恢復到備份時刻的狀態後,可以通過運行更新日誌中的查詢,重新運行備份之後所做的改變。這個操作將數據庫中的表恢復到了崩潰時刻的狀態。在文件系統備份語言中,數據庫備份文件表示完全轉儲(full dump),而更新日

Linux - “find” practical examples

Case 1: find the files modified within 24 hour shell> find / -mtime 0 # 0 = the current time, so 24 hours from now. # find / -mtime 3, so the files modifed 3 days ago (3*24 ~ 4*24 hours) Case 2: find the files under /etc, if the files are newer than the file - /etc/passwd shell> find /etc -newer /etc/passwd Case 3: find the files under /home, owned by userabc shell> find /home -user userabc Case 4: find the files, nit owned by anybody shell> find / -nouser Case 5: find the file, named “passwd” shell> find / -name passwd Case the files with attribute “f” shell> find /home -type f Case 7: find the files with attribute SGID/SUID/SBIT shell> find / -perm +7000 # 7000 = —s–s–t Case 8: find the files with attribute SGID/SUID/SBIT, then display in “ls -l” shell> find / -perm +7000 -exec ls -l {} \; # {} = [the find results] # \; = [the end of “-exec”] Case 9: find the files larger than 1MB shell> find / -size +1000k

Linux - rsync 備份 (全自動網路備份法)

rsync 備份 (全自動網路備份法) by OLS3 (ols3@www.tnc.edu.tw) 2002/10/18 一 . 簡介 rsync 本來是用以取代 rcp 的一個工具, 它目前是由 rsync.samba.org 維護. rsync 使用所謂的 "rsync 演算法", 提供一個非常快速的檔案傳輸方法, 使 local 和遠端二部主機之間的檔案達到同步, 它主要是傳送二個檔案的異動部份, 而非每次都整份傳送, 因此速度相當地快. 由於 rsync 可以搭配 rsh 或 ssh 甚至使用 daemon 模式, 因此許多人拿 rsync 當做一個優異的備份工具來使用. (拿來 update ISO 檔也很好用) 本文將簡單介紹運用 rsync 備份網路主機檔案的基本方法, 供各位伙伴參考. rsync 有 6 種不同的用法, 如 local 拷貝備份, local 檔案藉由 rsh/ssh 傳送至遠方主機.... 在此我們主要介紹 rsync 的 daemon 模式. 首先 , 先給個簡單的定義: 如果一台主機跑 rsync daemon 模式, 我們就稱這台機器為一 rsync Server, 或者說這台主機是一台備份主機( Backup Server). 備份主機會開啟一個 873 的服務通道(port), 等待對方 rsync 連接. 連接時 , rsync Server 會檢查密碼是否相符, 若通過密碼查核, 則開始進行檔案傳輸. 第一次連通完成時 , 會把整份檔案傳輸一次, 下一次就只傳送二個檔案之間異動的部份. rsync client (欲加以備份的網路主機) 和 rsync server 的運作方式, 如下圖所示: 藉由上述方法 , 我們可以設立多部備份主機, 使網路主機上重要的檔案能分散至數部主機中, 以分散風險. 一旦完成備份 , 我們可以對這些備份主機再做進一步的儲存動作, 如使用 tar 或 Ghost , 把檔案備份到更穩固,更能長久保存的設備上, 如 MO 或 燒錄設備. 以上 , 便是整個運作的想法, 底下, 我們來加以實作. 二 . 安裝法 rsync 目前最新版是 2.5.5, 可以到 rsync.samba.org 或 敝中心 FTP 下載 . 安裝 rsync 十分簡單,

Linux - Recover Root Passwrd

Linux root密碼丟失了怎麼辦?給你一個方法。 GRUB:在引導裝載程式功能表上,鍵入 [e] 來進入編輯模式。你會面對一個引導項目列表。搜尋其中類似以下輸出 的句行:   kernel /vmlinuz-2.4.18-0.4 ro root=/dev/hda2 按箭頭鍵直到這一行被突出顯示,然後按 [e]。你現在可在文本結尾處空一格再添加 single 來告訴 GRUB 引導單用戶 Linux 模式。按 [Enter] 鍵來使編輯結果生效。 你會被帶會編輯模式螢幕,從這裡,按 [b], GRUB 就會引導單用戶 Linux 模式。 結束載入後,你會面對一個與以下相似的 shell 提示:   sh-2.05# 現在,你便可以改變根命令,鍵入:   bash# passwd root 你會被要求重新鍵入密碼來校驗。結束後, 密碼就會被改變,你便可以在提示下鍵入 reboot 來重新引導;然後,象平常一樣登錄為根用戶。 LIL當系統啟動到出現LILO引導畫面時,對於圖形引導方式按TAB鍵進入文本方式,然後在LILO處輸入linux single回車即可進入免密碼的控制臺,進入以後使用passwd命令修改root的密碼即可。

Linux - Troubleshooting the "device is busy"

# umount /dev/dsk/c0t2d0s7 umount: /dev/dsk/c0t2d0s7: device is busy # fuser -u /dev/dsk/c0t2d0s7 /dev/dsk/c0t2d0s7: 1313co(oracle) 1223c(root) # fuser -k /dev/dsk/c0t2d0s7 /dev/dsk/c0t2d0s7: 1313co 1223c -k option to kill all processes using the specified file or filesystem

Linux - MySQL 備份 shell script

Quoted from http://www.real-blog.com #!/bin/sh # mysql_backup.sh: backup mysql databases and keep newest 5 days backup. # # Last updated: 20 March 2006 # ---------------------------------------------------------------------- # This is a free shell script under GNU GPL version 2.0 or above # Copyright (C) 2006 Sam Tang # Feedback/comment/suggestions : http://www.real-blog.com/ # ---------------------------------------------------------------------- # your mysql login information # db_user is mysql username # db_passwd is mysql password # db_host is mysql host # ----------------------------- db_user="root" db_passwd="" db_host="localhost" # the directory for story your backup file. backup_dir="" # date format for backup file (dd-mm-yyyy) time="$(date +"%d-%m-%Y")" # mysql, mysqldump and some other bin's path MYSQL="$(which mysql)" MYSQLDUMP="$(which mysqldump)" MKDIR="$(which mkdir)" RM="$

Linux - Creating Log Files (2>&1)

Redirect stdout and stderr to file The 2>&1 says make STDERR point to the same places as STDOUT. Since STDOUT is open already, and the shell has done a seek to the end, STDERR will also be appended to STDOUT. # ... > file 2>&1 For larger packages, it is convenient to create log files instead of staring at the screen hoping to catch a particular error or warning. Log files are also useful for debugging and keeping records. The following command allows you to create an installation log. Replace with the command you intend to execute. ( 2>&1 | tee compile.log && exit $PIPESTATUS ) 2>&1 redirects error messages to the same location as standard output. The tee command allows viewing of the output while logging the results to a file. The parentheses around the command run the entire command in a subshell and finally the exit $PIPESTATUS command ensures the result of the is returned as the result and not the result of the tee command. This will run t

Linux - 如何配置網路?

$ netconfig