Posts

Showing posts from April, 2008

Linux - Methods to mount Samba

[smbmount] smbmount -o username="Username",password="Password" //IP/share /mnt/smb smbumount /mnt/smb [mount] mount -t smbfs -o username="Username",password="Password" //IP/share /mnt/smb umount /mnt/smb [cifs] mount -t cifs -o username="Username",password="Password" //IP/share /mnt/smb umount /mnt/smb mount.cifs -o username="Username",password="Password" //IP/share /mnt/smb umount.cifs /mnt/smb

Linux - network monitor (iftop)

Image
iftop does for network usage what top does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth usage by pairs of hosts. Handy for answering the question "why is our ADSL link so slow?". 查看ppp0網路介面的即時流量: $ iftop -i ppp0 以位元組(bytes)為單位顯示流量(預設是位元bits): $ iftop -B 直接顯示IP, 不進行DNS反解: $ iftop -n 直接顯示連接埠編號, 不顯示服務名稱: $ iftop -N 其他參數可下 iftop -h 看說明. 進入iftop畫面時, 可按 p 切換是否顯示連接埠, n 切換顯示IP或主機的domain name, N切換顯示連接埠代號或名稱, p暫停顯示, b切換是否顯示長條, B切換計算幾秒內的平均流量, 其他按鍵可以按h觀看說明. 設定檔的位置在~/.iftoprc , 關於設定檔的寫法可以參考 iftop 的 info page.

Open Source Guide

Image
Open Source Guide is a site that is here to share the amazing open source software currently around the net. We offer a directory of open source software so we can all benefit from what the open source community has to offer.

Open Source Hardware Inventory Management Software

OCS Inventory NG , Open Computers and Software Inventory Next Generation is an application designed to help administrator keep track of the computers configuration and installed softwares. Low network traffic HTTP communications between agents and server. I’m currently testing this software and I will update all of you about my results. PcInventory Web-based system to track the Pc and the installed peripherals. phpMyInventory is a web-based hardware, software, and peripheral inventory system using PHP & MySQL. Currently stable on PHP version 4xx only! Windows Inventory . A Computer Hardware and Software Inventory system. Based around wmi, vbscript, mysql & php. Expandable via modules to include software distribution, remote control, event viewer, disk monitoring, etc.

Using Samba to join a Windows Domain

Using Samba to join a Windows Domain

SAMP (Solaris, Apache 2, MySQL 5, and PHP 5) Setup for Solaris

SAMP (Solaris, Apache 2, MySQL 5, and PHP 5) Setup for Solaris 10 OS and Solaris Express

OpenSSH for Windows

OpenSSH for Windows

Western, do you know what you are fighting for?

As a Chinese in Hong Kong, I don't realize the situation of Tibet indeed. I just saw from news that the Tibetans attacked the civilians. It was not demonstration, but insurrection and crime. How do you think about the situation of Ireland in Britain, and Basque in Spain? Is it any double standard?

Tibet under China

Linux - Apache DoS/DDoS mod

mod_evasive is an evasive maneuvers module for Apache to provide evasive action in the event of an HTTP DoS or DDoS attack or brute force attack.

Linux - redirect/rewrite http to https for a specified directory

<Virtualhost> ... <Location "/cacti"> RewriteEngine on Options +FollowSymLinks Allow from all RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] <⁄Location> ... <⁄Virtualhost>

Linux - Restart NFS server when network link down

Image
WARNING! Using restart option (i.e. service nfs restart ) may crash / freeze your Linux computer if executed. start service in following order: # service nfslock stop # service nfs stop # service portmap stop # umount /proc/fs/nfsd start service in following order: # service portmap start # service nfs start # service nfslock start # mount -t nfsd nfsd /proc/fs/nfsd

勤力是我密友

在溫室泛舟 誰又記得奮鬥 走出門口 原來越冷越長壽 逆流便向上游 微笑者可得救 難過更過不好以後 *逆境出對手 時運也講節奏 高手能守 然後自有然後 上游亦勝下流 能吃苦都不瘦 迎接猛風就當盪韆鞦* #勤力是我密友 陪著我走過最驚險時候 朝著明日走呀走 強橫要天也佩服地拍手 勤力令我自幼 無常中得到自信的成就 胸懷大過四海人潮任我游#

MySQL Proxy Load balancing and Failover Tutorial

MySQL Proxy Load balancing and Failover Tutorial

Linux - monitor MySQL Tools

$ mysql -u admin -p 123456 mysql> show status; mytop is a console-based (non-gui) tool for monitoring the threads and overall performance http://jeremy.zawodny.com/mysql/mytop/ $ mytop -u admin -p 123456 $ mytop -u admin -p 123456 -d phpbb You can store this information in ~/.mytop file: vi ~/.mytop Add config text as follows: user=admin pass=123456 host=mysql0.hosting.some.com db=imail delay=10 port=3306 socket= batchmode=0 header=1 color=1 idle=1 mtop (MySQL top) monitors a MySQL server showing the queries which are taking the most amount of time to complete. mkill (MySQL kill) monitors a MySQL server for long running queries and kills them after a specified time interval. Queries can be selected based on regexes on the user, host, command, database, state and query. http://mtop.sourceforge.net/ innotop is designed to monitor InnoDB transactions and internals, replication status, deadlocks, general queries and status values, and much more. http://sourceforge.net/projects/innotop/

Linux - Procedure to convert a running single disk servers to software RAID1

Remote Conversion to Linux Software RAID-1 for Crazy Sysadmins HOWTO

Linux - rebuilding a RAID array after a disk fails

Assuming that new SCSI disk is /dev/sdb, type the following command: # raidhotadd /dev/mdX /dev/sdb Replace /dev/mdX with actual raid device name (e.g. /dev/md0). While array is under construction, you can see progress and other information by typing following command: # cat /proc/mdstat

Linux - Setting up RAID 1 on running system.

Config was as follows: /dev/hdb (/dev/hdb1 40 GB) /dev/hdc (/dev/hdc1 40 GB) Each partition has been 40 GB size ext3 formatted (make sure partition id is set to Linux raid auto). RAID tools and software was installed. It is called mdadm. Remember first software device will be /dev/md0, second will be /dev/md1 and so on You need to type following command to setup /dev/md0: mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hdb1 /dev/hdc1 You can see status, health of /dev/md0 at /proc/mdstat. Type the following command: cat /proc/mdstat Better uses watch command to refresh it automatically: watch cat /proc/mdstat Format /dev/md0 as ext3 fs: mkfs.ext3 /dev/md0 Mount /dev/md0 at /data2 directory: mkdir /data2 mount /dev/md0 /data2 Don't forget to add /dev/md0 to /etc/fstab: vi /etc/fstab Append following text: /dev/md0 /data2 ext3 defaults 0 0

Linux - copy master boot record (MBR)

dd if=/dev/sda of=/dev/sdb bs=512 count=1

Linux - How do you take a single line of input from the user in a shell script?

Image
One line is read from the standard input (keyboard), or from file descriptor FD if the -u option is supplied, and the first word is assigned to the first NAME, the second word to the second NAME, and so on, with leftover words assigned to the last NAME. Syntax: read {variable-name} read -p {’Prompt text’} {variable-name} Read single line of input from the user and store to variable called dbname: read dbname OR read -p 'Enter Database name : ' dbname To display variable value, enter: echo $dbname Sample shell script

Linux - IP Address Allocation Table script

If you need a tabular representation of relationships and source of the various variables representing a chunk from /32 to /0 subnets use iptab command. This is useful if you are allocating IPs to end users. $ iptab Sample output: +----------------------------------------------+ | addrs bits pref class mask | +----------------------------------------------+ | 1 0 /32 255.255.255.255 | | 2 1 /31 255.255.255.254 | | 4 2 /30 255.255.255.252 | | 8 3 /29 255.255.255.248 | | 16 4 /28 255.255.255.240 | | 32 5 /27 255.255.255.224 | | 64 6 /26 255.255.255.192 | | 128 7 /25 255.255.255.128 | | 256 8 /24 1C 255.255.255.0 | | 512 9 /23 2C 255.255.254.0 | | 1K 10 /22 4C 255.255.252.0 | | 2K 11 /21 8C 255.255.248.0 | | 4K 12 /20 16C 255

Linux - Subnets Calculator

If you need to calculate subnet under Linux use an IP Netmask/broadcast calculator called ipcal & sipcalc. [a] ipcalc : ipcalc takes an IP address and netmask and calculates the resulting broadcast, network, Cisco wildcard mask, and host range. By giving a second netmask, you can design sub- and supernetworks. It is also intended to be a teaching tool and presents the results as easy to understand binary values. [b] sipcalc : Sipcalc is also an ip subnet calculator consisting of two parts. A plain text based console version, and web (cgi) based counterpart. Sipcalc, in it’s simplest form takes an ip-address and a subnet mask on the commandline and outputs information about the subnet. Sipcalc has support for both IPv4 and IPv6 addresses. Let us see how to calculate subnets for 192.168.0.1/24: $ ipcalc 192.168.0.1/24 Output: Address: 192.168.0.1 11000000.10101000.00000000. 00000001 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000