顯示具有 linux 標籤的文章。 顯示所有文章
顯示具有 linux 標籤的文章。 顯示所有文章

2013年6月13日 星期四

Linux常用指令

shutdown / reboot , reference from 鳥哥

重起sendmail
service sendmail stop
service sendmail start


重起apache

apache reset
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start


掛上一個裝置

mount -t ext3 /dev/sdb1 /mnt/data2
rm -rf *   刪除,recursive & force
cp -rf * ../data2  複製,recursive & force
fg

symboic link
ln -sf /mnt/data2 /mnt/db_disk
$ ln [參數] 來源檔案或資料夾 要建立的 link 名稱
沒有參數的時候是建立 hard link,沒辦法跨 file system,沒辦法 link directory
-s : symbolic link
-f : 要建立的 link 如果存在,會先移除掉再建立

[root@www ~]# ln -s /etc/crontab crontab2
[root@www ~]# ll -i /etc/crontab /root/crontab2
1912701 -rw-r--r-- 2 root root 255 Jan  6  2007 /etc/crontab
 654687 lrwxrwxrwx 1 root root  12 Oct 22 13:58 /root/crontab2 -> /etc/crontab

rm db_disk
umount /mnt/data
若是busy請離開/mnt/data工作目錄

要複製資料且保留權限要使用
tar cvf * -R
tar xvf 

SFTP to non port 22

注意: -oPort 參數要在前面,以避免某些程式解命令列參數時解錯。
解法範例:
sftp -oPort=6789 jjdai@example.com

2013年2月11日 星期一

根目錄的空間不足

遇到空間不足
/var/spool/mail
下有占了很多空間

可以使用
cp /dev/nulll /var/spool/mail/root 如此一來就直接清空
不可以直接刪除喔!!

要找出哪個地方占空間可以使下面的指令
du搭配sort可以快速地整理出
du -B M --max-depth=1 | sort -g

-B M,意思是統一以Mega(百萬位元組)為單位
--max-depth=1可以把子目錄的容量不顯示出來,但會加總到它的父目錄容量下

df -M
可以先看出裝置的使用狀態