Tuesday, January 5, 2010

Continue stalled scp file transfer session

Stalled scp file transfer session will happen when the network connection is unstable. You can see the status of the session at the message shown at your stdout like below:

file1 3% 136MB 0.0KB/s - stalled -


To continue back the file transfer, you can use this command at a new terminal, but make sure both the server and client have rsync installed:

$ rsync --partial --progress --rsh=ssh username@server:/path/to/remote-file /path/to/local-file

For example, if the transfer of file1 is stalled for user abu:

$ rsync --partial --progress --rsh=ssh abu@master:/home/abu/file1 /home/abu/file1

The scp transfer process will continue transferring the file

file1 4% 136MB 300.0KB/s 2:03:17 ETA

Saturday, November 14, 2009

Creating specific sized file

To create a specific sized file, dd command can be used. Example below will create a file named output with 10M size:


$ dd if=/dev/zero of=output bs=1M count=10
where bs is block size, and count is number of blocks to be created

The output:

$ ls -lh output
-rw-r--r-- 1 user user 10M 2009-11-14 06:21 output

Friday, November 13, 2009

Splitting big files

To split big files, split command can be used. Below is command used to split 400MB file named bigfile into 100MB chunk files named smallfile0*


$ split -b 100M -d --verbose bigfile smallfile
creating file 'smallfile00'
creating file 'smallfile01'
creating file 'smallfile02'
creating file 'smallfile03'
where -b is for byte size, -d is for numeric suffixes and smallfile is the prefix to be used

The output is:
$ ls
bigfile smallfile00 smallfile01 smallfile02 smallfile03

To recover back the splitted files into a file named newbigfile:
$ cat smallfile0* > newbigfile


Tuesday, September 29, 2009

Restore GRUB

GRUB is a boot loader commonly used with linux operating system. It can be used to managed dual boot environment where linux and windows can coexist easily in a same machine without problem provided you install the windows OS first so that when you install linux, GRUB will overwrite Windows boot loader and automatically detect and manage both operating system the next time you boot your computer. Problems will happen if you alter your partitions outside the knowledge of GRUB, for example, you create new partition in your hard drive using windows. This will cause GRUB to automatically go into GRUB shell when boot. To restore back your GRUB is very simple, just follow easy steps below:

1. find in which partition does GRUB store its configuration file, which is your /boot partition. (hd0,2) means third partition of the first hard drive
grub> find /boot/grub/stage1
(hd0,2)

2. set the root for GRUB to be (hd0,2)
grub> root (hd0,2)

3. write GRUB to the Master boot record(MBR) of your hard drive. Change (hd0) to (hd0,2) to write GRUB to your /boot partition instead
grub> setup (hd0)

4. Reboot machine
grub> reboot

All those steps can also be used using livecd, if let say the grub shell did not come out but you cannot boot your machine or you cannot boot your linux due to messed up GRUB. just boot from livecd, open a terminal, and type "grub" as a superuser to go to GRUB shell

Thursday, August 6, 2009

Mounting Windows shared folder on linux

Mounting windows shared folder on linux is very easy provided you know the ip of the windows machine, the name of the folder that is being shared, the username and password of the windows machine. As far as I know, there are 2 ways you can mount your windows shared folder on your linux machine.

The first way:

For gnome user, type Ctrl+F2, and type smb://windows_machine_ip/shared_folder_name. For example, see below picture


You can access the folder from Places


The second way:

Using command line;

sudo mount -t cifs //windows_machine_ip/shared_folder_name /directory_to_mount -o username=username,password=userpassword

example for mounting a shared folder named MP3 on 192.168.1.110 using windows username usin and password 123456 to /home/user/mp3:

$ sudo mount -t cifs //192.168.1.110/MP3 /home/user/mp3 -o username=usin,password=123456

Your shared folder now can be accessed from /home/user/mp3


That's all friends :)