Showing posts with label gedit. Show all posts
Showing posts with label gedit. Show all posts

Saturday, February 9, 2013

Basic of Shell Programming

Why shell?
Even though there are various graphical interfaces available for Linux, the shell still is a very neat tool. The shell is not just a collection of commands but really good programming language. You can automate a lot of tasks with it. The shell is very good for system administrator tasks. You can quickly try out if your idea which makes it very useful for simple prototyping and it is very useful for small utilities that perform some relatively simple tasks where efficiency is less important than ease of configuration, maintenance and portability.
Let's see how it works:
Creating a script file:-
There are two ways to create a script file, i.e. we can save script file with .sh extension that will indicate that it's a shell file or we can write “#!/bin/sh” at the very first line. The “#!” character tells the system that the first argument that follows on the line is the program to be used to execute this file. In this case “/bin/sh” is shell we use. And for creating script file we can used any text editor like GEDIT, VI editor etc.
Variables:-
As we know every programming language needs variables, without variables it’s next to impossible to do programs. But in shell programming we don't have data types. All variables are of string data types and we don't need to declare it, to assign values to variables. Syntax is as follows:-
Variable_name=value
Even we don't need terminator operator to end statement, actually its optional, you can used it if you want.
Examples:-
str=”This is shell Programming ”
num=169
You can also print the values of variables by just using “$” symbol in front of variables.
echo “values of num is=$num”
It will print value of num that is 169 on the screen.
Comments:-
In Shell programming we can use comments for user understanding using # symbol at first of your statements.
Example:-
#This is my first shell program.
#Program based on Linux.
Reading values from Keyboard:-
This is very important to take values from user, as I mention above shell programming doesn't have data type so we don't need to specify which type of values we need to read. To read values from keyboard just use “read” command as given below:-
echo "Enter value for A"
read A
echo "Enter value for B"
read B
C=`expr $A + $B` - Line5
echo "Addtion is =$C"
Now, here some more things come at Line5 that is back quotes and expression (expr). To do any kind of calculation we have to follow this procedure.
In shell programming we have many things to do, but above things are the basic which we have to know at the initial stage of shell programming. For more information you can search it on www.google.com or you can also mail me on panditdilipr@gmail.com .

Friday, January 18, 2013

Install Packages from Non-Admin Account in Linux Distro



In my last blog “Add user account to root in Ubuntu”, I had written about how we can add or give all root access to any account. Now in this blog I will explain you that how to give only installation access to any Non-Admin account. After giving this access to non-admin account, the user of this account can install as well as remove any packages to and from Non-Admin account.
This is one of most important trick for those Companies and Organization whose Admin is not able to install and removes each packages from every PC’s of each employee.
To use gedit you have to do following:

Open the Terminal and type:

       sudo gedit /etc/sudoers

 
If you want to use vim you can simply enter the following into the Terminal:

        sudo visudo

When you used the “sudo visudo” command in terminal the “sudoers” file is open in terminal with vim editor.
   
Once you have the sudoers file open, scroll down to the line:
   
         root   ALL = (ALL)ALL
After this, on next line of above statement writes following configuration,
         UserName ALL=NOPASSWD : /usr/bin/apt-get , /usr/bin/aptitude
You can change username with your non-Admin account name, save the sudoers file and logout from root account and try to install packages from non-Admin account.

Monday, September 17, 2012

Add User Account to root in Ubuntu


Whenever we create any user account which doesn't has the authority of the “sudo” (Super user do) command, then that user account doesn't have any kind of permission to do anything with System. But as per the future requirement, we have to give the permission of “sudo” Command to the user account. Now how to do this?
 There are two ways to do this activity, first from the account that has the permission to used “sudo” command or the second way is from the root. Now what you have to do is just open the “sudoers” file which is located at /etc/sudoers using your favorite text editor.

    To use gedit you have to do following:

    Open the Terminal and type:

    sudo gedit /etc/sudoers

    If you want to use vim you can simply enter the following into the Terminal:

    sudo visudo


Fig. Opening sudoer file in vim editor
When you used the “sudo visudo” command in terminal the “sudoers” file is open in terminal with vim editor.
   
Once you have the sudoers file open, scroll down to the line:
   
root   ALL = (ALL)    ALL

Add the following line below the root line (replacing “user” with the name of the account you wish to give sudo access to)

user   ALL = (ALL)    ALL


Fig.2 Adding user account to root
For example, your account name is “Admin”, then simply replace the user with Admin.

Admin  ALL=(ALL)  ALL

Save and close the file.  The new user has now been added.