Saturday, October 10, 2015

Linux Commands

1 MOUNT A DOS PARTITION
$sudo fdisk -l               -shows all partitions
$sudo mount /dev/sda9 /mnt/DATA1  -mount partition sda9 as noted from fdisk -l to the directory /mnt/DATA1 which is already created

2 UNMOUNT
$sudo unmount /mnt/DATA1

3 VIEW ALL MOUNTED PARTITIONS
$cat /etc/mtab

4 CHANGE DEFAULT BOOT OS in GRUB2
$gksudo gedit /etc/default/grub
modify GRUB_DEFAULT=<> and save the file
$sudo update-grub

5 MOUNT A .ISO FILE
$sudo mkdir /mnt/iso
$sudo mount -o loop //.iso /mnt/iso

...

$sudo umount /mnt/iso


6. ADD A GRUB ENTRY IN BOOT MENU TO BOOT A .ISO FILE IN HARD DISK
PRE-REQUISITE:
i. GRUB IS ALREADY INSTALLED
ii. Any version of UBUNTU/MINT LINUX already installed

a. Boot into Linux an open a terminal
b. $gksudo gedit /etc/grub.d/40_CUSTOM
   append the following lines 

menuentry "Ubuntu 12.04 ISO" {
 Set isofile="/downloads/ubuntu/ubuntu-12.4-desktop-i386.iso"
loopback loop (hd0,msdos9)$isofile
      |
      |--> equivalent to sda9 partition

linux (loop)/casper/vmlinux boot=casper iso-scan/filename=$isofile noprompt noeject
initrd (loop)/casper/initrd.lz
}

b. save 40_custom file
$sudo update-grub

when you boot now, this 40_CUSTOM menu should be available in GRUB menu

7. TO BOOT FROM AN UBUNTU .ISO FILE IN HARD DISK WITHOUT ADDING AN ENTRY IN GRUB 
a. Reboot machine and press C in GRUB menu page
b. grub> ls  <-- know the partitions available
c. ls (hd1,mdos9)       <-- check label to confirm the partition
                            that has to the .iso file to boot
d. ls (hd1,msdos9)/ press tab <-- all files are displayed
                                  locate the .iso file
e. run each line from line 35 above (containing Set isofile="/down.." with this file path 
   If no messages are displayed on entering the command, then it means the command ran successfully
f. grub> boot


 ---------------
Add system wide PATH  and environment vars
-------------------------------------------------
open terminal
$ su 
add new file myenvvars.sh in /etc/profiled/ 
(eg. if you want to add jdk and maven path add below) after restart this works

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_77
export M2_HOME=/opt/apache-maven-3.3.9
export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH


-----------
Set bash in vi mode (by default it will be in Emacs key shortcut mode
$ set -o vi 



No comments:

Post a Comment