Thursday, November 26, 2015

what is mean by shell in linux?

What is a Shell?

The shell is an interactive command interpreter environment within which commands may be typed at a prompt or entered into a file in the form of a script and executed. The origins of the shell can be traced back to the early days of the UNIX operating. In fact, in the early days of Linux before the introduction of graphical desktops the shell was the only way for a user to interact with the operating system.

A variety of shell environments have been developed over the years. The first widely used shell was the Bourne shell, written by Stephen Bourne at Bell Labs.

Yet another early creation was the C shell which shared some syntax similarities with the C Programming Language and introduced usability enhancements such as command-line editing and history.

The Korn shell (developed by David Korn at Bell Labs) is based on features provided by both the Bourne shell and the C shell.

The default shell on RHEL 6 is the Bash shell (shorthand for Bourne again shell). This shell, which began life as an open source version of the Bourne shell, was developed for the GNU Project by Brian Fox and is based on features provided by both the Bourne Shell and the C Shell.

Gaining Access to the Shell

From within the GNOME desktop environment, the shell prompt may be accessed from a Terminal window either by selecting the Applications -> System Tools -> Terminal menu option or right clicking on the desktop and selecting Open in Terminal from the resulting menu. When remotely logging into an RHEL server, for example using SSH, the user is also presented with a shell prompt. When booting a server based system in which a desktop environment has not been installed, the shell is entered immediately after the user completes the login procedure at the console terminal or remote login session.

different type of shells in linux

Bourne Shell

    The original Bourne shell is named after its developer at Bell Labs, Steve Bourne. It was the first shell used for the Unix operating system, and it has been largely surpassed in functionality by many of the more recent shells. However, all Unix and many Linux versions allow users to switch to the original Bourne Shell, known simply as "sh," if they choose to forgo features such as file name completion and command histories that later shells have added.

C Shell

    The C shell, as its name might imply, was designed to allow users to write shell script programs using a syntax very similar to that of the C programming language. It is known as "csh."

TC Shell

    TC shell is an expansion upon the C shell. It has all the same features, but adds the ability to use keystrokes from the Emacs word processor program to edit text on the command line. For example, users can press Esc-D to delete the rest of the highlighted word. It is also known as "tcsh."

Korn Shell

    Korn Shell was also written by a developer at Bell Labs, David Korn. It attempts to merge the features of the C shell, TC shell and Bourne shell under one package. It also includes the ability for developers to create new shell commands as the need arises.

    It is known as "ksh."

Bourne-Again Shell

    The Bourne-Again shell is an updated version of the original Bourne shell that was created by the Free Software Foundation for its open source GNU project. For this reason, it is a widely used shell in the open source community.

    Its syntax is similar to that used by the Bourne shell, however it incorporates some of the more advanced features found in the C, TC and Korn shells.

    Among the added features that Bourne lacked are the ability to complete file names by pressing the TAB key, the ability to remember a history of recent commands and the ability to run multiple programs in the background at once.


Wednesday, November 18, 2015

what is the difference between rhel 6 and rhel 7 ?

Default File System
Kernel Version
3.10.x-x kernel
2.6.x-x Kernel
Kernel Code Name
General Availability Date of First Major Release
2014-06-09 (Kernel Version 3.10.0-123)
2010-11-09 (Kernel Version 2.6.32-71)
First Process
systemd (process ID 1)
init (process ID 1)
runlevels are called as "targets" as shown below: -> -> -> -> -> -> ->

/etc/systemd/system/ (this by default is linked to the multi-user target)
Traditional runlevels defined :

runlevel 0
runlevel 1
runlevel 2
runlevel 3
runlevel 4
runlevel 5
runlevel 6

and the default runlevel would be defined in /etc/inittab file.
Host Name Change
In Red Hat Enterprise Linux 7, as part of the move to the new init system (systemd), the hostname variable is defined in /etc/hostname.
In Red Hat Enterprise Linux 6, the hostname variable was defined in the /etc/sysconfig/network configuration file.
Change In UID Allocation
By default any new users created would get UIDs assigned starting from 1000.

This could be changed in /etc/login.defs if required.
Default UID assigned to users would start from 500.

This could be changed in /etc/login.defs if required.
Max Supported File Size
Maximum (individual) file size = 500TB
Maximum filesystem size = 500TB

(This maximum file size is only on 64-bit machines. Red Hat Enterprise Linux does not support XFS on 32-bit machines.)
Maximum (individual) file size = 16TB
Maximum filesystem size = 16TB

(This maximum file size is based on a 64-bit machine. On a 32-bit machine, the maximum files size is 8TB.)
File System Check

XFS does not run a file system check at boot time.

File system check would gets executed at boot time.
Differences Between xfs_repair & e2fsck


- Inode and inode blockmap (addressing) checks.
- Inode allocation map checks.
- Inode size checks.
- Directory checks.
- Pathname checks.
- Link count checks.
- Freemap checks.
- Super block checks.


- Inode, block, and size checks.

- Directory structure checks.

- Directory connectivity checks.

- Reference count checks.

- Group summary info checks.
Difference Between xfs_growfs & resize2fs

xfs_growfs takes mount point as arguments.

resize2fs takes logical volume name as arguments.
Change In File System Structure
/bin, /sbin, /lib, and /lib64 are now nested under /usr.
/bin, /sbin, /lib, and /lib64 are usually under /
Boot Loader
Supports GPT, additional firmware types, including BIOS, EFI and OpenFirmwar. Ability to boot on various file systems (xfs, ext4, ntfs, hfs+, raid, etc)
GRUB 0.97
RHEL7 supports kdump on large memory based systems up to 3 TB
Kdump doesn’t work properly with large RAM based systems.
System & Service Manager

systemd is a system and service manager for Linux, and replaces SysV and Upstart used in previous releases of Red Hat Enterprise Linux. systemd is compatible with SysV and Linux Standard Base init scripts.
Enable/Start Service
For RHEL 7, the systemctl command replaces service and chkconfig.

- Start Service : "systemctl start nfs-server.service".

- Enable Service : To enable the service (example: nfs service ) to start automatically on boot : "systemctl enable nfs-server.service".

Although one can still use the service and chkconfig commands to start/stop and enable/disable services, respectively, they
are not 100% compatible with the RHEL 7 systemctl command (according to redhat).
Using "service" command and "chkconfig" commands.

- Start Service : "service start nfs" OR "/etc/init.d/nfs start"

- Enable Service : To start with specific runlevel : "chkconfig --level 3 5 nfs on"
Default Firewall
"Firewalld (Dynamic Firewall)"

The built-in configuration is located under the /usr/lib/firewalld directory. The configuration that you can customize is under the /etc/firewalld directory. It is not possible to use Firewalld and Iptables at the same time. But it is still possible to disable Firewalld and use Iptables as before.
Network Bonding
"Team Driver"

- DEVICE=”team0”

- DEVICE=”bond0”
Network Time Synchronization
Using Chrony suite (faster time sync compared with ntpd)
Using ntpd
NFSv2 is no longer supported. Red Hat Enterprise Linux 7 supports NFSv3, NFSv4.0, and NVSv4.1 clients.
Cluster Resource Manager
Load Balancer Technology
Keepalived and HAProxy
Desktop/GUI Interface
GNOME3 and KDE 4.10
Default Database
MariaDB is the default implementation of MySQL in Red Hat Enterprise Linux 7
Managing Temporary Files
RHEL 7 uses systemd-tmpfiles (more structured, and configurable, method to manage tmp files and directories).
Using "tmpwatch"

How To Use Systemctl to Manage Systemd Services in RHEL7

Useful SystemD commands (hints for systemctl or systemctl vs chkconfig and service)
List all running services

# systemctl

Start/stop or enable/disable services

Activates a service immediately:

# systemctl start foo.service

Deactivates a service immediately:

# systemctl stop foo.service

Restarts a service:

# systemctl restart foo.service

Shows status of a service including whether it is running or not:

# systemctl status foo.service

Enables a service to be started on bootup:

# systemctl enable foo.service

Disables a service to not start during bootup:

# systemctl disable foo.service

Check whether a service is already enabled or not:

# systemctl is-enabled foo.service; echo $?

0 indicates that it is enabled. 1 indicates that it is disabled

How do I change the runlevel?

systemd has the concept of targets which is a more flexible replacement for runlevels in sysvinit.

Run level 3 is emulated by Run level 5 is emulated by is a symbolic link to and is a symbolic link to

You can switch to ‘runlevel 3′ by running

# systemctl isolate (or) systemctl isolate

You can switch to ‘runlevel 5′ by running

# systemctl isolate (or) systemctl isolate

How do I change the default runlevel?

systemd does not use /etc/inittab file.
List the current run level

# systemctl list-units --type=target

[root@redhat7 ~]# systemctl list-units --type target
UNIT                LOAD   ACTIVE SUB    DESCRIPTION        loaded active active Basic System   loaded active active Encrypted Volumes        loaded active active Login Prompts    loaded active active Graphical Interface loaded active active Local File Systems (Pre)     loaded active active Local File Systems   loaded active active Multi-User System      loaded active active Network          loaded active active Network File System Server        loaded active active Paths    loaded active active Remote File Systems       loaded active active Slices      loaded active active Sockets         loaded active active Swap      loaded active active System Initialization       loaded active active Timers

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

runlevel command still works with systemd. You can continue using that however runlevels is a legacy concept in systemd and is emulated via ‘targets’ and multiple targets can be active at the same time.

If u want to change default runlevel by using following command u can change the default runlevel in rhel7

[root@rhel7 ~]# systemctl set-default

[root@rhel7 ~]# reboot or systemctl reboot

You are server defaulty goes to cli mode.

if u want graphical mode using following you can change the cli to graphical mode

[root@rhel7 ~]# systemctl set-default

[root@rehl7 ~]# reboot or systemctl reboot or init 6

you are default server is goes to graphical mode.

Service vs. systemd

# service NetworkManager stop


# systemctl stop NetworkManager.service

Chkconfig vs. systemd

# chkconfig NetworkManager off


# systemctl disable NetworkManager.service


systemd has a built-in readahead implementation is not enabled on upgrades. It should improve bootup speed but your mileage may vary depending on your hardware. To enable it:

# systemctl enable systemd-readahead-collect.service
# systemctl enable systemd-readahead-replay.service

How to check the number of service running on the you are server in rhel7?

using following command you can check number of services running on you are server

[root@rhel7~]# systemctl list-units --type service

SystemD cheatsheet

RHEL6                          RHEL7

service foobar start     systemctl start foobar.service             Used to start a service (not reboot persistent)
service foobar stop     systemctl stop foobar.service             Used to stop a service (not reboot persistent)
service foobar restart     systemctl restart foobar.service     Used to stop and then start a service
service foobar reload     systemctl reload foobar.service     When supported, reloads the config file without interrupting pending operations.
service foobar condrestart     systemctl condrestart foobar.service     Restarts if the service is already running.
service foobar status     systemctl status foobar.service     Tells whether a service is currently running.
ls /etc/rc.d/init.d/     ls /lib/systemd/system/*.service /etc/systemd/system/*.service     Used to list the services that can be started or stopped
chkconfig foobar on     systemctl enable foobar.service     Turn the service on, for start at next boot, or other trigger.
chkconfig foobar off     systemctl disable foobar.service     Turn the service off for the next reboot, or any other trigger.
chkconfig foobar     systemctl is-enabled foobar.service     Used to check whether a service is configured to start or not in the current environment.
chkconfig foobar –list     ls /etc/systemd/system/*.wants/foobar.service     Used to list what levels this service is configured on or off
chkconfig foobar –add           Not needed, no equivalent.