2.1 A brief introduction to Linux Basics required for RHCSA
Welcome back, in the previous tutorial we discussed what RHCSA examination is all about, what is the cost for examination, why you should go for this exam, we also have installed RHEL machine which is registered with RHN, refer this link to review chapter-1. In this tutorial, we will understand Linux BASH shell, terminal basics and run few basics commands which will be required for day to day administration activities.
2.2 Accessing Linux command line
In this chapter we will include basic Linux essential tools which are must understand for a Linux Administrator. In RHEL 7 there are almost 2000 commands, so you need to understand how and when to use a particular command, although presently RHCSA examination includes GUI part too, but a true Linux Administrator is required to be a master of the terminal. The BASH or Bourne-again shell is the default shell for RHEL.At the end of this chapter, the user should be able to login to Server and will be able to execute basic commands using bash shell.
2.3 A Brief Introduction to BASH shell
The shell is the default working environment for Linux Administrators, it is a text based interface which gets instructions from a user and interprets the command entered by the user. Different shell for Linux are available but BASH or GNU Bourne-again shell is the default for Red Hat systems, bash shell uses two strings to symbolize the role of a user i.e. either user is ordinary user and can perform only limited tasks or a user is super user and can perform administrative tasks. The $ symbol indicated that user is nonprivileged user and # symbol indicated that user is a root or privileged user.
[rhcsa@unixmen]$ <- ordinary user
[rhcsa@unixmen]# <- root or superuser
The shell has an advantage that it can provide scripting language which is nothing but a combination of multiple commands in the form of a single script.
2.4 What are shell environment and environment variable?
All programs that run under Linux are called processes, these processes run continually, although you can kill the process using different commands when you start a program a new process is created and this process runs under an environment. A particular environment has some specific characteristics which the process can interact with. Every process runs under its own environment. Variable is a fixed name that can be assigned with dynamic values. Variable will have some name and a value.
To get overview of default working environment variables, type:
2.4.1 What is the virtual console?
User access the bash shell through terminal or console, Red Hat supports multiple consoles which can be logged in independently my different users in the same time; such consoles are called virtual console. This console can be accessed by holding CTRL+ALT and pressing function key from f1 to f6 e.g. hold CTRL+ALT and press f1, it will open a new screen when you can log in from a different user.
2.5 A brief Introduction to important Linux commands
In this chapter, you are required to understand basics commands only, as we will move ahead step by step you will start understanding complicated commands and scripts which are nothing but a combination of simple commands using pipes, filter or shell scripts. It is recommended that simply learn commands as such and do not mess up with the complexity of the Linux system because after going through the series you will start understanding things automatically. Let us begin:
Open Terminal and try following commands
2.6 Basic Linux commands
Used to list directories and files.
$ ls <directory/file>
Used to create an empty file.
$ touch <file_name> e.g. $ touch um
To display current date
To display a calendar.
To display content of file directly to terminal
$cat <file_name> e.g. $ cat example.txt
Display username currently log in.
Show who is logged in and what they are doing
Clear the screen of the terminal.
Display list of commands recently executed by the user.
It will display what type of file is that, file command scan file classify type of file, have a look:
$ file /bin/bash
You can change password of current user using the passwd command, make sure password is minimum 8 character complex password, otherwise it will show error.
Linux has the auto-completion facility for the command line, e.g. you if you want to use mkdir command there is no need to type complete command.
e.g. type mkd and press <tab> button twice, all available options will be displayed.
2.7 Important Command Line shortcuts for Linux
A System Administrator is expected to perform tasks quick and efficiently, there are some shortcuts which you will make your life easy when you are working with commands, it is recommended that you should practice these shortcuts:
Ctrl+a: Jump to beginning of command line.
Ctrl+e: Jump to the end.
Ctrl+k: delete to the end of the line starting from the cursor position.
Ctrl+z: suspend command.
Ctrl+c: cancel command.
Ctrl+u: Delete entire line.
Ctrl+t: You can retype last two characters of the command, suppose you have mistyped certain commands and you wants to correct that e.g. you type daet instead of date, press Ctrl+t twice and retype.
Ctrl+r: search history of command with a pattern.
Ctrl+Right Arrow: Jump cursor to ‘beginning of command line word’ right side.
Ctrl+Left Arrow: Jump cursor to the ‘beginning of command line word’ right side.
After going through these two chapters, user is able to install a fresh Red Hat Linux machine, open terminal and run initial basic but important commands, till now we are accessing terminal as non-privileged user, in next upcoming chapter of this “RHCSA Examination Preparation Guide” series we will include a detailed in-depth introduction to Red Hat File system, file system hierarchy, relative and absolute path and handle Linux file system using command line. If you are a fresher, things can appear a little bit complicated, but believe us that you will enjoy the journey as we will move ahead step by step, stay tuned. Have Fun!!
2.9 DIY Exercise
- Reboot system, login and open terminal.
- Change password of user using ‘passwd’ command.
- Use ‘file’ for ‘/etc/passwd’ file.
- create some files using touch command.
- Use ‘ls’ command to have a look in /etc/ directory.
- See history.
2.10 What next chapter of RHCSA guidewill include?
2.10 What next RHCSA tutorial will include?
In next chapter of this RHCSA series we will learn hirarchial model of Red Hat linux file system, what is relative and absolute path, file operations using command lines e.g. create files, directories, remove, copy or remove files/directories, how to create files in bulk with a single command. Stay tuned!!