Introduction to Shell Programming Basics Bash

Source: Internet
Author: User
Tags linux

1. Understanding Shell

As long as the interface that can manipulate the application can be called Shell. The shell is also an application that works in user mode and runs as a process. The shell process is primarily used to provide a command-line interface, providing a range of working characteristics, and some features can be set on its own. When a user logs on to the Linux operating system in a variety of ways, we can assume that the user has opened a shell to interact with the system.

The shell's role under Linux system is as follows:

2. Why to learn Shell

The shell of the command line interface is bad, but after learning the benefits are many. For example, graphical interfaces like Windows XP, Win 7 each version of the system their graphical operations are very different, but the command line is not so, when we finished the shell, we can basically operate most of the Linux distribution. In addition, when we are in the system management, especially remote management, the command line interface is relatively fast, allowing us to quickly complete the relevant task deployment. In addition, we can manage the host through the script under the command line interface. This will not require us to perform complex mouse operations. So I think that learning the shell is an orderly and efficient management system of the first question.

You can view the shell supported by the current system by using the following command:

Cat/etc/shells
/bin/sh            : Replaced by/bin/shell
/bin/bash          : Linux system default
/sbin/nologin      : Non-interactive logon
/ Bin/dash          : is a Unix shell smaller than bash
/bin/tcsh          : Consolidate C Shell to provide more functionality
/BIN/CSH: replaced           by/bin/tcsh

The shell used by default on 2.rhel6.4 is bash. The main functional characteristics are as follows:

1. Command memory function (history)

2. You can use the tab to complete the command

3. You can use the alias to set the command alias

4. To do the related script writing

5. Use of some shortcut keys

6. Support for piping and I/O redirection

3. You can control bash welcome and login information by setting the contents of the relevant file.

Cat/etc/issue                  display information before login
cat/etc/issue.net              display user information for Telnet login
cat/etc/motd                   prompt after login

4.BASH configuration file:

Mainly divided into 2 categories as follows:

Profile class:
file:
    /etc/profile            Global, effective/etc/profile.d/*.sh global for all users     , effective for all users
     ~/.bash_ Profile:       only for a user's own effective
function:
    set environment variable
    Run command or script
BASHRC class:
file:
    /ETC/BASHRC            Global, Valid for all users
    ~/.BASHRC              only for current user
:
    set local variable
    define command alias

When you update the above configuration files, the newly defined commands and execution statements in the file do not take effect immediately. The following 2 ways can be used to make it effective:

SOURCE FILE

. FILE

User logins are divided into interactive and non-interactive logins, and the order in which they execute these files is not the same. There are two main types of interactive logins, 1. Users who log in directly from the terminal; 2. Users who log on to the system through Su-username. Non-interactive logon User: 1. Through Su USERNAME 2. Under the graphical interface, open pseudo terminal. 3. The user when the script is automatically executed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.