Linux Server Basic Configuration (Java environment variable, firewall)

Source: Internet
Author: User
Tags first string ssh port

The principle of configuring environment variables and Windows under Linux is the same, which is to make the path of the JDK a global variable, with sudo gedit(if not installed can use VI) to open/etc/profile, at the end of the file to add

Export java_home=/usr/java/jdk1.6.0_45

Export path= $JAVA _home/bin: $PATH

Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Jdk1.6.0_45 change to the folder name of the JDK you installed

After the modification is completed, update with the Source/etc/profile command;

The following steps are important because OPENJDK is preinstalled on many Linux systems, so even if these settings are set above, the default is not what we want to set up, and if you want to actually use our own JDK, you need to do it:

sudo update-alternatives--install/usr/bin/java Java xxx/bin/java 300

sudo update-alternatives--install/usr/bin/javac javac Xxx/bin/javac 300

( This is just a sign, it doesn't make sense, it's just the next step )

sudo update-alternatives--config java

performing this step will list all installed on the system Java , then choose the last one for you - the One


sudo update-alternatives--config javac

Ditto

Note: Some articles say that you can only use the following statements:
sudo update-alternatives–config Java, I have not tried!

You're done, use the java-version command to view our Java environment variables

--------------------------------------------------------------------------------------------------------------- ----
To set some ports in the firewall switch, you can modify the edit/etc/sysconfig/iptables file, such as open SSH Port 22, you can add the following:
In the system's original configuration: The Rh-firewall-1-input rule chain adds a line like this:

-A rh-firewall-1-input-m state--state new-m tcp-p tcp――dport 22-j ACCEPT
-A rh-firewall-1-input-m state--state new-m udp-p UDP--dport 22-j ACCEPT
If you find the original-j reject a class of statements, the above two sentences to put in front of it

Effective after reboot
Open: Chkconfig iptables on
OFF: chkconfig iptables off or/sbin/chkconfig--level 2345 iptables off

2) immediate effect, failure after reboot
Service mode
Open: Service iptables start
Close: Service iptables stop
Iptables Way
To view the firewall status:
/etc/init.d/iptables status
To temporarily turn off the firewall:
/etc/init.d/iptables stop
Restart Iptables:
/etc/init.d/iptables restart

--------------------------------------------------------------------------------------------------------------- ----

command to enter VI
VI FileName: Opens or creates a new file and places the cursor at the beginning of the first
VI +n FileName: Opens the file and places the cursor at the beginning of nth
VI + FileName: Opens the file and places the cursor at the beginning of the last line
VI +/pattern FileName: Opens the file and places the cursor at the first string that matches the pattern
Vi-r FileName: The last time you were editing with VI, a system crash occurred, restoring filename
VI filename....filename: Open multiple files, edit them sequentially


Save exit
┌───────────┬───────────────┐
│ Command │ Description │
├───────────┼───────────────┤
│zz│ Save and Exit │
├───────────┼───────────────┤
│:w filename│ Write File │
├───────────┼───────────────┤
│:w│ Writing Files │
├───────────┼───────────────┤
│:x│ Save (if the current file has been modified) and exit │
├───────────┼───────────────┤
│:q! │ do not save files, direct exit │
├───────────┼───────────────┤
│:q│ Exit vi│


: Wq mandatory write file and exit. Force write even if the file is not modified, and update the file's modification time.

: X writes the file and exits. The file modification time is not updated unless the file is modified and the file modification time is updated.


Linux Server Basic Configuration (Java environment variable, firewall)

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.