w3reference home
Shell Tutorial


Bookmark and Share

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 filename
In vi editor, you can type your code and after saving your file, you can make it executable as follows:
$ chmod 755 filename
Now, to execute the file:
$ ./filename
$
Now we will make our first bash program, named first.
$ vi first
And then we type our code:
#!/bin/bash          
echo My first bash program
The 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
$
Code Validator
Learn FTP
Color finder
Link Checker
Free web designs
Coming soon!
Interview Questions...
'w3reference : Learn by examples ... Advanced to beginner's tutorials ...'
Ajax: AJAX tutorial1 | Apache: Apache HTTP Server | Restarting Apache | CSS: CSS Border | CSS Syntax | CSS Selector | CSS Comment | CVS: CVS Release | CVS Login | CVS Logout | CVS Annotate | Databases: Rolap Tutorial | OLAP Tutorial | OLTP Tutorial | data warehousing | Expect: HTML: html | Linux: Dot (.) conf files | Linux Mount Point | Linux Filesystem | SSH Tutorial | Linux Commands: cal | cat | cfdisk | chroot | MySQL: MySQL Commands | PHP: PHP Basics | PHP Variables | PHP Output (echo/print) | PHP String Concat | PL/SQL: PL/SQL Data Types | PL/SQL Control Structures | PL/SQL File Extensions | PL/SQL DBMS_OUTPUT package | Python: My first Python program | Shell: Starting Bash | Bash Redirection | Bash Pipes | Bash Variables | SQL: SQL Transactions | SQL Constraints | SQL Drop | SQL Union & Union All | SVN: svn architecture | SVN Repository | SVN Import | SVN Checkout | Tech: soap | Web Designing: Web Hosting | HTML/XHTML/CSS code validator | Learn FTP | Search Engine Optimization Tips | www: XML: XML vs HTML | XML Syntax | XML Tags, Elements and Attributes | XML Namespaces |
Sitemap | Disclaim | Privacy Policy | Contact | ©2007-2009 w3reference.com All Rights Reserved.