Shell command mechanism

Source: Internet
Author: User

the previous article provided some basic overview of Linux.

This time we started to play the basis of command-line operation, and then rely on some graphical operation to improve our efficiency.

Since we want to learn the Linux operating system, we have to learn its command, it is well known that the graphical interface of Linux is not stable, its graphical interface is just an application, so it is easy to crash. So we should learn some of the mechanisms under the graph, including using the command line to implement something, using the shell to implement something, including understanding its internal mechanisms.

Of course, these commands are not allowed to memorize.

Start the virtual machine and start Ubuntu.

The graphical interface switches to the command line by pressing ctrl+alter+ F2 or F3 or F4

Command line switch back to graphical interface ctrl+alter+ F7

1. First command: LS

List all the files under the file, LS is actually a list of an abbreviation

Now let's analyze how this command is implemented, and what is the implementation mechanism?

Literally, the shell is the shell/shell meaning.

Let's say a--"This is the kernel of the operating system kernel, on the kernel we will have the definition of the user interface, and then we have a shell to wrap it up, this shell has a lot of command tools, we use these command tools and write our own shell script command, A bit similar to Windows under the batch processing, through these to achieve access to the following.

So the LS implementation process is this:

(1) The LS is entered

(2) ls-> go to the corresponding directory to find Shell command program, then where to find the shell, of course, in the path to find, then where is the path set? Environment variables.

(3) When it is found, execution is based on some basic shell libraries, for example, in Ubuntu, our shell uses bash

(4) The last is to access the kernel kernel

Now let's take a look at where this path is configured so we know where the LS command is.

Before we look at path, let's look at a new command.

Whereis ls

Print it out LS:/bin/ls/usr/share/man/man1/ls.1.gz

Let's find out/bin/ls this directory

Ls/bin/ls

Print out the/bin/ls display is green, indicating that it is an executable file


Now let's see if the environment variable really points to/bin/ls, so where is the environment variable? Let's imagine that the folder we talked about earlier was configured, as if it were the ETC folders.

Let's go to the ETC folder to see

CD etc

So the environment variable is under/etc/environment, we ls a bit

Ls/etc/environment

Print out/etc/environment, we learned that it was a general document

We open the file with the VI tool

VI /etc/environment

We can see there's a path.

Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/usr/games"

Which means that when LS executes, it goes down to the files to find the executable file.

Using bash to parse LS

2. How Linux implements the shell

(1) Bash

(2) Coreutils

To understand these two pieces we have to talk about GNU and check out the GNU translation.

Bash and Coreutils were developed on the GNU

GNU's official website: http://www.gun.org/

There's an introduction to GNU bash.

Download bash

We can view the current bash version via Bash-version

How to do bash porting into our system without the command how to manually transplant, you can view the Help document


Be sure to understand the relationship between gun and Linux





Shell command mechanism

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.