Archives For command skills

internet speed test

Want to test your internet bandwidth without opening web browser? Well, here’s command line tool to do this using speedtest.net.

This may be help if you’re on Ubuntu Linux servers that doesn’t have a GUI. The tool is based on Python 2.4-3.3, so it works on all Canonical supported Ubuntu releases.

To install the tool, speedtest-cli:

1.) First install python-pip, a tool for installing and managing Python packages. To do so, run below command:

sudo apt-get install python-pip

2.) Install speedtest-cli via python-pip:

sudo pip install speedtest-cli

Once installed, you can use one command to test your internet bandwidth. The command is:

speedtest

You’ll see the similar output, which display you internet bandwidth as well as ISP & IP address.

Retrieving speedtest.net configuration…
Retrieving speedtest.net server list…
Testing from M-net Telekommunikations GmbH (88.217.180.40)…
Selecting best server based on ping…
Hosted by InterNetX GmbH (Munich) [2.23 km]: 18.756ms
Testing download speed………………………………….
Download: 7.81 Mbit/s
Testing upload speed…………………………………………..
Upload: 3.46 Mbit/s

NRG A .nrg file is a proprietary CD image file format used by Nero Burning ROM. In Ubuntu Linux, you can easily convert the .nrg to .iso file using the command line tool nrg2iso.

nrg2iso is available in Ubuntu universe repository. You can install it using Ubuntu Software Center. Or run below command if you’re on Ubuntu Server without GUI:

sudo apt-get update; sudo apt-get install nrg2iso

Once installed, you can convert .NGR file to .ISO via one command. For example:

nrg2iso image.nrg image.iso

That’s it. Enjoy!

If you’re dual booting Ubuntu with Windows 7 or other Operating Systems, you may wish to change boot order to set which OS starts by default. Well, In this tutorial I’ll show you how to do it in Ubuntu 13.10 Saucy and 13.04 Raring.

grub2 boot loader

There’s a GUI (graphical user interface) tool for editing Grub 2 boot loader, it called Grub-Customizer. You can install it in Ubuntu using the PPA repository. To do so, press Ctrl+Alt+T to open terminal, then run below commands one by one:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer

sudo apt-get update

sudo apt-get install grub-customizer

With Grub-Customizer, highlight the OS entry and click up / down arrow button to change its order. Or set the default OS in General Settings tab.

change boot order via grub customizer

If you’re comfortable with running some terminal commands, it’s not difficult to change default OS without installing any third-party program.

1.) Press Ctrl+Alt+T to open terminal. Edit the “/etc/default/grub” via below command and change GRUB_DEFAULT=0 to GRUB_DEFAULT=saved. This will make it easy to change default OS later.

sudo gedit /etc/default/grub

2.) Update grub to apply changes to grub configuration:

sudo update-grub

3.) After that, you can run sudo grub-set-default with the number of menu entry to boot (the first entry is 0) at any time, which will set the entry as default OS permanently. Or run sudo grub-reboot only for next boot.

For example, below command will set Windows 7 as default OS (Windows 7 is 4 in picture at top) permanently.

sudo grub-set-default 4

This simple tutorial shows you how to repair your Windows 7 boot loader (MBR) from Ubuntu dual boot or Ubuntu Live CD / USB. This can be useful if you don’t have a Windows CD or DVD on hand.

To do so, first boot into your Ubuntu system. When you’re in Ubuntu, press Ctrl+Alt+T on your keyboard to open terminal and follow below steps:

1.) First run below command to check your disk:

sudo fdisk -l

The output tells you the disk information:

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x016c8108

Device Boot Start End Blocks Id System
/dev/sda1 * 63 39054014 19526976 7 HPFS/NTFS/exFAT

2.) Now run commnad to install syslinux, which is a suite of lightweight IBM PC MBR bootloaders for starting up computers with the Linux kernel.

sudo apt-get update; sudo apt-get install syslinux

install syslinux to fix mbr

3.) Once installed, you can fix your Windows bootloader by running below command in terminal:

sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda

Replace the startup disk name /dev/sda in the above command according to the output in step 1.

repair-mbr

Enjoy!

This simple and brief tutorial will show you how to backup live CD or DVD to iso image on Ubuntu Linux using dd command.

dd is a command on Unix and Unix-like operating systems whose primary purpose is to convert and copy a file. On Unix, device drivers for hardware (such as hard disks) and special device files (such as /dev/zero and /dev/random) appear in the file system just like normal files; dd can also read from (and in some cases write to) these files. As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining fixed amount of random data.

To make iso image out of CD or DVD:

Insert your live CD or DVD into computer, then you can check the device name by running below command:

df -lh

You’ll get a similar output. The last line tells the device name /dev/sr0 and mount point /media/handbook/CD-Rom

Filesystem Size Used Avail Use% Mounted on
/dev/sda6 92G 47G 41G 54% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 870M 4.0K 870M 1% /dev
tmpfs 176M 980K 175M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 878M 3.5M 874M 1% /run/shm
none 100M 56K 100M 1% /run/user
/dev/sr0 807M 807M 0 100% /media/handbook/CD-Rom

Now, use below command to create iso from it:

dd if=/dev/sr0 of=~/backup.iso bs=1000000 count=512 &&sync

Here if reads from file /dev/sr0, of write to file backup.iso, ~/ means user home directory. The value of ‘bs’ means read and write up to 1000000 bytes at a time.

For more, run:

man dd