使用者工具

網站工具


linux:basic

差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版前次修改
下次修改
前次修改
linux:basic [2007/04/19 01:33] – wenpeilinux:basic [2010/04/06 12:19] (目前版本) – wenpei
行 1: 行 1:
 +====== 關掉 console 下的蜂鳴器 ======
 +  sudo modprobe -r pcspkr
 +
 +或者用 sudo modconf,找到 drivers/input/misc/pcspkr.ko 並移除。
 +
 ====== 家目錄的原始檔 ====== ====== 家目錄的原始檔 ======
   /etc/skel   /etc/skel
行 4: 行 9:
 ====== 手動建帳號 ====== ====== 手動建帳號 ======
   - 編輯 /etc/passwd   - 編輯 /etc/passwd
 +  - 將 /etc/passwd 與 /etc/shadow 同步化 ( pwconv )
   - 編輯 /etc/group   - 編輯 /etc/group
 +  - 將 /etc/group 與 /etc/gshadow 同步化 ( grpconv )
   - 開設使用者的自家目錄(通常在 /home 中, 建一個和使用者帳號同名的目錄)   - 開設使用者的自家目錄(通常在 /home 中, 建一個和使用者帳號同名的目錄)
   - 將 /etc/skel 中的檔案全拷貝至使用者的自家目錄(cp /etc/skel/.* /home/使用者)   - 將 /etc/skel 中的檔案全拷貝至使用者的自家目錄(cp /etc/skel/.* /home/使用者)
行 10: 行 17:
   - 設定密碼   - 設定密碼
  
 +====== 大量建帳號 ======
 +<code>
 +for line in `cat account.txt`
 +do
 +account=`echo $line | cut -d : -f 1`
 +passwd=`echo $line | cut -d : -f 2`
 +useradd -m $account
 +echo $account:$passwd | chpasswd
 +done
 +</code>
 +
 +account.txt 格式:
 +  account:password 
 +
 +====== 手動移除帳號 ======
 +  - 先以 find / -user account 找出所有的帳號檔案,並將他刪除
 +  - 將 /etc/passwd 與 /etc/shadow 的相關資料刪除
 +  - 將 /etc/group 及 /etc/gshadow 相關資料刪除
 +  - 將 /home 底下關於該帳號的目錄刪除
 +  - 到 /var/spool/mail 以及 /var/spool/cron 裡面將相關的使用者檔案刪除
  
 ====== 使用者郵件轉寄 ====== ====== 使用者郵件轉寄 ======
行 84: 行 111:
   scp [file] [username]@[host]:[path]   scp [file] [username]@[host]:[path]
 example: example:
-  scp make.conf fang@140.115.189.106: +  scp make.conf user@192.168.1.2:~ 
-主機後面要加一個「:」+主機後面要加一個「:」代表遠端的主機,「~」代表遠端的家目錄。
  
 ====== 透過 ssh 掛載遠端 filesystem ====== ====== 透過 ssh 掛載遠端 filesystem ======
行 112: 行 139:
 ===== bmon ===== ===== bmon =====
 ===== iftop ===== ===== iftop =====
 +===== iptraf =====
  
  
行 130: 行 158:
   set paste   set paste
   set softtabstop=4   set softtabstop=4
 +
 +====== cp ======
 +  * -p 表示保留 permission,ownership,timestamp
 +  * -d 表示完整複製 symlink and hard link
 +  * -R 表示複製子目錄與特殊屬性的檔案 (socket, pipe line file)
  
 ====== tar ====== ====== tar ======
行 177: 行 210:
   # uname -snrvm > /var/run/motd   # uname -snrvm > /var/run/motd
   # [ -f /etc/motd.tail ] && cat /etc/motd.tail >> /var/run/motd   # [ -f /etc/motd.tail ] && cat /etc/motd.tail >> /var/run/motd
 +
 +====== SSH 不檢查 key ======
 +~/.ssh/config
 +  StrictHostKeyChecking no
 +
 +====== 備份指令 ======
 +===== bash =====
 +http://blog.wu-boy.com/2006/12/10/52
 +<code>
 +#!/bin/bash
 +date=`date +%Y-%m-%d`
 +RETENTION_PERIOD="7"
 +HEADER="Backup data"
 +remove_oldfiles(){
 +        echo "Removing directory $1 files older than $RETENTION_PERIOD days"
 +| wall
 +        find $1 -type f -mtime +$2 -exec rm '{}' \;
 +}
 +
 +BACKUPDIR="/home/appleboy /var/www/html"
 +back_www_dir="/backup01/www_data"
 +
 +#
 +# 開始備份
 +#
 +
 +cd $back_www_dir
 +
 +for TARGET in $BACKUPDIR
 +do
 +        echo "System backup on $TARGET" | wall
 +        BASENAME=`basename $TARGET`
 +
 +        tar -zcvf ${BASENAME}-${date}.tar.gz $TARGET 1>/dev/null
 +        sleep 2
 +done
 +
 +#
 +# 刪除7天前的資料
 +#
 +remove_oldfiles $back_www_dir $RETENTION_PERIOD
 +</code>
 +
 +====== Run commands on multiple machines ======
 +Fanout and Fanterm: http://blog.wu-boy.com/2010/01/08/1950/
 +
linux/basic.1176917593.txt.gz · 上一次變更: (外部編輯)