Basic Linux TutorialIntroduction – What is it? Why to learn? Linux installation directory structures Boot process Run levels in Linux Desktop Environments Different shells BASH Internal and External Commands Basic Linux Commands Important files and directories in Linux Environmental and Shell Variables Command history in Linux Character classes in Linux Text editors vim nano Searching files Creating new files Viewing File Contents File commands File permissions and ownership WildCards (Globbing) in files File compression Directory commands xargs command in Linux Comparing files Searching patterns using grep command Translating the characters using tr command Extracting data using cut command Stream editing using sed command Data extraction and reporting using awk command Sorting the file or string input uniq command in Linux Difference between grep, tr, cut, sed and awk commands Hardware commands Hard disk and memory space commands Working with Processes Managing Jobs Working with cron jobs Service command in Linux Network commands Managing Users and Groups Other Popular commands Standard streams and Redirection Pipes Package Managers in Linux
BASH in linux shellBASH is the default shell in most of the Linux operating systems. To launch new shell terminal in Ubuntu, you can use CTRL+ALT+T hotkey. You can SHIFT+CTRL+N to create a new terminal window. You can use SHIFT+CTRL+N hotkey to start new terminal tab within existing window. You can check what shell you are running by using below command.
If you see the output as /bin/bash, it means that you are using the BASH Shell. To find out all commands starting with specific letter or letters, you can type the letter and press the TAB key twice. Also you do not need to enter the full directory or file name. You can type first few characters of the file and then press tab key. BASH will auto complete the file name automatically provided it is able to identify the file uniquely. For example – let us say we have 2 directories with name bigcities and bigcountries. Then to change the directory to bigcities, you can use below command.
and then press TAB key. Directory name will be auto-completed. But if type only “big” and then press TAB key, name will not be auto-completed because BASH does not find the unique directory name. To exit the shell you can use below command
You must know below things when working with BASH.
- CTRL+c – This hotkey sends SIGINT singal (Interrupt signal) to the application. It is up to the application if it has to terminate itself.
- CTRL+z – This hotkey sends SIGTSTP singal (Stop signal) to the foreground application. Application is sent to the background in suspended mode.
- You can view all application that are in background using jobs command.
- CTRL+a – sends the cursor to the start of the command line.
- CTRL+e – sends the cursor to the end of the command line.
- CTRL+u – Cut the left portion of command from the cursor position.
- CTRL+k – Cut the right portion of command from the cursor position.
- CTRL+r – Search for the commands from command history and execute it.
- ALT+. – Access the last argument of previous command on the command line.
- CTRL+w – Delete one word from the command line
Some interesting stuff about running commandsWe can run 2 commands one after another using below syntax.
If you want to run second command only if first one is successful, you can use below syntax.
cmd1 ; cmd2
If you want to run second command only if first one fails, you can use below syntax.
cmd1 && cmd2
You can run the command in background using below syntax.
cmd1 || cmd2
Web development and Automation testing