现在的位置: 首页 > 综合 > 正文

笔记081103 TALK IFCONFIG 环境变量 Find Things On Unix GREP PS KILL SLEEP JOBS FG BG PKILL

2018年04月10日 ⁄ 综合 ⁄ 共 5134字 ⁄ 字号 评论关闭
Nov 4, 2008 1:11 PM posted by tiger chang ********************************************************
Name
    :changtiger
Date      :2008-11-03
Email    :o52tiger@yahoo.com.cn   

********************************************************


Linux / Unix talk command

About talk

Talk with other logged in users.

Syntax

talk person
[ttyname]

person If you wish to talk to someone on your own machine, then person
is just the person's login name. If you wish to talk to a user on another host,
then person is of the form 'user@host'.
ttyname If you wish to talk to a user who is logged in more than once,
the ttyname argument may be used to indicate the appropriate terminal name,
where ttyname is of the form 'ttyXX' or 'pts/X'.

Examples

talk hope

Typing the above command would start a talking session with the user hope.


********************************************************
ifconfig
command

Examples

ifconfig eth0

View the network settings on the first Ethernet
adapter installed in the computer.

ifconfig -a

Display into on all network interfaces on
server, active or inactive.

ifconfig eth0 down

If eth0 exists would take it down causing it
cannot send or receive any information.

ifconfig eth0 up

If eth0 exists and in the down state would
return it back to the up state allowing to to send and receive information.

ifconfig eth0 192.168.1.102 netmask
255.255.255.0 broadcast 192.168.1.255

Assign eth0 with the above values for IP, netmask
and broadcast address.

********************************************************
设置环境变量     
(这是修改环境变量的一般步骤)
在主目录下使用以下命令
ls -a 
查看文件
可以看到隐藏文件.bash_profile
该文件用来存储环境变量
对该文件进行编辑可以使用vi,kate等编辑工具

vi .bash_profile
修改
path=$PATH:/SFDS:.

继续修改该文件 PATH=$PATH:/SFDS:/sbin:.
这个是用:区分的,只需要将你要要执行的命令所在的文件夹的地址添加在这里,当执行命令的时候它会依次在这里记录的目录里面查找。.表示当前目录。$PATH就是对全局变量的引用。

source .bash_profile
执行给文件(由于该文件是一个shell文件,在编辑后续重新执行一次 ,
可以减产文件是否改的正确)
当机器注销一次后才可以在全局产生作用,在原来执行的终端中执行了,会只在该终端中产生作用。

********************************************************
系统环境变量的设置:
/etc/profile文件
文件内容如下
bash-2.05$ cat profile
#ident  "@(#)profile    1.19   
01/03/13 SMI"   /* SVr4.0 1.3   */


# The profile that all logins get
before using their own .profile.


trap ""  2 3
export LOGNAME PATH

if [ "$TERM" = "" ]
then
        if /bin/i386
        then
               
TERM=sun-color

        else
                TERM=sun
        fi
        export TERM
fi

#       Login and -su shells get
/etc/profile services.

#       -rsh is given its environment
in its .profile.


case "$0" in
-sh | -ksh | -jsh | -bash)

        if [ ! -f .hushlogin
]

        then
               
/usr/sbin/quota

                #       Allow the user
to break the Message-Of-The-Day only.

                trap "trap '' 2" 
2

                /bin/cat -s
/etc/motd

                trap "" 2

                /bin/mail -E
                case $? in
                0)
                        echo "You have
new mail."

                        ;;
                2)
                        echo "You have
mail."

                        ;;
                esac
        fi
esac

umask 022
trap  2 3
CC=/usr/local/bin/gcc; export
CC

CCC=/usr/local/bin/g++; export
CCC

ORACLE_BASE=/export/home/oracle9;
export ORACLE_BASE

ORACLE_HOME=/export/home/oracle9/product/9.2.0;
export ORACLE_HOME

ORACLE_SID=tarena; export
ORACLE_SID

ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data;
export ORA_NLS33

LD_LIBRARY_PATH=/usr/local/lib:$ORACLE_HOME/lib32:/usr/lib;
export LD_LIBRARY_PA

TH
NLS_LANG=american_america.ZHS16GBK;
export NLS_LANG

PATH=$ORACLE_HOME/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/usr/ucb:/etc:/usr
/openwin/bin:/usr/ccs/bin:.
bash-2.05$
********************************************************
Find Things On Unix
users    :Display a compact list
of users logged in
who     :Display information about all users currently
logged on
who am i    :the whow am i command displays information about yours
real user ID
whoam i     :the whoami command displays only the login name of
the effective user
find     :Find files based on specific criteria, then
execute a mcommand on the matching files
    find / -name perl
从跟目录开始查找
    find ~/ -name perl 根据名字来查找
    find ~/ -mtime 10 -print 
根据修改时间来找 并打印出来
    find ~/ -atime 2 ReadMe.txt
        -atime n True if
the file was accessed n days ago.  The  access   time of directories in path is
changed by find itself.
    find /export/home -type f -atime +365 -exec rm {}
/;
    find ~ find.txt 在当前目录下查找find.txt文件。
   
grep    
    grep
root /etc/passwd
    ls -a | grep -i 'sep 1'
         将由ls -a 查找的的文件名字
传递给grep在其中查找含有字符串'sep 1'的文件名
    bash-2.05$ ls -al | grep -i 'Find'         
-i 表示要忽略大小写
    -rw-r--r--   1 changhu  other      17780 11月  3 20:12
Find.txt
    -rw-r--r--   1 changhu  other      17780 11月  3 19:59
find.txt
    -rw-r--r--   1 changhu  other      17780 11月  3 19:52
find_man.txt

        bash-2.05$ ls -al | grep -i 'find'
   
-rw-r--r--   1 changhu  other      17780 11月  3 19:59 find.txt
   
-rw-r--r--   1 changhu  other      17780 11月  3 19:52 find_man.txt
   
bash-2.05$ ls -al | grep -i 'find_'
    -rw-r--r--   1 changhu  other     
17780 11月  3 19:52 find_man.txt

    grep -i 'find' *.txt
在所有的txt文件中查找字符串'find'

    ls find* |xargs grep 'find .'
先列出find*,xargs表示讲得到的每一个条信息作为一个参数        ,给grep使用。
wc   
   
统计文件的行数,单词书,字符数。
    bash-2.05$ wc -l find.txt
         594 find.txt
du

    查看磁盘使用情况。
    du -sk *

********************************************************
ps    
查看当前机子上运行的进程

    ps -ef 列出所有的进程的详细信息。
    bash-2.05$ ps -ef | grep java 
查看含字符java 的进程

     changhu  6825  4003  0 20:28:31
pts/34   0:00 grep java

kill   
    kill -9 6992 关闭ID
为6992的进程。

   
sleep
    sleep 300 &   
&表示将此进程放在后台进行。

jobs    
    Display which jobs are currently
running

    显示当前正在运行的进程
bg %n
    place a job in the
background

    将一个进程放在后台运行
fg %n
    place a job in the
foreground

    将一个进程放在前台运行
pkill    
    pkill sleep 按照名字关闭进程,关闭 sleep
进程,sleep为进程名

********************************************************

抱歉!评论已关闭.