Linux-bash shell function; built-in command type

Source: Internet
Author: User
Tags aliases builtin

Command editing ability (history):

One of the great features of Bash is that "he can remember the commands he used!"

"This is a really great feature!" Because I just have to press the "up and Down" button in the command line to find the front/rear input command!

And in very many distribution. The default command memory function can reach 1000! In other words, almost all of the commands you've issued have been recorded.

Where are all the commands recorded? Inside your home folder. Bash_history!

Just, the need to pay attention to IS. ~/.bash_history records the commands that were executed in the previous login, and the commands executed by this login are cached in memory when you successfully log out of the system. The command memory will be recorded. Bash_history one of them!

What is the function of this? The biggest advantage is the ability to "query the previous actions." "So you can know your execution steps. Then you will be able to track the orders you have issued. As a tool for debugging! But there is also an annoyance. is to assume that the hacker invaded. Then he just has to go through the commands you have executed, just as your commands are related to the system (like the password of MySQL directly on the command line), then your host can be a headache!

Is it better to record more or fewer commands? This part is a matter of opinion, there is no definite answer.



command and file Completion function: ([tab] key Advantages)

[Tab] is followed by the first word of a string of commands, then the command is complete.
[Tab] is followed by the second word of a string of commands. Then "File Up"!


Command alias Configuration feature: (alias)

You can enter alias in the command column to know what the command aliases are now. You can also configure aliases by issuing commands directly:



Job control, foreground background control: (Jobs control, foreground, background)

The use of pre-and background control can make the work more smoothly!

As for job control (jobs), it's a broader use, allowing us to throw work into the background at any time! Instead of accidentally using [Ctrl] + C to stop the program. That's good!

In addition, it can be in a single sign-on environment. Achieve multi-tasking purpose!


Programmatic scripting: (shell scripts)

In the DOS era, remember the so-called "batch file" that writes a bunch of commands together? The shell scripts under Linux is a more powerful feature that allows you to write a sequential command that is often required by your management system as a file that can be used to detect the host in a interactive way! It is also possible to design with environment variables and related commands provided by the shell. Once in DOS need program language ability to write things, under Linux using a simple shell scripts can help you reach!


Wildcard character: (Wildcard)

In addition to the complete string. Bash also supports a number of wildcard characters to help users query and command release. For example, do you want to know how many files with X at the bottom of/usr/bin? Use: "Ls-l/usr/bin/x*" on the line know ~ besides. There are also other wildcard characters available for use. These can speed up the operation of the user!


Bash Shell built-in command: type

How do you know if this command came from an external command (referring to other commands not provided by bash) or built in bash? Hey!

You can use the type command to see it!

For example:

[Email protected] ~]#type [-TPA] nameOptions and Parameters: No matter what options and parameters, type shows whether name is an external command or bash built-in command-T: When you increase the-t parameter, the type displays the word name with the following words: file: represented as      External command. Alias: Indicates the name that the command is configured for the command alias; Builtin: Indicates that the command is a command function built in bash;-P: Assume that the name that follows is the external command. The full file name is displayed. -A: In the path defined by the PATH variable. List all commands with name, including aliasExample one: query ls This command is built in bash? [Email protected] ~]#type lsLS is aliased to ' LS--color=tty '<== No matter what the number of parameters, the main use of LS list[Email protected] ~]#type-t lsAlias<== lists only the basis for LS execution[Email protected] ~]#type-a lsLS is aliased to ' LS--color=tty '<== First use of AliaseLS Is/bin/ls<== also found an external command in/bin/lsexample two: So what about CDs? [Email protected] ~]#Type cdCD is a shell builtin<==, you see that? The CD is a shell built-in command

Linux-bash shell function; built-in command type

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.