Friday, May 23, 2008

Linux commands and tricks

Just Commands:
sleep X -
sleeps for X seconds
chroot -
root to selected dir
slocate - find file from database suppressing all permission warnings.
which - shows where
specified program is located in PATH
w - show who is logged on and what they are doing
tput - change cursor location, colour, text format.


Change last entered command:
^what_to_change^how_change - changes last entered command.
$:man bash
$:^ba^c ( that will give - man csh )

Changing default shell:
/etc/passwd holds starting shells for each user on machine.

Auto Mounting:
/etc/fstab holds all devices that should be mounted automatically.
/dev/sda3 /win ntfs defaults 0 0
Script commands:
enable - execute program
source - include other file to current script


Switching workspace in command line:

GNOME DESKTOP
  • [ program wmctrl needed ] ( yum install wmctrl )
  • wmctrl -s desktopNum
Restoring GRUB loader:

Restoring GRUB:
  • Boot from live CD(say knoppix)
  • mount /dev/sda1 /media/sda1
    (mount system)
  • chroot /media/sda1
  • grub-install /dev/sda
    ( or /dev/sdaNUM, where NUM is partition )
OR
  • mount /dev/sda1 /
    (mount system)
  • grub
    ( opens grub terminal )
  • find /boot/grub/stage1
    ( shows partitions where grub is installed )
  • root (hd0,partNum)
    ( partNum you can get from previous command, hd0 - means first hard disk, hd1 will be second.. )
  • setup (hd0)
    ( if grub has to be installed to MBR. Or [ setup (hd0,partNum) ] - installs GRUB to linux root partition)

No comments: