Sunday, February 3, 2013

how to mention a user in sudoers list

Most the time when we add a new user to group and try to run sudo command on that user,we encounter error :

             this user is not present in the sudoers list

to solve this problems we have to easy methods.
one can be used while creating a new user,and another is for those who have already created the user and are wondering to use sudo with that user.


First we will go with the those who have already created the user :

  1. login with a use who is already present in the sudoers list
  2. open the teminal window and type in sudo adduser username sudo.
and you are set.

now lets come to those who want to create a new user and mention it in the sudoers list:

  1. you have to add option while creating a new user.
  2. just add the option -G sudo in the useradd command.
  3. for eg. useradd -u 500 -g dba -G sudo -d /home/oracle oracle

basically sudo is a group and all the users present in this group will have the full control over the sudo command.we are just adding the user to the sudo group.

resolving the error **Unexcpected Operator** in shell scripts

In Some Linux systems the full functionality of the sh or bash shell is not available.So to solve this we have to follow a few steps:

  1. open the .sh extension script file you are working with.
  2. find the clause #!/bin/sh. in most of the scripts its the very first line,
  3. just replace the #!/bin/sh with #!bin/bash.
  4. save the file and open the terminal window
  5. navigate to the directory where the file is present .
  6. now execute the command  bash ./filename.sh
and that's it , you are done with the error.