Linux环境基本配置

一、JAVA_HOME

    有日子没配过linux环境了,居然已经开始生疏了。

vim ~/.profile

     配置Java环境、配置时区

写道
#Java环境
export JAVA_HOME=/usr/bin/java
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=.:$JAVA_HOME:$PATH

    然后加载文件:

. ~/.profile

 

二、TimeZone

    还是修改 ~/.profile文件

vim ~/.profile

    追加: 

#时区
export TZ='Asia/Shanghai'

 

   这回,时区对了,UTC变CST了
$ date
Fri Nov 14 15:23:39 CST 2014

    或者,手动选择时区:

dpkg-reconfigure tzdata

    记得要重启

 

二、Static IP& DNS

    配置静态IP:    

sudo vim /etc/network/interfaces

    默认如下:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

 

    我想把它绑定在192.168.158.151,可以改成如下内容:

写道
iface eth0 inet static
address 192.168.158.151
netmask 255.255.255.0
gateway 192.168.158.2
broadcast 192.168.158.255
network 192.168.158.0

 

    这时候如果不能访问外网,说明DNS配置有问题。

如果这个文件是空的,类似这样:
cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

    需要修改/etc/resolvconf/resolv.conf.d/base(这个文件默认是空的)

sudo vim /etc/resolvconf/resolv.conf.d/base

    在里面插入:

nameserver 8.8.8.8
nameserver 8.8.4.4

   然后执行: 

sudo resolvconf -u

    这时候就可以访问外网了~~Linux环境基本配置