Little Ant learns Linux (9)--shell Basics and bash basic features

Source: Internet
Author: User
Tags aliases clear screen learn php save file

Shell Simple Understanding

View the current SHELL echo $SHELL

Try the first little script: Vim test.sh

1 #!/bin/bash

2 echo ' I'll be-back ';

Note: #!/bin/bash This sentence is bound to add, remember.

How to execute the script:

1. Give execute permission, chmod 755 test.sh, run directly./test.sh, note: To be executed with a relative or absolute path.

2. Execute script via bash call, e.g. bash test.sh


Basic features of Bash


    1. Alias

    2. View existing aliases in the system alias

      command to modify aliases alias ls= ' ls--color:never '

      Add name Other command alias Vi= ' Vim '

Commands to remove aliases Unalias VI

Note: The use of the alias command is temporary, and if you restart the server, these settings will become invalid. If you want the alias to take effect permanently, you can write the alias settings to the environment variable configuration file. Command: VI < home directory >/.BASHRC is written in the default format and location. However, this procedure requires a re-login in order to take effect, if necessary in time, but the use of the command: source. bashrc. This will call the file again and then take effect.

Command Effective Order:

1. First-order bit execution of commands executed with absolute or relative paths

2. Second sequential bit execution alias

3. Third sequential execution of bash internal commands

4. The IV sequence bit executes the first command found in the order of the directories defined by the $PATH environment variable.

2. Common shortcut keys

CTRL + C terminates ctrl+e cursor fast to end of line

Ctrl+l Clear Screen Ctrl + Z put commands into the background (not recommended)

Ctrl+u Delete full row ctrl+r search in history command CTRL + A cursor jumps to the beginning of the line

3. Historical order

History "Options" "Historical command Save File"

Option:-C clears the history command (not recommended to empty, anyway this will not occupy much space)

-W Write history command in cache to history command save file < home directory >/.bash_history

Note: The history command saves 1000 by default and can be modified in the environment variable configuration file/etc/profile. Find histsize=1000, modify it.

The most common two calls to historical commands are:

1. Use the up and down arrows to invoke the previous history command

2. Use "! String "To repeat the last command that starts with the string

4. TAB key Auto-complete function

Command completion: Depends on the environment variable.

File or directory Completion: The path of the dependent action.

learn PHP's small ant original blog http://my.oschina.net/woshixiaomayi/blog



Little Ant learns Linux (9)--shell Basics and bash basic features

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.