linux步步为营(2)--常用配置 & shell

1、环境变量____________________________________________________________

 

1.1、登陆系统时shell读取的顺序(可用export LANG=zh_CN  缺省LANG=en_US测试 ) :

       /etc/enviroment --> /etc/profile --> $HOME/.profile   -->$HOME/.env (如果存在)

       (0) /etc/environment, 设置整个系统的环境与登录用户无关 

       (1) /etc/profile: 设置每个用户环境变量,第一次登录时,该文件被执行. 文件内容为执行:/etc/profile.d/*.sh,/etc/bash.bashrc

       (2) /etc/bashrc: 为每一个运行bash shell的用户执行此文件.可以为空

       (3) ~/.bash_profile: 当前用户专有的环境变量,内容可以为空。 

       (4) ~/.bashrc: 当前用户专有bash shell。

       (5) ~/.bash_logout:退出bash shell时,执行该文件.

 

1.2、查看环境变量

       set | grep "^\w*=.*$" \w转义算一个字符,不能(\w)*,[\w]+这么用

       env

       echo $HELLO

       export(显示,shell下直接用)

       export PATH="$PATH:../bin"(在profile,bashrc中用,environment中不能用)

              

1.3、环境变量后不能登录,解决办法,与内部命令

       /etc/environment中设置了PATH=/usr/java131/jre/bin:/usr/java131/bin:$PATH;

       启动会报错,但是可以用xshell登录,只能用内部命令export,cd..., usr/bin下面的命令比如ll用不

       用export设置一下环境变量,找到,比如ll,vi等,再编辑/etc/environment

       /etc/environment先于shell启动,所以/etc/environment中不能用任何命令(export,set),它不是profile,其内容并非以脚本形式执行。只能有envvar=param这样简单的形式存在于/etc/environment中

 

2、其他常用配置____________________________________________________________

 

2.1、安装ftp服务,可以用xftp登录管理(用netstat -anp | grep ftp查看)

        apt-get install vsftpd 

        

2.2、安装ssh服务,可以用xshell等远程登录管理

        apt-get install openssh

         

2.3、静态IP

        /etc/network/interfaces 

        auto lo 

            iface lo inet loopback 

            #static IP

        auto eth0

            iface eth0 inet static 

        address 192.168.1.10 

        netmask 255.255.255.0 

        gateway 192.168.1.1 

 

        /etc/resolv.conf  

        nameserver 202.106.196.115

        $sudo /etc/init.d/networking restart 

只要显示Reconfiguring network interfaces... [OK] 

即成功重启网络组件。

         

3、shell____________________________________________________________

 

3.1、shell(壳),kernel(核),shell是操作系统与外部的接口,广义上的shell:

       3.1.1、GUI shell(Graphical User Interface) : Windows Explorer, linux X window manger / GNOME...

       3.1.2、CLI shell(Command Line Interface) : cmd.exe/MS-DOS, bash / sh / ksh / csh

       

3.2、Shell是一个命令解释器,通信模式:       

       1, 交互方式(从键盘输入,可立即得到响应)

       2, shell script(不与你交互,从文件读取)方式执行

 

猜你喜欢

转载自luckywnj.iteye.com/blog/1716350
今日推荐