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

2009年4月12日 星期日

7-Zip Command Line

the linux version of 7zip is called p7zip
usage of 7za in windows is totally same to 7za in linux
the help message of command line version isn't detailed enough so here is an example

7za a -t7z -m0=lzma -mx=9 -mfb=64 -md=64m filename.7z target

a: add files to archive
e: extract files from archive (without using directory names)
-t: type of archive
-m0 : compression algorithm
-mx : compression level, 0 = no compression, 9 = ultra
-mfb : number of fast bytes for LZMA
-md : dictionary size
-ms=on : solid archive

p7zip is able to extract rar archives, but you have to use the exact command 7z, neither 7za nor 7zr because they are light-weighted commands which don't load plugins

if you use ubuntu, there is a package named p7zip-rar. on arch linux, p7zip package also installs rar plugin to /usr/lib/p7zip/Codecs/Rar29.so

7z e filenamr.rar

2009年4月6日 星期一

Unify Encoding of MySQL Clients on Ubuntu

it solves encoding of phpmyadmin and mysql cli aren't same.

sudo vi /etc/mysql/my.cnf
--

[client]
default-character-set = utf8

2009年3月23日 星期一

Install WTorrent which is one of Web Interfaces of RTorrent on Ubuntu

1. wtorrent requires webserver( lighttpd or apache ), php, scgi module, sqlite, xmlrpc so install them

sudo apt-get install apache2 libapache2-mod-scgi php5 php5-sqlite libxmlrpc-c3

2. enable scgi module in apache

sudo a2enmod scgi

# a2dismod is to disable

a2enmod is the command which automatically create symbolic links for module_name.conf and module_name.load under mods-enabled from mods-available

3. add the following line to /etc/apache2/httpd.conf

SCGIMount /RPC2 127.0.0.1:5000

4. download wtorrent from http://www.wtorrent-project.org/trac/ and extract

unzip wtorrent.zip

5. move wtorrent to root of your webserver and and create necessary directory for wtorrent

mv wtorrent/ /var/www/

6. make sure necessary directories of wtorrent exist, torrents/, db/, tpl_c/ and conf/

mkdir /var/www/wtorrent/tpl_c/

7. change permission for wtorrent read and write usage

chmod -R 777 /var/www/wtorrent/

8. open install.php in your browser

http://localhost/wtorrent/install.php

9. delete install.php after proper installation

rm /var/www/wtorrent/install.php

2009年3月11日 星期三

Map Remote Servers into the Space of the Local Apache Server with Authentication on Ubuntu

1. delete symbolic link of the default proxy.conf

sudo rm /etc/apache2/mods-enabled/proxy.conf

2. make another copy of proxy.conf in the same folder, mods-enabled

sudo cp /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf

3. edit it

sudo vi /etc/apache2/mods-enabled/proxy.conf
--

ProxyVia On

ProxyPass /mirror/ http://address:port/
ProxyPassReverse /mirror/ http://address:port/

<Location /motion/>
AuthName "TITLE"
AuthType Basic
AuthUserFile /var/www/.htpasswd
require valid-user
</Location>

# ProxyPass causes a local request for the http://localhost/mirror/ to be internally converted into a proxy request to http://address:port/
# ProxyPassReverse provides location header on http adjusting which redirects http://localhost/mirror/sub/ to http://address:port/sub/ also

4. generate apache password file, /var/www/.htpasswd

sudo htpasswd -c /var/www/.htpasswd username

2009年1月4日 星期日

Set up a Webcam Security System on Ubuntu

1. plug your webcam into usb slot, some useful commands to diagnose hardware information

dmesg # print bootup messages
lsusb # list usb devices

2. install motion, the package provide motion detection for webcam or netcam

sudo apt-get install motion

3. modify configuration file

sudo vi /etc/motion/motion.conf
--
.
.
# Image width (pixels). Valid range: Camera dependent, default: 352
width 640

# Image height (pixels). Valid range: Camera dependent, default: 288
height 480
.
.
# The mini-http server listens to this port for requests (default: 0 = disabled)
webcam_port 8081
.
.
# Restrict webcam connections to localhost only (default: on)
webcam_localhost on
.
.

4. according to the above settings, you can watch live webcam only from localhost. i would to like to access it from anywhere with authentication, so i pick up mod_proxy to satisfy my needs

sudo cp /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf
sudo ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load
sudo ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load

5. map internal web pages to main apache web server

<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
AuthName "Live Webcam Server"
AuthType Basic
AuthUserFile /var/www/.htpasswd
require valid-user
</Proxy>
ProxyVia On
ProxyPass /motion http://localhost:8081
</IfModule>

to understand all parameters, please refer to http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

6. create a password file for the username

sudo htpasswd -c /var/www/.htpasswd username

7. nobody can access .htpasswd through http request just because of this section in /etc/apache2/apache2.conf

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>

2008年12月18日 星期四

Boot a Virtual Machine from command and Control it through Remote Desktop Protocol on Ubuntu

1. we will need VBoxHeadless command to run virtual machine in background, free version of virtualbox in ubuntu repository doesn't have it. so we need to install official version
from http://www.virtualbox.org/wiki/Linux_Downloads

complie VirtualBox Modules

sudo /etc/init.d/vboxdrv setup

2. set up your virtual machine completely through GUI, Applications -> System Tools -> Sun xVM VirtualBox. if you can't find the icon, just relog desktop environment after installed

change Settings -> Remote Display -> Enable VRDP Server
Authentication Method = Null

its unsafe but we will set something for security on windows later

3. command-line usage

start a virtual machine

VBoxHeadless -startvm "name"
or
VBoxHeadless -startvm "uuid"

poweroff a virtual machine

VBoxManage controlvm "name" acpipowerbutton

show info about a running virtual machine

VBoxManage showvminfo "name"

4. your login screen of guest windows has a shutdown button, it means anyone who connect to the right port can shutdown your machine. we have to hide it by changing the registry below

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\shutdownwithoutlogon -> 0

5. the last thing I must remind is remember to logout / switch user then windows will back to login screen. if you are afraid of forgetting to do so, try set screensaver with password protection. nobody can kick you if you are connecting and occupying the port.

2008年12月17日 星期三

Play restricted formats on Ubuntu

1. the package, ubuntu-restricted-extras supports for mp3 playback and decoding, various other audio formats, microsoft fonts, java runtime environment, flash plugin, lame, and dvd playback.

sudo apt-get install ubuntu-restricted-extras

2. about real media files like .rm .rmvb, you'll need w32 codecs because there is no native support in linux

adding the repositories

sudo wget http://www.medibuntu.org/sources.list.d/hardy.list --output-document=/etc/apt/sources.list.d/medibuntu.list

3. add the gpg key

sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update

4. install codecs

sudo apt-get install w32codecs

5. to play encrypted dvd, the libdvdcss2 package is essential. it is a simple library designed for accessing dvd without having to bother about the decryption

sudo apt-get install libdvdcss2

2008年12月13日 星期六

VirtualBox Open Source Edition on Ubuntu

1. install open source edition of virtualbox and its module

sudo apt-get install virtualbox-ose virtualbox-ose-modules-generic

2. from console output or /var/log/apt/term.log, you can see there is no matching virtualbox-ose module for kernel 2.6.24-22. virtualbox-ose-modules-generic is linked to kernel 2.6.24-21 so apt-get installs linux-image-2.6.24-21-generic automatically.

in short, we have to change default boot number of grub to kernel 2.6.24-21

sudo vi /boot/grub/menu.lst
--
default n

3. scim conflicts with virtualbox-ose. it results keyboard is locked in both host and guest os when you press key or mouse which is captuered in guest os. below is the solution

sudo apt-get install scim-bridge-client-qt
im-switch -z en_US -s scim-bridge

4. reboot then done

5. before sharing folders between host and guest, you must install Guest Additions. once installed it, go to Devices -> Shared Folders.. to set your sharing folders. if guest os is windows, run

net use x: \\vboxsvr\FolderName

2008年11月18日 星期二

Add image resizing and rotating to Gnome on Ubuntu

1. the package name is nautilus-image-converter, nautilus extension to mass resize or rotate images

sudo apt-get install nautilus-image-converter

2. logout and login again, or reboot, you will find right-click pop menu on image has the features we need

2008年11月17日 星期一

Set up a Tor relay node on Ubuntu

1. verify that your clock is set correctly

2. install tor

sudo apt-get install tor

3. make sure to define at least Nickname and the listening port, ORPort

sudo vi /etc/tor/torrc

--
.
.
SocksPort 9050 # what port to open for local application connections
SocksListenAddress 127.0.0.1 # accept connections only from localhost
.
Nickname ididnteditheconfig
.
RelayBandwidthRate 20 KBytes # Throttle traffic to 100KB/s (800Kbps)
RelayBandwidthBurst 40 KBytes # But allow bursts up to 200KB/s (1600Kbps)
.
ORPort 9001
.
.

5. restart tor to reload config

sudo /etc/init.d/tor restart

4. add this line to privoxy configuration file /etc/privoxy/config

forward-socks4a / localhost:9050 .

it means tor listens socks4a on port 9050
In the SOCKS 4A protocol, the DNS resolution of the target hostname happens on the SOCKS server, while in SOCKS 4 it happens locally.

5. according the default setting in /etc/privoxy/config

listen-address 127.0.0.1:8118

port 8118 should be used as http proxy

6. when your browser is set with privoxy proxy, you can check this website to verify

https://torcheck.xenobite.eu/


7. when you check log file, /var/log/tor/log
you may notice the warning message

MMM ddd hh:mm:ss.xxx [warn] Your application (using socks4 to port 80) is giving Tor only an IP address. Applications that do DNS resolves themselves may leak information. Consider using Socks4A (e.g. via privoxy or socat) instead. For more information, please see http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#SOCKSAndDNS.

2008年11月11日 星期二

Set up CACTI on Ubuntu

1. install cacti, it depends on many packages like snmpd, apache2, mysql-server

sudo apt-get install cacti

2. installation in progress
password of your database's administrative user: password of mysql administrator
mysql application password for cacti: leave it blank, cacti will create a random password
webserver type: apache2

3. visit the webpage of your cacti server, http://localhost/cacti
follow cacti installation guide in your web-browse

4. login with default username and password, admin / admin

5. Devices -> Add
Description: Give this host a meaningful description.
Hostname: localhost
Host Template: Generic SNMP-enabled Host
SNMP Version: Version 1
SNMP Community: public
create

6. Associated Graph Templates -> Add Graph Template
add any you need

7. Associated Data Queries -> Add Data Query
add SNMP - Get Mounted Partitions and SNMP - Interface Statistics
save

8. Create Graphs for this Host
select any items you need
create

9. Graph Trees -> Add
Name: A useful name for this graph tree.
create

10 Tree Item -> Add
Tree Item Type: host
Tree Item Value -> Host: choose what you just created
create

2008年11月1日 星期六

Could not update ICEauthority file /home/user/.ICEauthority

this error makes me fail to login gnome

1. boot into recovery mode
press ESC while loading grub

2. chown user:user /home/user/.ICEauthority

3. chmod 644 /home/user/.ICEauthority

4. shutdown -r now
restart

2008年10月29日 星期三

Install command-line BitTorrent client, RTorrent on Ubuntu

rtorrent is a text-based ncurses BitTorrent client

1. install rtorrent

sudo apt-get install rtorrent

2. because ubuntu package of rtorrent doesn't include default configuration file, it would result in a warning messege, couldn't not read resource file: ~/.rtorrent.rc
we have to create the file

vi ~/.rtorrent.rc

--
# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.

# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
#max_peers = 100

# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
#max_peers_seed = 50

# Maximum number of simultanious uploads per torrent.
#max_uploads = 15

# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 0
upload_rate = 180

# Default directory to save the downloaded torrents.
directory = ~/download

# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session = ~/.rtorrent/session

# Watch a directory for new torrents, and stop those that have been
# deleted.
#schedule = watch_directory,5,5,load_start=./watch/*.torrent
#schedule = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low.
#schedule = low_diskspace,5,60,close_low_diskspace=100M

# Stop torrents when reaching upload ratio in percent,
# when also reaching total upload in bytes, or when
# reaching final upload ratio in percent.
# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
#schedule = ratio,60,60,"stop_on_ratio=200,200M,2000"

# The ip address reported to the tracker.
#ip = 127.0.0.1
#ip = rakshasa.no

# The ip address the listening socket and outgoing connections is
# bound to.
#bind = 127.0.0.1
#bind = rakshasa.no

# Port range to use for listening.
port_range = 6890-6999

# Start opening ports at a random position within the port range.
#port_random = no

# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
#check_hash = no

# Set whetever the client should try to connect to UDP trackers.
use_udp_trackers = yes

# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
# encryption = allow_incoming,enable_retry,prefer_plaintext

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
#
dht = on

# UDP port to use for DHT.
#
dht_port = 6881

# Enable peer exchange (for torrents not marked private)
#
peer_exchange = yes

scgi_port = localhost:5000
encoding_list = UTF-8

#
# Do not modify the following parameters unless you know what you're doing.
#

# Hash read-ahead controls how many MB to request the kernel to read
# ahead. If the value is too low the disk may not be fully utilized,
# while if too high the kernel might not be able to keep the read
# pages in memory thus end up trashing.
#hash_read_ahead = 10

# Interval between attempts to check the hash, in milliseconds.
#hash_interval = 100

# Number of attempts to check the hash while using the mincore status,
# before forcing. Overworked systems might need lower values to get a
# decent hash checking rate.
#hash_max_tries = 10

3. create directory structure for the need of rtorrent resource file we just made

mkdir -p .rtorrent/session

4. type rtorrent to run rtorrent
about rtorrent operation, check out http://libtorrent.rakshasa.no/wiki/RTorrentUserGuide

2008年10月6日 星期一

Batch image resize script on Ubuntu

- be able to specify resolution of image
- create a folder to put resized images in


#!/bin/bash

printf "Batch Image Resize..\n"
read -p "width: " width
read -p "height:" height

[ -d resize/ ] || mkdir resize

ls -1 *.[jJ][pP][gG] | while read file
do
convert -scale ${width}x${height} "$file" resize/"$file"
[ -f "$file" ] && printf "$file\tOK\n"
done

2008年10月5日 星期日

Convert encoding of characters on Ubuntu


iconv input_filename -f input_encoding -t output_encoding -o output_filename

if input_filename is not specified, iconv reads from standard input.
if output_filename is not specified, the result is written to standard output.

2008年9月24日 星期三

Verify SFV listings on Ubuntu

sfv is simple file verfication.

1. download and install cksfv which is no longer in the repository

sudo dpkg -i cksfv_1.3.5-1_i386.deb

2. verify files listed in .sfv

cksfv -f filename.sfv

2008年9月18日 星期四

Run .Net applications on Ubuntu

1. you'll have to install wine and mono, standard compliant .NET compatible set of tools.

sudo apt-get install wine mono

2. run .net applications as common win32 program

wine /path/filename

3. you may suffer this kind of problem related to gdiplus.dll like below

wine: Call from 0x7b844b20 to unimplemented function gdiplus.dll.GdipCreateFontFamilyFromName, aborting

wine: Unimplemented function gdiplus.dll.GdipCreateLineBrushI called at address 0x7b844940 (thread 0009), starting debugger...

4. download gdiplus.dll from www.dll-files.com and put it in .wine/drive_c/windows/system32 then run again

2008年8月21日 星期四

MoBlock on Ubuntu

1. add moblock package path to /etc/apt/sources.list

deb http://moblock-deb.sourceforge.net/debian hardy main
deb-src http://moblock-deb.sourceforge.net/debian hardy main

2. add the gpg key

gpg --keyserver wwwkeys.eu.pgp.net --recv 9072870B
gpg --export --armor 9072870B | sudo apt-key add -

3. update package lists and install moblock and its front-end gui, mobloquer

sudo apt-get update
sudo apt-get install moblock moblock-control mobloquer

4. choose which blocklists to be loaded
http://tbg.iblocklist.com/Lists/
http://www.bluetack.co.uk/forums/index.php?autocom=faq&CODE=02&qid=17

ads-trackers-and-bad-pr0n.gz #advertising
bogon.gz #bogus IP announcements
dshield.gz #hackers
edu.gz #educational institutions
fornonlancomputers.gz #LAN IP ranges
hijacked.gz #IP blocks that are being used without permission
iana-multicast.gz #http://www.iana.org/assignments/multicast-addresses
iana-private.gz #http://www.iana.org/assignments/ipv4-address-space/
iana-reserved.gz #http://www.iana.org/assignments/ipv4-address-space/
level1.gz #for p2p users
level2.gz #general corporate
level3.gz #paranoid list
Microsoft.gz #Microsoft Corp ranges that are not on Level1
proxy.gz #various proxy servers
rangetest.gz #suspicious IPs
spider.gz #automated programs also known as spiders or bots
spyware.gz #malicious SPYWARE and ADWARE IP Address ranges
templist.gz #sending corrupt or virus p2p data

BusinessISPs.zip should not be loaded because most people are in the ranges.
fornonlancomputers.gz and Bogon.zip must be not selected if there is lan traffic with this host.

5. moblock usage (need root privileges)

moblock-control start - inserts iptables rules and starts MoBlock
moblock-control stop - deletes iptables rules and stops MoBlock
moblock-control restart - restarts MoBlock
moblock-control reload - rebuilds the blocklist and reloads MoBlock
moblock-control update - updates the blocklists and reloads MoBlock
moblock-control status - gives the iptables settings and the status of the MoBlock daemon
moblock-control test - simple test to check if MoBlock is working

6. the use of files in /etc/moblock

blocklists.list #blacklist
allow.p2p #whitelist
guarding.p2p #real ip database which should be blocked built from blocklists.list
moblock.conf #configuration file

7. log location

/var/log/moblock.log #block log
/var/log/moblock-control.log #moblock-control status log

8. you can reconfigure moblock withing reinstalling

sudo dpkg-reconfigure moblock


9. allow port 1863 for msn, 5050 for yahoo, 5190 for icq

vi /etc/moblock/moblock.conf

WHITE_TCP_IN=""
WHITE_UDP_IN=""
WHITE_TCP_OUT="80 443 1863 5050 5190"
WHITE_UDP_OUT=""
WHITE_TCP_FORWARD="80 443 1863 5050 5190"
WHITE_UDP_FORWARD=""

you have to set WHITE_TCP_FORWARD if you want to have same whitelist ports on lan or packets from lan computers will be dropped in moblock_fw chain

2008年8月17日 星期日

Video is too bright while playing on Ubuntu

1. xvattr is the tool to query or set XVideo settings

sudo apt-get install xvattr

2. to execute xvattr directly can show all xv attributes

3. set contrast to normal value via command line

xvattr -a XV_CONTRAST -v 64

4. there is a gui for xvattr, gxvattr

2008年7月10日 星期四

Reset gnome settings on Ubuntu

if you delete gnome panels accidently, these steps can help you reset all your gnome settings to default

1. logout

2. ctrl + alt + f1 to terminal console

3. rm -rf .gnome .gnome2 .gconf .gconfd .metacity

4. ctrl + alt + f7 to gui desktop

5. login