Source code of several ubuntu scripts

Source: Internet
Author: User

1. About the configuration file/etc/profile

This file is automatically executed when the system starts. Any user logs on to the system to execute this file.
The configuration in this file is global configuration. Therefore, if you want to allow all users to use your variables, you can add them in this configuration file.
For example, the configuration of JAVA_HOME variable.
However, do not modify the configuration file as far as possible because it is the system configuration file. We try to modify our independent configuration file.
You can modify your configuration file at any time when possible or when you reconfigure it, without affecting others or the server system.

Similarly, modifying/etc/rd. local can achieve the same effect.
But like the above, it is not a good choice.

What is the alternative?
First, let's look at the source code of/etc/profile.

If [-d/etc/profile. d]; then
For I in/etc/profile. d/*. sh; do
If [-r $ I]; then
. $ I
Unset I

If ["$ PS1"]; then
If ["$ BASH"]; then
PS1 = '"u @" h: "w" $'
If [-f/etc/bash. bashrc]; then
./Etc/bash. bashrc
If ["'id-U'"-eq 0]; then
PS1 = '#'
PS1 = '$'
Explanation: 1. [-r $ I] indicates readable, and unset I indicates deleting the environment variable I.
The code in red indicates that/etc/profile will first execute all *. sh files in the/etc/profile. d/directory.
This gives us a scalable idea.

To configure JDK, create the jdk. sh file under/etc/profile. d /.


Jdk. sh

JAVA_HOME =/usr/lib/jvm/jdk1.6.0 _ 35
CLASSPATH =.: $ CLASSPATH: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib: $ JAVA_HOME/lib/tools. jar:/$ JAVA_HOME/lib/dt. jar
PATH = $ PATH: $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin:

Export PATH = $ PATH :~ /Bin

To configure oracle, create the oracle. sh file under // etc/profile. d /.

Then, add your own configuration in the corresponding configuration file.

This is the idea I used in the last two blogs.

========================================================== ==========================================

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: 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.