RHCE Study Guide

This tutorial explains Linux virtual console, shell command prompt, bash shell, internal commands and external commands in detail with example.

Linux Virtual Console (Terminal)

To understand the Linux virtual console concept, we have to look back in the history of computers. In earlier days computers used to be very expensive. Instead of personal computers, companies used to prefer mainframe computers. A mainframe computer allows multiple users to connect with it separately. In mainframe computing, every user accesses mainframe computer as a separate computer.

linux terminials

A device known as terminal which contains only few parts and a monitor with integrated keyboard is used to access the mainframe computer. Terminal connects with mainframe computer on serial console port. Once connected it uses all resources such as CPU, RAM and Hard disk from mainframe computer. The earliest terminals were also known as teletypes (abbreviated TTY).

linux terminial

Since a terminal directly communicate with system at low level on dedicated serial console port, it does not need any special service, software or application to run. When you booted up the terminal, you would see a login prompt called Linux console on monitor. Linux console it the only place where you can enter commands for system in terminal. Operating system installed in mainframe computer emulates each console as a separate system with a separate login session.

Over the time computers technology improved and price came down which made companies to switch on personal computers from mainframe computers. Since a PC has all necessary resource for operating system, we usually install operating system in every computers.

Even though terminals are history now, terminal concepts still exists in Linux operating system. Now it is abstracted into the software. For instance RHEL 7.2 provides six consoles. If we have physical terminals, we can attach them with consoles directly via serial console port. If we don’t have physical terminal, we can still access the consoles virtually.

To access virtual console following key combination is used

Key combination Console Terminal
Alt +Ctrl+F1 First console (Graphic mode) tty0
Alt +Ctrl+F2 Second console (Text only) tty1
Alt +Ctrl+F3 Third console (Text only) tty2
Alt +Ctrl+F4 Fourth console (Text only) tty3
Alt +Ctrl+F5 Fifth console (Text only) tty4
Alt +Ctrl+F6 Sixth console (Text only) tty5
Key points
  • Graphic mode will be available only if we have installed desktop packages (gnome is default).
  • Each virtual console represent a separate terminal and provides an independent login session.
  • We can switch between virtual consoles. Switching will not terminate the active login session.
Exam Tip

To test the candidate ability usually Red Had disabled the login prompt in virtual console.

Exercise

Objective :- Access multiple virtual consoles simultaneously and figure out who is logged in on which terminal.

Solution :- During the installation we have created a user account. We can use that account to complete this exercise. Login with that user account in graphic mode.

linux graphic login prompt

To learn how to install RHEL 7 step by step please see our previous article RHEL 7 Installation step by step Explained with Screenshots

Now access any virtual console by pressing Alt + Ctrl + (F2,F3,F4,F5,F6) and login from root user

root user login

Run who command to figure out who is logged in currently

linux who command

As output shows that there are two users logged in currently. First user (sanjay) is logged in graphic mode (tty0) and second user (root) is logged in text mode(tty4).

Bash shell

Shell is the program which accept commands from user, execute them in system and display the result back to the user. It provides command prompt and working environment in Linux. Default shell in RHEL is bash (GNU Bourne-Again Shell) which is the improved version of Bourne Shell (sh).

Shell command prompt

To avoid the mistakes shell provides two types of command prompt :-

  • For regular user it ends with $ character
  • For super user it ends with # character

Both command prompt includes some essential information such as username, hostname and current directory.

linux difference between normal user and root user command prompt

Linux command types

When we type any command in shell prompt, before executing it shell determines what type of command this is.

Shell divides commands in following types :-

Based on location

Internal:- Commands which are integrated in shell.

External :- Commands which are stored in hard disk.

A Linux command is basically a link of an executable file. Location of this file decide the type of command. If executable file is available with in shell then command will be considered as an internal command. If executable file is available outside the shell then command will be considered as an external command.

If command is internal, shell will execute that immediately. If command is external, shell will search the executable file in specified locations. If shell finds a match, it will run that file. Otherwise it will return with error message “command not found”.

  • To know whether command is internal or external we can use type command with –t option.
  • If command is external, we can use which command to know the location of executable file.
  • To know where shell will search for executable file, we can use echo $PATH command.

linux type command

Based on privilege

Non-privileged commands :- These commands are available for both user accounts; regular and root. These commands are used for regular works and do not require any special privilege while executing them.

Privileged commands:- These commands are available only for root (super user) account. These commands are intended for system management and requires special privilege while executing them.

Every file in Linux is secured with permission levels. These permission levels define who are allowed to access this file and how they are allowed to access this file. When shell accesses an executable file, it reads the permission properties of file and decide whether the user who is trying to execute this file has the permission to do this or not. If he has the permission, shell will execute the command otherwise it will ask user to provide necessary credentials.

linux command

If users fails to provide necessary credentials, command will not execute.

That’s all for this article in next article I will explain some essential commands in detail with example.