顯示包含「ubuntu」標籤的文章。顯示所有文章
顯示包含「ubuntu」標籤的文章。顯示所有文章

2010年9月1日星期三

Ubuntu 10.04 上, 定時用ClamAV 掃毒並 email log

安裝
$ sudo apt-get install clamav



更新病毒庫
$ sudo freshclam


設定cron

$ sudo vim /usr/local/bin/virus_scan.sh


#!/bin/bash
# ----------------------------------------------------------------------
# Virus scan with ClamAV
# ----------------------------------------------------------------------

# Disabling PATH improves the security of the script
unset PATH

# Declare the variables
ECHO=/bin/echo;
DATE=/bin/date;
FRESHCLAM=/usr/bin/freshclam;
CLAMSCAN=/usr/bin/clamscan;
LOG_FILE=/home/user/clamscan.log;
SCAN_FOLDER=/;

# Start the log entry
$ECHO Complete system virus scan starting >> $LOG_FILE;
$DATE >> $LOG_FILE;
$ECHO \* >> $LOG_FILE;
# Update Virus definitions
$FRESHCLAM >> $LOG_FILE;

# Run the scan
$CLAMSCAN -ri $SCAN_FOLDER >> $LOG_FILE;

# Finish the log entry
$ECHO \* >> $LOG_FILE;
$ECHO Complete system virus scan finished >> $LOG_FILE;
$DATE >> $LOG_FILE;
$ECHO \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* >> $LOG_FILE;

$cat clamscan.log | mail -s "ClamAV Scan" someone@server.com
$rm clamscan.log


設定限權

sudo chown root /usr/local/bin/virus_scan.sh
sudo chmod u=rwx /usr/local/bin/virus_scan.sh
sudo chmod go= /usr/local/bin/virus_scan.sh


把shell加到 crontab 內

sudo vim /etc/crontab

20 3 * * * root /usr/local/bin/virus_scan.sh



# 記得更改 LOG_FILE , SCAN_FOLDER
# 想用gmail寄可參考 ubuntu 10.04 上,透過 gmail 用命令列寄信


shell 修改自http://ubuntuforums.org/showthread.php?t=631293

ubuntu 10.04 上,透過 gmail 用命令列寄信

$ sudo apt-get install heirloom-mailx msmtp
$ vim ~/.mailrc

set from="YOURNAME@gmail.com (YOURNAME)"
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"

$ vim ~/.msmtprc

defaults
logfile /home/USER/msmtp.log

# gmail account
account gmail
auth on
host smtp.gmail.com
port 587
user YOURNAME@gmail.com
password YOURPASSWORD
from YOURNAME@gmail.com
tls on
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt

# set default account to use (not necessary with single account)
account default : gmail

$ chmod 600 ~/.msmtprc
$ echo "Hello, world!" | mail -s "Test from command line" -a attachment.txt somebody@somedomain.org


ssmtp也有相同作用, 但ssmtp會把帳密以明碼存在/etc/下,會增有gmail被帳號被盜。


參考
How To Use Gmail Account To Relay Email From a Shell Prompt
在 Ubuntu 8.04 上透過 gmail 用命令列寄信

2009年1月18日星期日

把firefox 設為ubuntu 的 default browser


./firefox.exe -silent -setDefaultBrowser


firefox.exe 是program file 下的 , 而非安裝檔。

2009年1月17日星期六

my conky config


# Conky sample configuration
#
# the list of variables has been removed from this file in favour
# of keeping the documentation more maintainable.
# Check http://conky.sf.net for an up-to-date-list.

# set to yes if you want Conky to be forked in the background
background yes

# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
#font 7x13
#font 8x13
#font 9x15
#font *mintsmild.se*
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-*

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
xftfont Bitstream Vera Sans Mono:size=8

# Text alpha when using Xft
xftalpha 0.8

# Print everything to stdout?
# out_to_console no

# MPD host/port
# mpd_host localhost
# mpd_port 6600
# mpd_password tinker_bell

# Print everything to console?
# out_to_console no

# mail spool
mail_spool $MAIL

# Update interval in seconds
update_interval 5.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window no

# If own_window is yes, you may use type normal, desktop or override
own_window_type desktop

# Use pseudo transparency with own_window?
own_window_transparent yes

# If own_window_transparent is set to no, you can set the background colour here
own_window_colour black

# If own_window is yes, these window manager hints may be used
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 280 5

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Draw borders around graphs
draw_graph_borders no

# Stippled borders?
stippled_borders 8

# border margins
border_margin 4

# border width
border_width 1

# Default colors and also border colors
default_color white
default_shade_color black
default_outline_color black

# Text alignment, other possible values are commented
#alignment top_left
#alignment top_right
alignment middle_right
#alignment bottom_right
#alignment none

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 12
gap_y 12

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer none

# Allow each port monitor to track at most this many connections (if 0 or not set, default is 256)
#max_port_monitor_connections 256

# Maximum number of special things, e.g. fonts, offsets, aligns, etc.
#max_specials 512

# Maximum size of buffer for user text, i.e. below TEXT line.
#max_user_text 16384

# Timing interval for music player thread, e.g. mpd, audacious
#music_player_interval (update_interval is default)

# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument


own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager


# stuff after 'TEXT' will be formatted on screen
TEXT
${font Bitstream:size=14}${color1}${time %Y-%m-%d %A}
${font Radio Space:size=55}${color1}${time %H:%M}
${voffset -15}${font ConkyWeather:size=36}c ${font Verdana:size=15}${voffset -5}${execi 3600 conkyForecast --location=CHXX0049 --datatype=LT} / ${execi 3600 conkyForecast --location=CHXX0049 --datatype=HT}
$stippled_hr
${font Verana:style=Bold:size=9}HDD Temperature: ${font Verana:size=8}${execi 3 ~/.conky/gethddtemp.sh}
${font Verana:style=Bold:size=9}GPU Temperature: ${font Verana:size=8}${execi 3 nvclock -T | grep "temperature" | grep "[0-9][0-9]" -o}°C
${font Verana:style=Bold:size=9}CPU Temperature: ${font Verana:size=8}${acpitemp}°C
${font Verana:style=Bold:size=9}CPU1: ${font Verana:size=8}${cpu cpu1}% ${cpubar cpu1}
${font Verana:style=Bold:size=9}CPU2: ${font Verana:size=8}${cpu cpu2}% ${cpubar cpu2}
${font Verana:style=Bold:size=9}RAM Usage:${font Verana:size=8}$color $mem/$memmax - $memperc% ${membar}
${font Verana:style=Bold:size=9}Swap Usage:${font Verana:size=8}$color $swap/$swapmax - $swapperc% ${swapbar}
$stippled_hr
${font Verdana:style=Bold:size=9}Name PID CPU% MEM
${font}${color #ddaa00} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${font}${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${font}${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${font}${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
${font Verdana:style=Bold:size=9}Mem usage
${font}${color #ddaa00} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
${font}${color lightgrey} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${font}${color lightgrey} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
${font}${color lightgrey} ${top_mem name 4} ${top_mem pid 4} ${top_mem cpu 4} ${top_mem mem 4}
$stippled_hr
${font Verana:style=Bold:size=9}IP Address: ${font Verana:size=8}${addr eth0}
${font Verana:style=Bold:size=9}Total Download: ${font Verana:size=8}${totaldown eth0}
${font Verana:style=Bold:size=9}Total Upload: ${font Verana:size=8}${totalup eth0}
${font Verana:style=Bold:size=9}Up Speed: ${font Verdana:size=8}${upspeed eth0} Kb/s ${font Verana:style=Bold:size=9}Down Speed: ${font Verdana:size=8}${downspeed eth0} Kb/s
$stippled_hr
${font Verana:style=Bold:size=9}BOINC:
${font Verana:style=Bold:size=9}${execi 10 perl ~/.conky/boinc.pl}
$stippled_hr
${font Verana:style=Bold:size=9}$nodename - $kernel on $machine

2008年12月29日星期一

把UBUNTU WUBI 轉移到 正式的 EXT3 partition

假設你只有一個ntfs ( window)的 文件系統( partition), 本文將會介紹如何使用 LVPM (Loopmounted Virtual Partition Manager ) 轉移到 正式的 EXT3 文件系統。

第一步 : 分割一個新的文件系統
我將會使用 UBUNTU 的Live CD來分割 一個新的文件系統。當然你也可以用其他工具分割。
  • 使用Live CD開機
  • 按系統, Partition Editor
  • 選目前的文件系統, 按 "Resize"
  • 按 "Apply"
  • 在"未使用空間"內, 創造兩個新的文件系統。 其一為 SWAP, 大小約2000MB; 其二為 EXT3, 使用全部剩餘空間
  • 按 "Apply"

第二步 : 安裝與使用LVPM
  • 進入Wubi 的 UBUNTU
  • 到這下載最新的LVPM, 並進行安裝
  • 在LVPM的對話框內, 選"TRANSFER" , "sda3"(按你的硬碟位置而定, 可到"硬碟分割處理器"查看 )
  • 重新開機
  • 在GRUB內, 選新的UBUNTU。 如果顯示"Error 17: Cannot mount selected partition." 則繼續下一步; 沒有的話, 你已經成功了 ^^
  • 按"e"修改指令。把 "root ()" 改為 "root (hd0,2) " hd0指第一隻硬碟, 2指第3個文件系統, 請按自已的環境更改。
  • 進入新的ext3 ubuntu 後, 請到" /boot/grub/menu.lst" 把 新的 "root ()" 改為 "root (hd0,2) "
  • 完成了^^



原文参考: http://www.saltycrane.com/blog/2008/08/notes-moving-ubuntu-wubi-standard-ext3-partition-using-lvpm/

2008年12月15日星期一