how to use Bash Shell in linux?

Using the Bash Shell 

Bash is a Unix shell written by Brain Fox for the GNU Project as a Free Software replacement for the Borne Shell(sh).Released in 1989, it has been distributed widely as the shell for the GNU Operating System and as a default shell on Linux and MAC OS X.
Command Line Shortcuts: 
Globing is wildcard expansion:-

Option
Description
Example
*
matches zero or more characters
# rm *mp3
all files in the directory have names ending in mp3 will be removed
?
matches any single character
#echo ?o*
{0-9}
matches a range of numbers
#ls -l {1,2,3,4}
it display all the files matches the list.




The Tab Key- type
 tab to complete command lines: for the command name, it will complete a command name for an argument, it will complete a file name
examples:
 #cle 
#clear
 #ls myfi 
#ls myfile.txt 

 History: 

1. bash stores a history of the commands you have entered, which can be used to repeat commands
 2. use history command to see list of "remembered" commands 

 examples: 

#history 
#!! repeat last command
#!char repeats last command that start with char
#!num repeat a command by its number in history output
#!?abc repeats last command that contains abc 
#!-n repeat a command entered n command back use ^old^new to repeat the last command with old change     to new 
#cp myfil.txt /aa/bb/cc
#^myfil.txt^myfile.txt

more history tricks-

1. use the up and down keys to scroll through previous commands
 2. type Ctrl-r to search for a command in command history

 to recall last argument from previous command:
 Esc. (the Escap key followed by a period)
Alt-. (hold down the alt key while pressing the period)
 !$ (only valid for the last command)
 Command Line Expansion-
Tilde (~)
May refer to your home directory

 #cat ~/filename

 2. May refer to another user's home directory
 #ls -l ~john/filename

Command and Braced sets:
1. command Expansion: $() or ``
prints output of one command as an argument to another

 #echo "this system's name is $(hostname)"
#echo this system's name is `hostname`

 2. Brace Expansion: { }
 #echo file{1,2,3}
 #rm -f file{1,2,3}

Bash Variables-

1. variables are named values useful for storing data or command  output
2. set with VARIABLE=VALUE
#x=5

3. referenced with $VARIABLE

 example:
#HI="Hello, and Welcome to the IIJT Computer Education Ltd"
 #echo $HI

Command Editing tricks

 1. Ctrl+a moves to beginning of line
 2. Ctrl+e moves to end of line
 3. Ctrl+u deletes to beginning of line
 4. Ctrl+k deletes to end of line
 5. Ctrl_arrow moves left or right word

 gnome terminal- 
1. Application->Accessories->Terminal
 2. Graphical terminal emulator that supports multiple "tabbed" shells.

 1. Ctrl+shift+t create a new tab
2. Ctrl+pgup/pgdn switch to next/prev tab
3. Ctrl+Shift+c copies selected text
 4. Ctrl+Shift+v pastes text to the prompt
5. Shift+pgup/pgdn Scroll up and down a screen at a time

 Scripting Basic-

1. shell scripting are text files that contain a series of commands or statement to be executed.
2. shell scripting are useful for:
1. automating commonly used command
2. performing system administration and troubleshooting
3. creating simple applications
4. manipulating or text or files.

No comments:

Post a Comment