5. Get started with the bash

Now we can start with the command line. It is similar to the cmd.exe in windows! Command lines are always powerful than graphical interfaces. Bash shell is the default shell a Linux user can get ( we will discuss about shells later).
You can start a command line interface call gnome-terminal from application->system tools -> terminal. (from desktop right click open terminal also will do the same).
when you open a new terminal you will get a prompt like
[alimajaf@Server ~]$
where alimajaf is the user name Server is the shot of computer name and the $ prompt is given for a normal user. If you have logged in as root user you will get a prompt as follows
[root@Server ~]#
here $ is replace by # to make it more obvious that it is a super user.
Command Line Basics
----------------------
We can enter commands at the prompts. Basically a command has three parts
1. command : The name of the program to be run
2. options : describe the adjustable behavior of the command
3. arguments : the target on which the command has to run
Normally command will be followed by options normally start with single or two dashes (eg -a or --all) and it will be followed by the arguments.
You will get help on any command by typing
$ <command> --help
here the $ symbol indicates its a prompt, note that its not the part of the command syntax.
When you get help on any command when u see any syntax these are the basic conventions:
1. anything inside square bracket [] is optional
2. ... represents arbitrary length of what it follows
3. | represents OR
4. angle brackets <> represents variable data. <file-name> means you have to enter the actual file name over there.
Using Bash
-----------
We can start with some basic commands
. su - <user-name>
this command is used to switch the current user to the new user. All the permissions and privileges of the new user will be loaded to that shell. If you omit the user-name then the default user name will be root.
.id
command id with no option and arguments will give you the basic information about the current user.
. passwd [user-name]
passwd command is used to change the password of any user. but by default only root user can change the password of others. To change the self password it is not necessary to specify the username.
.exit
exit is used to exit from a shell. Its like logging out from the shell.
Note: we can use tab to auto-complete the commands and arguments. To get the history you can use the command 'history'. to access a particular command from the history we can use the command number
$ !45 -> will execute the 45th command from the history or
$ !pass -> will execute the latest command that start with pass
or even we can use up and down arrow keys to search in the history.
Launching Graphical Tools From Bash
------------------------------------
Simply type the command from the bash is enough to run it graphically.
$ gedit -> will run the gedit in graphical but the prompt will be locked. we would say the program is running forground of the terminal. If close the terminal the program also will close. If you want to run in background type one & symbol after the command. for eg. gedit &
We have some additional job control commands
ctrl+c : will terminate the foreground process completely
ctrl+z : it will suspend the the foreground program you can later make it run in the background on can kill completely.
jobs : it will list the background and stopped process with the shell with job id
fg : send a job in foreground. remember only one process can run in foreground
bg: send a job in background, with fg and bg job-id can be given to specify the job otherwise the current job will be considered.