วันพุธ, มีนาคม 09, 2554

How-To Find the IP Address in used in the network (ip scanner) in Ubuntu

In ubuntu I want to find the used IP address, want to find who is use prohibited static IP address.

$sudo apt-get install nmap

Just that :) then

Here's the sample command line:-

IP Scanning with range 192.168.0.0 – 192.168.0.255
$ sudo nmap -sP 192.168.0.0/24

IP Scanning with range 192.168.0.1 – 192.168.0.254
$ sudo nmap -sP 192.168.0.1-254

Port Scanning with range port 100 – port 139
$ nmap 192.168.0.3 -p100-139

Scanning Operating system on target IP
$ sudo nmap -O 192.168.0.3

nmap Faster Execution
If you want to make faster scan, use -T4 option on nmap command..
$ sudo nmap -A -T4 192.168.0.3


reference: http://taufanlubis.wordpress.com/2007/10/20/ip-and-port-scanning-using-nmap-network-mapper-in-ubuntu/

วันอังคาร, มีนาคม 08, 2554

Shrink/Compress a VirtualBox Windows Guest Machine

Window guest image file (.vdi) eaten up the hard disk space. Check inside the Window guest; there're much of free spaces, didn't took so much of spaces as allocated on the host machines.
  So, I got bad mood!, my HDD's spaces was running out -_-" then I found this article "Shrink/Compress a VirtualBox Windows Guest Machine" (find the link at the bottom of the post)

  1. Open the window guest 
  2. Then use SDelete, small utility from MS themself.
    1. extract sdelete into windows directory
    2. open the command line terminal
    3. execute sdelete -c
    4. follow on-screen instruction
  3. close the VM
  4. use VBManage command to compact the vdi file
    1. VBoxManage modifyhd  .vdi --compact
  5. Hooray! :D

reference:
1 from http://r3dux.org/2010/10/how-to-shrinkcompress-a-virtualbox-windows-guest-machine/
2  VirtualBox help
  • With the --compact option, can be used to compact disk images, i.e. remove blocks that only contains zeroes. This will shrink a dynamically expanding image again; it will reduce the physical size of the image without affecting the logical size of the virtual disk. Compaction works both for base images and for diff images created as part of a snapshot. For this operation to be effective, it is required that free space in the guest system first be zeroed out using a suitable software tool. For Windows guests, you can use the sdelete tool provided by Microsoft. Execute sdelete -c in the guest to zero the free disk space before compressing the virtual disk image. Please note that compacting is currently only available for VDI images. A similar effect can be achieved by zeroing out free blocks and then cloning the disk to any other dynamically expanding format. You can use this workaround until compacting is also supported for disk formats other than VDI.

วันพฤหัสบดี, มีนาคม 03, 2554

HOWTO Configure SSH for passwordless logins

HOWTO Configure SSH for Passwordless Logins (Succeed/Tested on Ubuntu)
Do these on client pc (machine that will make a connection to a remote server)

Step 1 - 
$ ssh-keygen -t rsa
Note: Enter when it asking for the passphrase

Step 2
$ ssh-keygen -N '' -f ~/.ssh/id_dsa

Step 3
$ ssh-copy-id [remote-server]
i.e.: ssh-copy-id root@172.16.0.88

Step 4
$ ssh [remote-server] 'chmod 700 .ssh'
i.e.: ssh root@172.16.0.88 'chmod 700 .ssh'

Step 5
Test connecting..it will not ask for password anymore 
$ ssh [remote-server]
ssh root@172.16.0.88

    I have more than a server for this pc to make the connection so I repeat step 3 thru step 5 for each remote machines. Don't need to repeat step 1, 2 and don't do that.


from http://fak3r.com/geek/howto-build-your-own-open-source-dropbox-clone/ 

วันพุธ, มีนาคม 02, 2554

Calibre server; howto sync repository between local & remote server


  1. Install calibre in desktop pc, building my ebooks library
  2. Move default Calibre's repository to another place i.e.: calibre-repo
  3. Add the books as much as you want.
  4. Copy folder calibre-repo to the a remote server
  5. Use rsync program to synchronize the repository between a desktop (which always add a new book from here) and the remote server

    Command line

    To sync/copy the refresh repository data to the remote 

    rsync -r -a -v -e "ssh -l " :/remote/path /local/path

  6. On remote server I'm starting calibre server with this command
    calibre-server --daemonize --auto-reload --pidfile=$HOME/calibre.pid --port=8012 --with-library=$HOME/calibre-repos
    headless start, background process no need the GUI environment.
  7. After first deployment, whenever I want to update the remote's repository I will execute the command in #5
  8. For sure, I will restart the calibre process;(#6)
  9. To restart the calibre process use
     kill -9 `cat HOME/calibre.pid`
    then execute the command in #6 again


Reference: 


$rsync -r -a -v -e "ssh -l " --delete :/remote/path /local/path

from: http://www.cyberciti.biz/tips/linux-use-rsync-transfer-mirror-files-directories.html


$rsync -avz --stats  /tmp/dir1/ /tmp/dir2

from: http://www.unixtutorial.org/2008/09/how-to-synchronize-directories-with-rsync/