Archives For command skills

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

How to Flush DNS Cache on Ubuntu 13.04, 12.10

Last updated: July 18, 2013

This simple tutorial will show you how to flush or clear your system’s DNS records on Ubuntu 13.04 Raring and 12.10 Quantal.

Objectives:

  • Flush DNS records on Ubuntu 13.04 or Ubuntu 12.10
  • Enjoy!

To get started, press Ctrl+Alt+T to open a terminal window.

Open Terminal to run commands

Then run command to flush dns:

sudo /etc/init.d/dns-clean restart

You can also use this command:

sudo /etc/init.d/networking force-reload

In addition, to flush nscd dns cache:

sudo /etc/init.d/nscd restart

To flush dnsmasq dns cache:

sudo /etc/init.d/dnsmasq restart

download

This tutorial shows you how to mount / access VMware Virutal Machine File System (vmfs) on Ubuntu (non host).

VMFS is a clustered filesystem designed to store virtual machine disks for VMware ESX or ESXi Server hosts. There is a command line tool for Linux that allows to access VMFS filesystems from some other non ESX/ESXi host for e.g. maintenance tasks.

First install this tool by searching and installing the package from Ubuntu Software Center. Or run the command below:

sudo apt-get install vmfs-tools

Find you vmfs partition by running this command:

sudo fdisk -l

Then mount vmfs with this tool. For example, /dev/sdb3 is the vmfs that we want to mount. We’re going to mount it to /mnt directory. Run this command in terminal (Ctrl+Alt+T):

sudo vmfs-fuse /dev/sdb3 /mnt/

After that, browser with Nautilus file browser.

Enjoy!