Understanding and Learning Bash

Source: Internet
Author: User

What is a shell

we have to go through the Shell "The instructions that we input (e.g. LS, CP) and Linux Kernel communication. Linux is a multiplayer environment where everyone can get a bash with the login system

SHELL the Benefits

The shell of the text interface is hard to learn, and x Windows provides an interface to manage the system, but why shell.

The bash used by almost every home distributions is the same. In this way, you can easily switch to different distributions.

L Remote Management: The text interface is faster.

If you really want to manage your host well, then a good shell program will need to be written

the legal shell of the system and /etc/shells function

Our Linux (CentOS 5.x for example) how many shells we can use at the moment. You can check/etc/shells this file, at least there are several available at the bottom of these shells:/bin/sh (has been replaced by/bin/bash)/bin/bash (is the Linux preset shell)/bin/ksh (Kornsh Ell by At&t Bell Lab. Developed, compatible with bash)/BIN/TCSH (integrated C-Shell, providing more functionality)/BIN/CSH (has been replaced by/BIN/TCSH)/bin/zsh (based on Ksh, a more powerful Shell)

Each shell has a similar function. The Linux preset is to use bash.

Why do we have a legal shell that is written into the/etc/shells file?

This is because some of the system's services are in the process of checking the shells that users can use, and these shells are being checked by/etc/shells this file.

For example , some FTP sites will check the user's available shell, and if you don't want these users to use a host resource other than FTP, you might give the user a weird shell that doesn't allow users to access other services. This time, you have to write the weird shell into/etc/shells. For example, we have a/sbin/nologin file in the/etc/shells of our CentOS 5.x, and this is the weird shell we're talking about.

So, think again, when can I get a shell to work with this user. And what shell I'm going to get from this user's preset. When I log in, the system will give me a shell to let me work. And this login-made shell is logged in the /etc/passwd file.

[Root@www ~]# cat/etc/passwd
Root:x:0:0:root:/root:/bin/bash
Bin:x:1:1:bin:/bin:/sbin/nologin
Daemon:x:2:2:daemon:/sbin:/sbin/nologin
..... (Omitted below) ...

As shown above, the last piece of information in each row is the preset shell you can get after you log in. You'll also see that Root is/bin/bash, but the system account bin and daemon, and so on, use that weird/sbin/nologin.

Bash Shell the function

l Command editing ability (history)

Bash can memorize the instructions used. Because I just need to press "key" on the command line to find the front/rear input instructions.

Where are the instructions? In your home catalogue. Bash_history. It should be noted, however, that ~/.bash_history records the instructions that were previously performed before the login, and as the instructions for this login are held in memory, the instruction memory is recorded when you successfully log out of the system. Bash_history in the middle

l Command and file full function: ([tab] key to the good)

l Command name setting function: (alias)

For example: >alias lm= ' Ls-al '

So performing LM is equivalent to executing ls-al

L work control, foreground background control: (Job Contro

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.