Custom Shell Work Environment

Source: Internet
Author: User

After logging into the system, we are the Shell interaction environment, use it every day to work, have a customized environment can make us more efficient.


1.PS1 variable

It is found that there is a string of characters on the left side of the cursor flashing: [[email protected] ~]#, this set of strings consists of [user name @hostname the current directory]#. In fact, this character is controlled by the PS1 variable, echo $PS to see:

This is actually something I've customized, adding color to some of the things I've shown. Let's get back to the way it was, ". BASHRC" is the user profile for the default child shell of the bash shell, the console input CD, which jumps to the user's default working directory without any parameters, and uses Ls–al to list all files, since the period begins with the file in Uni Hidden files under the X/linux operating system.

Less. BASHRC to see what's Inside:

Let's use the strongest editor VI under Linux to restore it to its original shape:

After saving, use the source. BASHRC to make the changes:

We see the result is not what we want, let's make some adjustments. We have the prompt, which shows the current user @ host name current working directory $. And look at our settings as follows:

The basic settings are as above, and of course there are some other parameters. For example \ t current time, \d current date, \ n newline, \s the current shell environment, \w the full working path, and so on.


2. PATH environment variable

As programmers, it is unavoidable to install some of our own tools on the machine, such as Java,maven,git. Download the software, unzip it to the directory we want, and take Java for an example. Terminal Input Java command, display Java:command not found. Indicates that the Java executable cannot be found under the path specified by the local PATH environment variable.

As above, we have downloaded the good JDK to our Linux virtual machine, the file can be extracted by TAR–XVF jdk-8u181-linux-x64.tar.gz. The next step in our implementation of the Java command is still not possible, we can change the work path to the JDK Bin directory to try, input./java–version, the effect is as follows:

Next we edit the. bashrc file, add the directory to the PATH environment variable, and you can invoke the Java command in any directory.

First we define the Java_home variable for later use, then add the bin directory of the JDK to the PATH variable, and add the format path= $PATH: New Value1:new value2. Later we use the Export command to copy the value of PATH to the child shell.


3. Select Shell

Linux system can run a variety of Shell, in the operating system history introduced by the time we have introduced a lot, so here is not repeated listed.

We can view the shell tools that have been installed on this machine via cat.

As we can see, there is currently only one shell tool installed on this machine: Bourne Again shell.

A wide variety of shells, each of which has its own unique control file. But they all support a standard at the same time. /etc/profile is a global profile that is recognized by all shells, and ~/.profile is a user profile that is recognized by all shells. So if you don't remember their unique profile, just remember these two files to do your job.

Here is the location of the main shell configuration files for your reference:

So far, the shell work environment has been customized.


Welcome to pay attention to me, study together.
















Custom Shell Work Environment

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.