28 June, 2010

important bash commands for system administration


As you know the terminal is the power tool that every linux user may have to come in contact even once in their computer life. Here is a post about controlling and managing your system using the gnome terminal.

How to shut down the system
 

$shutdown -h now

The word 'now' is enough to shutdown the system at this instant itself. You must be sudo before executing this command. You can specify the time instead of the word 'now' so that the system will shut after that time limit. Other  valid  formats  are  +m,  where m is the number of minutes to wait until shutting down and hh:mm which specifies the time on the 24hr clock.

       -r     reboots the system after shutdown

       -h    Requests  that  the system be either halted

              or powered off after it has been brought 
              down

       -c    Cancels  a  running  shutdown.   TIME is not 

              specified with this option, the first     
              argument is MESSAGE.

       -k    Only send out the warning messages and 

              disable  logins,  do  not actually bring the 
              system down.

How to take the root shell prompt
 

You can take the root shell prompt using the root password as follows

$ sudo su
 

How to switch between virtual consoles

In most debian based systems there are six switchable VT100-like character consoles available to start the command shell directly on the Linux host. Unless you are in a GUI environment, you can switch between the virtual consoles by pressing the Ctrl - Alt keys and one of the F1 --- F6 keys simultaneously. Each character console allows independent login to the account and offers the multiuser environment. You can get back to the X Window System, normally running on the virtual console 7, by pressing Ctrl - Alt - F7

Alternatively we can use the command chvt to  switch between virtual consoles from the command line
 

$ chvt  3        (switches to 3rd console )

 

How to quit the terminal

Press Ctrl + D to terminate the shell activity.



To create a new user account 


To create a new user account from the terminal type in as follows...


$ adduser carbon


This will add the user with name 'carbon'.  You can remove this user and it's home directory by using the following command.

$ deluser --remove-home carbon
 



Read rest of entry

23 June, 2010

How to recover Grub 2 in Ubuntu

The new versions of Ubuntu from 9.10 are preloaded with the new version of the Grub ie. Grub 2 as the default boot loader. Grub 2 has many modification over the previous versions. It is driven by a group of scripts in different directories in /boot and /etc. I have already blogged about configuring grub 2 to change the appearence, adding a background image etc... on to the boot loader menu in a previous post. This post is all about restoring the grub 2 in an occasion where you lost your current grub 2 boot loader overwritten by some other boot loader installation. This possibly occurs when you install multiple operating systems on a machine, and especially when some other OS after the Ubuntu. This is a simple and working tip, try it.



U should need following tools for this . . 

1. An Ubuntu Live CD (9.10 or any later versions)
2. The partition where your Ubuntu resides (that u are going to 
     restore), It should be something like /dev/sda12

 Follow the steps

Take the terminal and follow the steps 

$ sudo fdisk -l
  • Now, you need to remember which device listed is your linux distribution, for reference, /dev/sda1 will be used. Now weneed to mount the filesystem to/mnt
 $ sudo mount /dev/sda1 /mnt
  • If you have /boot on a separate partition, that need's to be mounted as well. For example /dev/sda2 is used here.
$ sudo mount /dev/sda2 /mnt/boot  

     Now mount the rest of your devices 

  $ sudo mount --bind /dev /mnt/dev
  • Now chroot into your system 
 $ sudo chroot /mnt

      You should be chroot'd into your system as root, you can now
       run commands as root, without the need for sudo.
  • Now edit the /etc/default/grub file to fit your system 
 $ nano /etc/default/grub
  • When that is done you need to run update-grub to create the configuration file. 
$ update-grub
  • Now install GRUB 2 to the MBR as follows
$ grub-install /dev/sda
  • If you encounter any errors, try 
    $ grub-install --recheck /dev/sda
  • Press Ctrl+D to exit out of the chroot.
  • Once you exit back to your regular console, undo all the mounting,
$ sudo umount /mnt/dev
$ sudo umount /mnt

(But if you have a separate boot partition which you mounted earlier, you have to unmount this first, or you will get a "device busy" error message.)
  • That's all you have to do with your Live CD. Exit the terminal and restart your machine.  
If you had alternate OS entries, update-grub might say "Cannot find list of partitions!". Ignore it and continue...
When rebooted the grub 2 boot loader will be ready for you. Don't worry if you don't see other operating systems that are already installed in your system. Once you can boot into your linux installation,  rerun update-grub and grub-install /dev/sda as root. This will add the entries of the other operating systems in to the current boot loader.



 


Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger