Starting with Bash
If you want to start with bash, chances are that you might be already using it or if you have changed the default shell, chances are that bash is still running somewhere in your system. Let's see a few simple commands to start with bash.Check date:
$ date Fri Mar 27 17:03:26 EDT 2009 $The above command will give the date. Now let's see this:
$ whoami root $If you get this output, logout and login again as an ordinary user. If you misuse this authority, you can cause serious harm to your system.
To start bash programming, you can write your code in a file and execute it. E.g. you can open vi editor as follows:
vi filenameIn vi editor, you can type your code and after saving your file, you can make it executable as follows:
$ chmod 755 filenameNow, to execute the file:
$ ./filename $Now we will make our first bash program, named first.
$ vi firstAnd then we type our code:
#!/bin/bash echo My first bash programThe first line indicates which program to use to run the file. It tells that the program is bash and it's location. The second line contains the code to be executed. When you execute this file, the commands will be:
$ chmod 755 first $ ./first My first bash program $If the bash is not located in the above location, you need to find out where your bash shell is located. The command for the same is:
$ whereis bash bash: /bin/bash /etc/bash.bashrc /usr/share/bash /usr/share/man/man1/bash.1.gz $
