HACKED BY MAHYAR_BINAME
Ubuntu 11.10 by default has Linux Kernel 3.0. The Linux Kernel version 3.2 was released weeks ago and comes with lots of bugs fixes and huge improvements like Ext4 supports block sizes up to 1MB, which decreases the time spent doing block allocations, upper limits of CPU time can now be set in the process scheduler, lots of Btrfs improvements and much more. If you are reading this article update your Kernel to 3.2 to experience all these improvements and bug fixes.
We are going to upgrade to Linux Kernel 3.2 via PPA.
Go to terminal and type the following commands:
sudo add-apt-repository ppa:francisbrwn9/kernels sudo apt-get update sudo apt-get dist-upgrade
To verify the upgrade use the following command to see the Linux Kernel version:
The if and else condition is used in decision making in shell script. If the given condition is true, the command is executed otherwise won’t. Condition is the comparison between the values. For example, you have seen in some websites, “Enter only if you are 18+”. If you click on Yes you can enter into the website and if you click No you won’t be allowed to enter the website.
The expression that will be used in shell scripting are:
1. “-gt” = Greater than
2. “-lt” = Less than
3. “-eq” = Equals to
4. “-ne” = Not equals to
3. “-ge” = Greater than or Equals to
4. “-le” = Less than or Equals to
The syntax for “if” statement is:
if test condition
this command will be executed
Let’s just take a simple example of 18+ websites. The simple logic is, if you are 18 and older, you are allowed to enter otherwise not.
echo "Enter your age:: \c" read age if test $age -ge 18 then echo "You are allowed to enter" fi
If the user enters the age greater than or equals to 18 he/she will be prompted will the message “You are allowed to enter” and If the user enter the number less than 18 the program will exit. See this, to run and execute this file. Let me show you the output.
Now, add the else statement to the if statement.
echo "Enter your age:: \c" read age if test $age -ge 18 then echo "You are allowed to enter" else echo "You are not allowed to enter" fi
Now, if you input the number less than 18 you will be prompted will the message “You are not allowed to enter”.
Nested or Multilevel If..Else Statement:
If you have to work on more than two conditions you will use Nested if else statement. Here’s the simple script that you will make you familiar with nested if..else statement.
#!/bin/sh echo "Enter the age of your child: \c" read age if test $age -le 1 then echo "Use mother's milk" elif test $age -le 5 then echo "Baby is growing up" elif test $age -le 10 then echo "Really grown up" else echo "**Age should be less than or equals to ten only**" fi
This is a simple script. See the output below.
Ubuntu has choose to implement Unity as its default desktop and netbook interface instead of classic GNOME since Ubuntu 11.04 Many users are obssesed with unity. Linux users have lot of flexibility. There are still lots of desktop environment you can choose you can always change to KDE, XFCE, Windowmaker, Openbox, LXDE, Enlightenment. Rozor-qt is new desktop environment in the list.
Razor-qt is advance, easy-to-use and fast develop environment based on QT technologies. I have just installed and tested it in Ubuntu 11.10 and the test went quite positive.The light weight, impressive look, easy customization and most of all working standard with old machine are some reason to try Razor.
Razor is available for wide amount of Linux distribution. Ubuntu user can install it with the following ppa
sudo add-apt-repository ppa:razor-qt sudo apt-get update sudo apt-get install razorqt
For Other Linux distribution check the installation guide here
Razor Qt welcome you with a decent look with a lot of common interface like KDE.It KDE is installed in your system it will user the current KDE theme However there is no any KDE dependencies. The source code size is just 5.8 MB and is most useful and recommended for old machines.
The user see the following screen after they login.(I have remove clock plugin and change wallpaper).The panel at botton of the screen contain dkestop switch application menu on the tray. The time information at left side of the panel provides easy navigation. The panel can be easily switch to top and bottom by right clicking the panel and click on “Show the panel at”
Application Menu provide easy access to the application that is install in your system.The menu is quite similiar to windows xp classic menu.
The different plugin can be added by right click on the panel>>Addplugin and a dialogue box will pop up showing several plugin. User can search the plugin, simply select it and add in their machine.
Razor settings is divided into two portion Razor Desktop configuration and Razor session Configuration.
Razor desktop configuration provides easy to use interface to change certain aspect of your desktop. Razor session configuration help user to arrange several basic setting, default application setting, auto start application setting. The modules can be enable and disable with just click.
This tutorial is continue to the how to write, save and execute the shell script. If you are already a programmer, then you are already familiar with the word variable. Variable is something that stores the value temporarily. We can store anything in the variable and later call that variable. Also, we can ask to the user to input something and store the inputed value in variable. Variable holds anything, anything means: numbers, characters and strings. Value is assigned in the variable. The syntax to create the variable and assign the value to it is:
Simple variable example:
The string “Hello Everyone!!” is assigned to the variable called var1. The value of var1 is retrieved by using $var1. As you already know, the output of this shell script is “Hello Everyone!!”.
How to ask for user input:
You can actually make shell script interactive. You can ask the user for input and do some cool things. Here’s how we do it:
#!/bin/bash echo "Enter your name:" read name echo "Welcome $name to the world of penguins."
The first line ask the user to enter his or her name. Then, whatever the user entered is stored in the variable name. So, the second line actually stores whatever the user entered. And, the last line displays what need to be displayed. See the output:
There are various things you can do with this. Let me do another simple one. My shell script will ask the user to “Input the command” and Execute whatever command the user inputs and at the end of the line, it will display the message. “Thank you.” First of all, try it yourself if you don’t get it look below.
#!/bin/bash echo "Input your command:: \\c " read command $command echo " \\n Thank you!!"
First of all, don’t let yourself get confused with \\n and \\c. The \\n gives the line spacing and \\c skips the line spacing. As the user inputs the command it is stored in command variable and $command execute the command that user inputs. See the output and you will find out.
Things to be considered while defining variable:
1) Must begin with alphanumeric and underscore(_) only.
For example: ##hello=12 in invalid.
2) Linux is case-sensitive, thus the variable too.
For example: NO=2 and no=2 are different.
3) No spaces at all on either side of equals to sign.
For example: hello =2, hello = 2, hello =2 are invalid
4) Do not name you variable with strange characters like ‘#’, ‘!’, ‘~’, ‘*’ etc.
For example: #hell!, ~ok, &ih are invalid.
Last thing, it’s not mandatory though. While assigning string to a variable assign as var=”Hello”, while assigning character assign as var=’a’ and while assigning number assign as var=10. It is a sort of standard to all other programming languages as well.
You have just entered or executed more than one command at a time using two ways in how to run multiple commands at same time. There are two ways to do it. In the second way, instead of writing the command in terminal directly we wrote the command in a file, save it and later executed it. This is what Shell Scripting or Shell programming is. The shell scripting is a combination of lots of commands to do some powerful things. Shell Scripting also makes you familiar with computer programming. If you already have a knowledge of computer programming, it’s going to be more easy and quick for you. If you don’t have don’t worry walk with us. In this tutorial, I will explore on the following topics:
What is Linux shell?
Shell is a terminal where we(user) interacts. We all are very familiar with the terminal or the shell. Someone may argue, I don’t use terminal so I don’t interact with the shell. Then, that someone completely wrong, even if you are working on the graphical view the command are executing in the hidden manner. You don’t see it but it’s happening. There are various shells available in Linux. Some are pre installed in your system other’s you can installed by yourself. Find out how to install shell in Linux.
To find the shell you are working on, go to terminal and type:
Find out the more usage of echo command.
The output will look like this:
As we can see I am working on the bash shell.
What is shell script?
Shell script is simply a file, which contains a group of commands. We simply store all the commands in the file. Instead of executing the command individually, the file is executed which means all the commands in it are executed at once like a program. Shell Script is written a plain text file using any editor. We can use nano, gedit, vi editor, cooledit etc.
Why shell script?
By now, you should yourself have the answer for this question. The shell scripts can execute lots of commands at once. We don’t have to type each command individually. We can also ask for the user input and execute the input using shell script. Shell script will definitely saves us a lot of time. A simple application can be created by using the shell script.
How to write shell script?
Let’s go formally on this one: The shell script always start with:
#!/bin/sh OR #!/usr/bin/sh
This means the script file is executed by sh which is under the bin directory. The script file works fine without writing this line as well but not recommended.Here’s the simple script file:
How to save shell script?
Now, the shell script is ready, save it as: filename.sh. Sh reminds that the file contains scripts and is a script file. You can save the file in .txt extension as well but not recommended. I will save my file as:
How to run shell script?
As we saved the file in the extension .sh the system understands it as a script file and to make the file secure all the permissions are blocked. So, first we need to add permission to the script file as:
chmod ugo+rwx myfirstscriptfile.sh
This will add read, write and execute permission to all the level of users. Read more about user permissions. Now, to execute the file, type:
In order to execute my file I would type:
You can also execute the script file using:
Here’s the output of the script file:
As, you can see the first line and second line is printed exactly the way we have written. “ls” command listed all the directories and files and at last “Thank you” is printed.
The multiple number of commands can be executed at once in Linux terminal using two different ways. Both the ways are too simple. The one way among the two introduce us to the Shell Scripting. Yes, I have been talking a lot about shell scripting. Well, it starts now! Let’s focus on how to run multiple command at same time. I recommend, if you are not familiar with the Linux commands see our other various tutorials which will make you familiar with the various Linux commands. Also, see the cool things that you can do in the terminal like watching games, playing movies and all.
This one is very simple. You just need to separate the commands which semi colon. After you are done, hit enter and all your commands will execute. The syntax is:
command; command; command; command
The commands ls, cat hello and ls -l are executed. The first command “ls” listed all the directories, “cat hello” read the file hell0 and “ls -l” commands listed all the files and directories in detail with permission. See, the various things you can do with ls command and cat command.
Instead of executing the command from terminal we will first store the commands in a text file and later execute that file. This is called shell script. Shell simply refers to terminal and script means command that do something. Thus, shell script is nothing just a bunch of commands written in a text file.
First let us create a file using cat utility with commands in that file:
We created a text file called shscriptexample and put three commands in that file. This file is now called script file.
How to execute script file:
The syntax for executing script file is:
As you can see, the result is same. The shell script makes the Linux shell more powerful. To perform specific task, you can create your own script file and execute that file. I am going to cover more tutorials on shell scripting.