linux基本命令實踐

20070830_linux基本命令實踐

----------------查找文件方法----------------------

find . -name "project_supply_sign.xsl"

----------------ftp方法---------------------------

[root@ecapp1 shx3]# cd common

[root@ecapp1 common]# cd js

[root@ecapp1 js]# ftp 172.0.2.21

Connected to 172.0.2.21.

220 (vsFTPd 2.0.1)

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (172.0.2.21:root): app1

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> cd songyc

250 Directory successfully changed.

ftp> get util.js

local: util.js remote: util.js

227 Entering Passive Mode (172,0,2,21,226,163)

150 Opening BINARY mode data connection for util.js (30380 bytes).

226 File send OK.

30380 bytes received in 0.0051 seconds (5.9e+03 Kbytes/s)

ftp> quit

##################### 用jar命令打war包 ##############################################

拷貝:

[root@emed4test song_temp]# cp ../shx3.war ./

解壓:

[root@emed4test song_temp]# jar -xvf ./shx3.war       解壓到當前目錄

刪除war:

[root@emed4test song_temp]# rm -f ./shx3.war

壓縮:

[root@emed4test song_temp]# jar -cvf ../shx3.war .

如果在被壓縮目錄下,則執行上面的命令,

如果在上一級目錄:

jar -cvf shx3.war ./被壓縮目錄

[root@emed4test root]# clear              清屏  ctrl+l

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

[root@emed4test root]# finger root        顯示用戶信息

Login: root                             Name: root

Directory: /root                        Shell: /bin/bash

On since Thu Feb  9 10:29 (CST) on pts/3 from 172.25.60.118

On since Thu Feb  9 09:57 (CST) on pts/0 from 172.25.50.96

   1 hour 2 minutes idle

Mail last read Thu Dec 29 06:03 2005 (CST)

No Plan.

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

[root@emed4test root]# whoami   顯示當前用戶

root

[root@emed4test root]# who am i   顯示當前用戶帶日期

root     pts/3        Feb  9 10:29 (172.25.60.118)

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

[root@emed4test root]# date   顯示系統時間

Thu Feb  9 11:04:41 CST 2006

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

[root@emed4test root]# last   顯示此前用戶登錄信息

root     pts/3        172.25.60.118    Thu Feb  9 10:29   still logged in   

root     pts/0        172.25.50.96     Thu Feb  9 09:57   still logged in   

root     pts/0        172.25.83.246    Thu Feb  9 09:05 - 09:21  (00:16)    

duanxw   pts/1        172.25.60.118    Tue Feb  7 09:04 - 09:14  (00:10)

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

[root@emed4test root]# history|more   顯示此前執行所有命令,每屏一停

   27  kill -9 28251

   28  ps -ef|grep java

   29  mkdir logs

   30  nohup ./startWebLogic.sh &

   31  tail -f nohup.out

   32  ps -ef|grep java

   33  kill -9 28388

   34  rm -rf nohup.out

   35  nohup ./startWebLogic.sh &

   36  cd /opt/httpd2fordata/bin/

   37  ./apachectl start

   38  ./apachectl stop

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

[root@emed4test root]# uptime   顯示從上次重起到現在的時間

 11:09:24  up 19 days, 21:16,  2 users,  load average: 0.02, 0.05, 0.01

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

[root@emed4test root]# ps   顯示當前用戶正在執行的進程

  PID TTY          TIME CMD

30419 pts/3    00:00:00 bash

30457 pts/3    00:00:00 man

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

[root@emed4test root]# ps axu | more   顯示可控及不可控所有進程,每屏一停

USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND

root         1  0.0  0.0  1364   72 ?        S    Jan20   0:18 init

nobody   22702  0.0  0.0  4888  376 ?        S    Feb07   0:00 [httpd]

root     29101  0.0  0.0  4164    4 ?        S    Feb08   0:00 /bin/sh ./startWebLogic.sh

root     29120  0.2  8.0 810720 82504 ?      S    Feb08   3:13 /opt/j2sdk1.4.2_08/bin/java -client -Xms32m -

Xmx200m -XX:MaxPermSize=128m -Xverify:none -Dweblogic.Name=myserver -Dweblogic.ProductionModeEnabled= -Djava

.security.policy=/opt/bea/weblogic81/server/lib/weblogic.policy weblogic.Server

root     29280  0.0  0.0  4164  172 ?        S    Feb08   0:00 /bin/sh /opt/bea/projects/shx3/startWebLogic.

sh

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

[root@emed4test root]# top    ------持續顯示各進程系統資源使用情況-----

 11:16:21  up 19 days, 21:22,  2 users,  load average: 0.23, 0.22, 0.09

85 processes: 66 sleeping, 1 running, 0 zombie, 18 stopped

CPU0 states:   4.0% user   0.1% system    0.0% nice   0.0% iowait  95.3% idle

CPU1 states:   0.0% user   0.0% system    0.0% nice   0.0% iowait 100.0% idle

Mem:  1030284k av, 1008176k used,   22108k free,       0k shrd,  119136k buff

                    767660k actv,       0k in_d,   20896k in_c

Swap: 2040244k av,  187196k used, 1853048k free                  325008k cached

  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND

29300 root      25   0  409M 403M 31032 S     3.9 40.0  14:04   0 java

30543 root      15   0  1184 1184   856 R     0.3  0.1   0:00   0 top

    1 root      15   0    96   72    52 S     0.0  0.0   0:18   1 init

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

[root@emed4test root]# free    ----------顯示內存使用情況--------------

             total       used       free     shared    buffers     cached

Mem:       1030284    1008448      21836          0     119152     325104

-/+ buffers/cache:     564192     466092

Swap:      2040244     187232    1853012

或可使用 cat/proc/meminfo 查看內存使用的詳細情況

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

[root@emed4test root]# df -h    顯示所有文件系統硬盤使用情況

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2              15G   12G  2.2G  85% /

/dev/sda1              99M   15M   79M  16% /boot

none                  504M     0  504M   0% /dev/shm

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

[root@emed4test root]# du / -bh|more       顯示每個進程中文件的硬盤使用狀況

8.0K    /lost+found/#508086/_appsdir_shx3_war/shx3.war/META-INF

8.0K    /lost+found/#508086/_appsdir_shx3_war/shx3.war/WEB-INF/classes/net/emedchina/address/db/map

48K     /lost+found/#508086/_appsdir_shx3_war/shx3.war/WEB-INF/classes/net/emedchina/address/db

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

[root@emed4test root]# cat /proc/cpuinfo -------顯示服務器各處理器的詳細參數----------

processor       : 0

vendor_id       : GenuineIntel

cpu family      : 6

model           : 8

model name      : Pentium III (Coppermine)

stepping        : 10

cpu MHz         : 999.552

cache size      : 256 KB

physical id     : 0

siblings        : 1

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 2

wp              : yes

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse

bogomips        : 1992.29

processor       : 1

vendor_id       : GenuineIntel

cpu family      : 6

model           : 8

model name      : Pentium III (Coppermine)

stepping        : 10

cpu MHz         : 999.552

cache size      : 256 KB

physical id     : 0

siblings        : 1

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 2

wp              : yes

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse

bogomips        : 1998.84

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

[root@emed4test root]# cat /proc/interrupts 顯示當前服務器的所有中斷

           CPU0       CPU1       

  0:   90130655   82403120    IO-APIC-edge  timer

  1:          5          7    IO-APIC-edge  keyboard

  2:          0          0          XT-PIC  cascade

  8:          1          0    IO-APIC-edge  rtc

 10:          0          0   IO-APIC-level  usb-ohci

 12:          6         27    IO-APIC-edge  PS/2 Mouse

 15:          0          2    IO-APIC-edge  ide1

 28:     860651     857984   IO-APIC-level  aic7xxx

 31:    3443745    3450446   IO-APIC-level  eth0

NMI:          0          0

LOC:  172534795  172534794

ERR:          0

MIS:          0

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

[root@emed4test root]# cat /proc/version 顯示服務器的操作系統版本信息

Linux version 2.4.20-8smp ([email protected]) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 SMP Thu Mar 13 17:45:54 EST 2003

[root@emed4test root]# cat /proc/filesystems 顯示當前使用的文件系統類型

nodev   rootfs

nodev   bdev

nodev   proc

nodev   sockfs

nodev   tmpfs

nodev   shm

nodev   pipefs

        ext2

nodev   ramfs

        iso9660

nodev   devpts

nodev   pcihpfs

        ext3

nodev   usbdevfs

nodev   usbfs

nodev   autofs

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

[root@emed4test root]# lsmod   顯示當前加載的核心模塊

Module                  Size  Used by    Not tainted

parport_pc             19204   1  (autoclean)

lp                      9188   0  (autoclean)

parport                39072   1  (autoclean) [parport_pc lp]

autofs                 13684   0  (autoclean) (unused)

e100                   62340   1

keybdev                 2976   0  (unused)

mousedev                5656   0  (unused)

hid                    22308   0  (unused)

input                   6208   0  [keybdev mousedev hid]

usb-ohci               22216   0  (unused)

usbcore                82592   1  [hid usb-ohci]

ext3                   73376   2

jbd                    56336   2  [ext3]

aic7xxx               142548   3

sd_mod                 13452   6

scsi_mod              110488   2  [aic7xxx sd_mod]

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

[root@emed4test root]# set|more --------使用set命令顯示所有本地定義的Shell變量----

ANT_HOME=/opt/apache-ant-1.6.5 使用env命令顯示所有的環境變量

BASH=/bin/bash

BASH_ENV=/root/.bashrc

BASH_VERSINFO=([0]="2" [1]="05b" [2]="0" [3]="1" [4]="release" [5]="i386-redhat-linux-gnu")

BASH_VERSION='2.05b.0(1)-release'

COLORS=/etc/DIR_COLORS

COLUMNS=108

CVSROOT=:pserver:[email protected]:/opt/cvshome

DIRSTACK=()

EUID=0

GROUPS=()

G_BROKEN_FILENAMES=1

HISTFILE=/root/.bash_history

HISTFILESIZE=1000

HISTSIZE=1000

HOME=/root

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

[root@emed4test root]# echo $PATH ------- 顯示系統path的內容------

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/opt/j2sdk1.4.2_08/bin:/opt/apache-ant-1.6.5/bin:/root/bin

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

[root@emed4test root]# man -help|more ------- 顯示某一命令的幫助-------

man, version 1.5k space翻頁,ctrl+d退出

usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list]

        [-m system] [-p string] name ...

  a : find all matching entries

  c : do not use cat file

  d : print gobs of debugging information

  D : as for -d, but also display the pages

  f : same as whatis(1)

  h : print this help message

  k : same as apropos(1)

  K : search for a string in all pages

  t : use troff to format pages for printing

  w : print location of man page(s) that would be displayed

      (if no name given: print directories that would be searched)

  W : as for -w, but display filenames only

  C file   : use `file' as configuration file

  M path   : set search path for manual pages to `path'

  P pager  : use program `pager' to display pages

  S list   : colon separated section list

  m system : search for alternate system's man pages

  p string : string tells which preprocessors to run

               e - [n]eqn(1)   p - pic(1)    t - tbl(1)

               g - grap(1)     r - refer(1)  v - vgrind(1)

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

[root@emed4test root]# man ls 顯示某一命令的幫助

NAME

       ls - list directory contents

SYNOPSIS

       ls [OPTION]... [FILE]...

DESCRIPTION

       List  information  about  the FILEs (the current directory by default).

       Sort entries alphabetically if none of -cftuSUX nor --sort.

       Mandatory arguments to long options are  mandatory  for  short  options

       too.

       -a, --all

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

[root@emed4test root]# ls 顯示目錄中文件列表

anaconda-ks.cfg  bea  fixbuild  install.log  install.log.syslog  mbox

ls -F 顯示當前目錄下內容(區別顯示目錄和文件)

ls -F a_directory 顯示a_directory目錄下的內容(區別顯示目錄和文件)

ls *.bea 顯示當前目錄下所有後綴bea的文件

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

[root@emed4test root]# apropos kill 顯示所有指定功能相關的命令

XKillClient [XSetCloseDownMode] (3x)  - control clients

baudrate [killchar]  (3x)  - curses environment query routines

baudrate [killwchar] (3x)  - curses environment query routines

erasechar [killchar] (3x)  - curses environment query routines

erasechar [killwchar] (3x)  - curses environment query routines

erasewchar [killchar] (3x)  - curses environment query routines

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

[root@emed4test root]# help kill 顯示命令的幫助

kill: kill [-s sigspec | -n signum | -sigspec] [pid | job]... or kill -l [sigspec]

    Send the processes named by PID (or JOB) the signal SIGSPEC.  If

    SIGSPEC is not present, then SIGTERM is assumed.  An argument of `-l'

    lists the signal names; if arguments follow `-l' they are assumed to

    be signal numbers for which names should be listed.  Kill is a shell

    builtin for two reasons: it allows job IDs to be used instead of

    process IDs, and, if you have reached the limit on processes that

    you can create, you don't have to start a process to kill another one.

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

[root@emed4test root]# ls -al |more 詳細顯示當前目錄下所有文件

total 248

drwxr-x---   18 root     root         4096 Feb  8 16:21 .

drwxr-xr-x   22 root     root         4096 Jan 21 06:23 ..

-rw-r--r--    1 root     root         1485 May 18  2005 anaconda-ks.cfg

-rw-------    1 root     root        12508 Feb  9 12:19 .bash_history

-rw-r--r--    1 root     root           24 Jun 11  2000 .bash_logout

-rw-r--r--    1 root     root          234 Jul  6  2001 .bash_profile

-rw-r--r--    1 root     root          509 Aug  5  2005 .bashrc

-rw-r--r--    1 root     root          365 Jun 17  2005 .bashrc.bak

drwxr-xr-x    2 root     root         4096 Aug  5  2005 bea

-rw-r--r--    1 root     root          210 Jun 11  2000 .cshrc

-rw-------    1 root     root           58 Aug  5  2005 .cvspass

-rw-------    1 root     root           16 May 18  2005 .esd_auth

drwxr-xr-x    6 root     root         4096 Aug 18 09:50 fixbuild

-rw-r--r--    1 root     root        46996 Jun  6  2005 .fonts.cache-1

drwx------    5 root     root         4096 Dec 29 03:15 .gconf

drwx------    3 root     root         4096 Dec 29 03:12 .gconfd

drwx------    5 root     root         4096 May 18  2005 .gnome

drwxr-xr-x    6 root     root         4096 Jun  8  2005 .gnome2

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

[root@emed4test root]# ls

anaconda-ks.cfg  bea  fixbuild  install.log  install.log.syslog  mbox

[root@emed4test root]# cd ..

[root@emed4test /]# ls

bin   dev  home    lib         misc  opt   root  temp      tmp  var

boot  etc  initrd  lost+found  mnt   proc  sbin  tftpboot  usr  webdata

[root@emed4test /]# cp /root/install.log . -------拷貝源文件到目標-----

[root@emed4test /]# ls

bin   dev  home    install.log  lost+found  mnt  proc  sbin  tftpboot  usr  webdata

boot  etc  initrd  lib          misc        opt  root  temp  tmp       var

可同時拷貝多個文件,如:

cp a b c_directory     將文件a,b拷貝到c_directory

可結合通配符的使用,如:

cp data* c_directory   將所有data開頭的文件複製到c_directory

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

[root@emed4test /]# ls

bin   dev  home    inst.log  lost+found  mnt  proc  sbin  tftpboot  usr  webdata

boot  etc  initrd  lib       misc        opt  root  temp  tmp       var

如果第二個參數是個文件mv的作用是改名

[root@emed4test /]# mv inst.log install.log ------- 將源文件改名----------------

[root@emed4test /]# ls

bin   dev  home    install.log  lost+found  mnt  proc  sbin  tftpboot  usr  webdata

boot  etc  initrd  lib          misc        opt  root  temp  tmp       var

如果第二個參數是個目錄mv的作用是移動

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

[root@emed4test /]# ls

bin   dev  home    install.log  lost+found  mnt  proc  sbin  tftpboot  usr  webdata

boot  etc  initrd  lib          misc        opt  root  temp  tmp       var

[root@emed4test /]# mv install.log ./root 移動文件到指定目標

mv: overwrite `./root/install.log'? y

[root@emed4test /]# ls

bin   dev  home    lib         misc  opt   root  temp      tmp  var

boot  etc  initrd  lost+found  mnt   proc  sbin  tftpboot  usr  webdata

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

[root@emed4test /]# ls

bin   dev  home    install.log  lost+found  mnt  proc  sbin  tftpboot  usr  webdata

boot  etc  initrd  lib          misc        opt  root  temp  tmp       var

[root@emed4test /]# rm install.log    刪除文件(須擁有該文件)

rm: remove regular file `install.log'? y

[root@emed4test /]# ls

bin   dev  home    lib         misc  opt   root  temp      tmp  var

boot  etc  initrd  lost+found  mnt   proc  sbin  tftpboot  usr  webdata

rm命令在執行前沒有提示,而且錯誤的命令也可被執行,因此非常危險,需要在執行前做好檢查。

例如:rm /opt/nohut.out   將被執行

      rm opt nohut.out    提示opt是個目錄不能刪除,而nohut.out被刪除。

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

[root@emed4test /]# mkdir songyc ----------創建目錄------

[root@emed4test /]# ls

bin   dev  home     initrd  lost+found  mnt  proc  sbin  tftpboot  usr  webdata

boot  etc  songyc  lib     misc        opt  root  temp  tmp       var

[root@emed4test /]# rmdir songyc -------刪除目錄----- rmdir拒絕刪除非空目錄

[root@emed4test /]# ls

bin   dev  home    lib         misc  opt   root  temp      tmp  var

boot  etc  initrd  lost+found  mnt   proc  sbin  tftpboot  usr  webdata

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

rm -r 作爲root用戶刪除文件,可刪除所有文件

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

[root@emed4test root]# cat install.log|more 顯示文件內容

Installing 690 packages

Installing glibc-common-2.3.2-11.9.

Installing hwdata-0.75-1.

Installing redhat-logos-1.1.12-1.

Installing setup-2.5.25-1.

Installing filesystem-2.2.1-3.

Installing basesystem-8.0-2.

Installing glibc-2.3.2-11.9.

Installing bzip2-libs-1.0.2-8.

Installing chkconfig-1.3.8-1.

Installing cracklib-2.7-21.

Installing db4-4.0.14-20.

Installing e2fsprogs-1.32-6.

Installing elfutils-libelf-0.76-3.

Installing expat-1.95.5-2.

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

[root@emed4test /]# find / -name install.log 按名稱查詢文件

/root/install.log

[14]+  Stopped                 find / -name install.log

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

[root@emed4test /]# locate install.html.    --------顯示包含該字符串的文件路徑--------

/var/www/manual/install.html.en 如果加/表示在目錄及以下子目錄查找,不加/在當前目錄查找

/var/www/manual/install.html.ja.jis

/var/www/manual/install.html.ko.euc-kr

/usr/apache2.bak/manual/install.html.de

/usr/apache2.bak/manual/install.html.en

/usr/apache2.bak/manual/install.html.es

/usr/apache2.bak/manual/install.html.ja.euc-jp

/usr/apache2.bak/manual/install.html.ko.euc-kr

/usr/apache2.bak/manual/install.html.ru.koi8-r

/home/duanxw/httpd2.0/manual/install.html.de

/home/duanxw/httpd2.0/manual/install.html.en

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

[root@emed4test root]# touch songyc.test -----------創建空文件----------------

[root@emed4test root]# ls

anaconda-ks.cfg  bea  fixbuild  songyc.test  install.log  install.log.syslog  mbox

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

startx 啓動窗口界面的linux

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

shutdown -h now 關機

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

[root@emed4test applications]# passwd duanxw --------修改用戶口令,root可改所有-----

Changing password for user duanxw.

New password:

BAD PASSWORD: it is too simplistic/systematic

Retype new password:

passwd: all authentication tokens updated successfully.

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

[root@emed4test /]# ping 172.25.88.89 顯示ping的信息

PING 172.25.88.89 (172.25.88.89) 56(84) bytes of data.

64 bytes from 172.25.88.89: icmp_seq=1 ttl=64 time=0.163 ms

64 bytes from 172.25.88.89: icmp_seq=2 ttl=64 time=0.125 ms

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

[root@emed4test /]# route -n 顯示路由表

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

172.25.0.0      0.0.0.0         255.255.0.0     U     0      0        0 eth0

169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0

127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo

0.0.0.0         172.25.2.1      0.0.0.0         UG    0      0        0 eth0

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

[root@emed4test /]# nslookup 172.25.88.89  測試dns是否工作,並可顯示指定ip主機名

Note:  nslookup is deprecated and may be removed from future releases.

Consider using the `dig' or `host' programs instead.  Run nslookup with

the `-sil[ent]' option to prevent this message from appearing.

Server:         210.51.183.181

Address:        210.51.183.181#53

** server can't find 89.88.25.172.in-addr.arpa: NXDOMAIN

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

top -p processId  顯示某一進程實時耗用的資源

************************************用vi命令修改文件的方法************************

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

1、vi 文件名

2、鍵入i            進入修改模式  ,也有的文檔說是vi

3、按esc             進入命令模式

4、輸入:wq           保存修改並退出

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

******************顯示環境變量HOME

echo $HOME  

/home/terry

*******************設置一個新的環境變量WELCOME

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

export WELCOME="Hello!"

echo $WELCOME

Hello!

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

*******************使用unset命令來清除環境變量

set可以設置某個環境變量的值。清除環境變量的值用unset命令。如果未指定值,則該變量值將被設爲NULL。示例如下:

export TEST="Test..." #增加一個環境變量TEST

env|grep TEST #此命令有輸入,證明環境變量TEST已經存在了

TEST=Test...

unset $TEST #刪除環境變量TEST

env|grep TEST #此命令沒有輸出,證明環境變量TEST已經不存在了

*****************使用readonly命令設置只讀變量

如果使用了readonly命令的話,變量就不可以被修改或清除了。示例如下:

export TEST="Test..." #增加一個環境變量TEST

readonly TEST #將環境變量TEST設爲只讀

unset TEST #會發現此變量不能被刪除

-bash: unset: TEST: cannot unset: readonly variable

TEST="New" #會發現此也變量不能被修改

-bash: TEST: readonly variable

**********************************linux快捷鍵***************************

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

1、將光標移到行首   Ctrl + a

2、將光標移到行尾   Ctrl + e

3、擦除光標前的整行 Ctrl + u

4、擦除光標後的整行 Ctrl + k

5、刪除光標前的一個詞 Ctrl + w  (以空格分隔)

6、清屏             Ctrl + l

7、殺掉當前進程     ctrl + c

8、重起             Ctrl + Alt + Del

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

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

[root@testzone shx3]# cat config.xml

<?xml version="1.0" encoding="UTF-8"?>

<Domain ConfigurationVersion="8.1.4.0" Name="shx3">

    <Server ListenAddress="" ListenPort="7001" Name="myserver"

        NativeIOEnabled="true" ReliableDeliveryPolicy="RMDefaultPolicy" ServerVersion="8.1.4.0">

        <SSL Enabled="false" HostnameVerificationIgnored="false"

            IdentityAndTrustLocations="KeyStores" Name="myserver"/>

    </Server>

    <JMSFileStore Directory="rmfilestore" Name="FileStore"/>

    <WSReliableDeliveryPolicy DefaultRetryCount="10"

        DefaultTimeToLive="60000" Name="RMDefaultPolicy" Store="FileStore"/>

    <Security Name="shx3" PasswordPolicy="wl_default_password_policy"

        Realm="wl_default_realm" RealmSetup="true"/>

    <EmbeddedLDAP

        CredentialEncrypted="{3DES}ty0HtOLFqyXHrSFXH3RhzodnQpjMa9NsVth5+CTI2h4=" Name="shx3"/>

    <SecurityConfiguration

        CredentialEncrypted="{3DES}+pVwSQ2Vdgzbxw30no0fOmBXMpZORhpmJyqoAn7vW+upHIN8HPxJ1BJkuxyMKt5k8Ydt604u+smmBRScMaynSSP6rO1rkI1Y"

        Name="shx3" RealmBootStrapVersion="1"/>

    <Realm FileRealm="wl_default_file_realm" Name="wl_default_realm"/>

    <FileRealm Name="wl_default_file_realm"/>

    <PasswordPolicy Name="wl_default_password_policy"/>

    <JMSServer Name="WSStoreForwardInternalJMSServermyserver"

        Store="FileStore" Targets="myserver">

        <JMSQueue CreationTime="1127704900867"

            JNDIName="jms.internal.queue.WSStoreForwardQueue"

            JNDINameReplicated="false" Name="WSInternaljms.internal.queue.WSStoreForwardQueuemyserver"/>

        <JMSQueue CreationTime="1127704901248"

            JNDIName="jms.internal.queue.WSDupsEliminationHistoryQueue"

            JNDINameReplicated="false" Name="WSInternaljms.internal.queue.WSDupsEliminationHistoryQueuemyserver"/>

    </JMSServer>

    <JDBCConnectionPool DriverName="oracle.jdbc.OracleDriver"

        Name="trade" PasswordEncrypted="{3DES}/8zgH7AfRYY="

        Properties="user=trade" StatementCacheSize="200"

        Targets="myserver" TestConnectionsOnReserve="true"

        TestTableName="SQL SELECT 1 FROM DUAL" URL="jdbc:oracle:thin:@172.25.88.89:1521:test2"/>

    <JDBCTxDataSource JNDIName="shx3_ds" Name="shx3_ds" PoolName="trade" Targets="myserver"/>

    <Application Name="shx3"

        Path="/opt/bea/projects/shx3/myserver/upload"

        StagingMode="nostage" TwoPhase="true">

        <WebAppComponent Name="shx3" Targets="myserver" URI="shx3.war"/>

    </Application>

</Domain>

//以下爲修改啓動缺省路徑

[root@testzone shx3]#

[root@testzone shx3]# cd /opt/httpd2.0.54/

[root@testzone httpd2.0.54]# cd conf/

[root@testzone conf]# vi Weblogic.conf                          *******************

WebLogicHost 172.25.88.92

WebLogicPort 7001

MatchExpression *.jsp

MatchExpression *.js

MatchExpression *.ocx

MatchExpression *.cab

MatchExpression */images/*

MatchExpression */common/*

<Location ~ "//shx3">                                            //改變文件映射路徑

SetHandler weblogic-handler

ErrorPage http://172.25.88.92/errorPage.htm

</Location>

~

"Weblogic.conf" [converted] 12L, 291C written                                                                     

[root@testzone conf]#

[root@testzone bin]# ./apachectl stop

httpd (no pid file) not running

[root@testzone bin]# ./apachectl start

//以下爲修改文件根目錄

[root@testzone bin]# cat ../conf/httpd.conf |grep DocumentRoot

# DocumentRoot: The directory out of which you will serve your

DocumentRoot "/webdata/htdocs"

# This should be changed to whatever you set DocumentRoot to.

# the manual, even if you choose to move your DocumentRoot.  You may comment

#    DocumentRoot /www/docs/dummy-host.example.com

[root@testzone bin]# cd /webdata/htdocs/

[root@testzone htdocs]# ls

index.html  iturs  shx3  upload

[root@testzone htdocs]# vi index.html

<html>

<head><title>Emed 3.0 fix Testing</title></head>

<body>

<script language="JavaScript">

window.location="/shx3/index.jsp";

</script>

</body>

</html>

"index.html" [converted] 8L, 155C written  

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

退出程序一般用

ctrl+d

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

查看命令幫助用man

man cat

翻頁用space

退出用q

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

cd 絕對路徑,以/開頭  ,如  cd /opt             絕對路徑不參照當前目錄

cd 相對路徑,           如  cd bin              相對路徑必須在當前路徑之下

                                                相對路徑.代表當前目錄,..代表父目錄

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

-------------保存屏幕輸出到文件---------------

[root@testzone /]# touch song.te

[root@testzone /]# ls -F > song.te              將命令執行結果保存到song.te 注意>符號

[root@testzone /]# cat song.te

bin/

boot/

data/

data1/

dev/

etc/

home/

initrd/

lib/

lost+found/

misc/

mnt/

opt/

proc/

root/

sbin/

song.te

tmp/

usr/

var/

webdata/

zshua/

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

------殺掉當前進程用

ctrl +c

------休眠當前進程

ctrl +z

------喚醒進程

命令行鍵入 fg

------指定命令後臺運行

在命令結尾加 &   ,例如 ./startWebLogic.sh &

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

顯示文件所佔空間及磁盤剩餘空間

du

顯示文件已用空間,及所佔比例

df

uptime 顯示從上次啓動到現在的時間

顯示當前系統用戶,即他們在做什麼

w

[root@testzone /]# w

 16:04:46  up 1 day,  5:04,  2 users,  load average: 1.06, 1.05, 1.01

USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU  WHAT

root     pts/0    172.25.60.118     1:25pm  1.00s  2:37m  0.01s  w

root     :0       -                Mon11am   ?     0.00s  0.21s  /usr/bin/gnome-session

head -30 song.test  顯示song.test的前30行

tail -30 song.test  顯示song.test的後30行

[root@testzone root]# file install.log     描繪文件特性

install.log: ASCII text

[root@testzone root]# wc install.log

   行數    詞數   字符數

    719    1437   22170 install.log

分別對應l    w      m

*****************************************用vi修改文件**************************************

先啓動shell:  bash

vi filename

切換模式                   i/esc    (修改模式顯示insert,命令模式無顯示)

輸入命令冒號加行號數字     :1   即跳到第一行

跳到文件尾ctrl g

找某個關鍵字用             /關鍵字    按n向下找

輸入:wq           保存修改並退出

apache的配置文件在conf/httpd.conf 通常修改影響壓力測試的最大和最小進程數

*****************************************安裝rstatd方法********************************

1、查看linux版本號

[root@localhost root]# more /etc/issue

Red Hat Linux release 9 (Shrike)

Kernel /r on an /m

2、在http://rpm.pbone.net/ 上找rstatd

找類似i386.rpm的,不要下src.rpm

下載rusers-server-0.17-25.i386.rpm

3、用SSH Secure File Transfer Client 將安裝文件上傳至服務器

4、安裝rstatd

[root@localhost /]# rpm -ivh *.rpm

warning: rusers-server-0.17-25.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Preparing...                ########################################### [100%]

   1:rusers-server          ########################################### [100%]

5、查看進程情況

[root@localhost /]# ps -ef|grep rpc

rpc       3231     1  0 Oct12 ?        00:00:00 [portmap]

rpcuser   3250     1  0 Oct12 ?        00:00:00 [rpc.statd]

root     18702 18638  0 13:40 pts/0    00:00:00 grep rpc

6、啓動rstatd進程

[root@localhost /]# rpc.rstatd

[root@linux32 /]# ps -ef|grep rpc

rpc        609     1  0 Oct08 ?        00:00:00 [portmap]

rpcuser    628     1  0 Oct08 ?        00:00:00 [rpc.statd]

root     20784     1  0 13:54 ?        00:00:00 rpc.rstatd          運行rstatd服務

root     20786 20708  0 13:56 pts/0    00:00:00 grep rpc

########################################################################

#######################|  通過ftp上傳下載文件  |##########################

########################################################################

cmd>

先登錄ftp,登錄後(如果新裝的linux系統需要打開ftp並將用戶加入可通過ftp訪問的列表中)

-----上傳:

ftp> put d:/deploy/shx3.war                 這是上傳某本地文件到linux上的當前路徑

d:/deploy/shx3.war: File not found

ftp> put d:/deploy/trade/shx3.war

200 PORT command successful. Consider using PASV.

150 Ok to send data.

226 File receive OK.

ftp: 80300209 bytes sent in 10.92Seconds 7352.15Kbytes/sec.

ftp>

-----下載:

ftp> get nohup.out                          下載到當前用戶目錄下,如administrator/

200 PORT command successful. Consider using PASV.

150 Opening BINARY mode data connection for nohup.out (169882 bytes).

226 File send OK.

ftp: 169882 bytes received in 0.02Seconds 10617.63Kbytes/sec.

ftp>

退出:

quit

======查看網絡情況

netstat

(不反查域名和服務名),例如:netstat -anp。

查看服務器偵聽情況,使用:netstat -an | grep LISTEN

查看服務器已建立的連接,使用:netstat -an | grep ESTABLISHED

ifconfig

ifconfig:查看(或設置)網絡設備信息

ifconfig -a:查看所有網絡設置信息

======查看登陸及重起情況

last:顯示登錄到服務器的情況以及服務器重啓情況

======查看硬盤使用情況

df:顯示硬盤空間及使用情況,Linux下可以帶參數h,顯示結果更人性化。例如:

df -h 硬盤空間按人性化顯示

df -k 硬盤空間按KB顯示

df -m 硬盤空間按MB顯示

w:顯示登錄到服務器上的用戶列表

以下幾個命令僅針對Linux

======顯示當前打開的文件

lsof:顯示當前打開的文件列表,包括建立的socket連接等。本命令可以用於程序員檢查編寫的程序打開的文件數。

======顯示(或設置)系統內核參數

sysctl:顯示(或設置)系統內核參數

sysctl -a 顯示所有內核參數

sysctl -w 參數名=參數值

例如:sysctl -w fs.file-max=10240 設置系統允許同時打開的最大文件數爲10240。

內核參數fs.file-nr包括三個參數值,第一個參數表示系統中曾經同時打開過的文件數峯值,

第二個參數表示空閒(分配後已釋放)的文件數,

第三個參數表示可以打開的最大文件數,其值等於fs.file-max。

當前打開的文件數 = 第一個參數值 - 第二個參數值

例如:

fs.file-nr = 977 223 10240

當前打開的文件數 = 977 - 233 = 744

設置內核參數時務必小心,如果設置不當會導致系統異常,甚至當機。

=======顯示用戶可以使用的資源限制

ulimit:顯示(或設置)用戶可以使用的資源限制

ulimit -a 顯示用戶可以使用的資源限制

ulimit unlimited 不限制用戶可以使用的資源,但本設置對可打開的最大文件數(max open files)

和可同時運行的最大進程數(max user processes)無效

ulimit -n <可以同時打開的文件數> 設置用戶可以同時打開的最大文件數(max open files)

例如:ulimit -n 8192

如果本參數設置過小,對於併發訪問量大的網站,可能會出現too many open files的錯誤

ulimit -u <可以運行的最大併發進程數> 設置用戶可以同時運行的最大進程數(max user processes)

例如:ulimit -u 1024

################################## 修改系統日期和時間 ##################################

修改日期

[root@emed4test exchange]# date -s 20070221

Wed Feb 21 00:00:00 CST 2007

修改時間

[root@emed4test exchange]# date -s 15:21:21

Wed Feb 21 15:21:21 CST 2007

######################################  linux文本方式與圖形方式切換的方法  ###################################

由xwindow切換text的方法

  ctrl+alt+F1   

  ctrl+alt+F2   

  ctrl+alt+F3   

  ctrl+alt+F4   

  ctrl+alt+F5   

  ctrl+alt+F6   

由text切換xwindow的方法

CTRL+ALT+F7回XWINDOWS

linux 網絡設置:在命令方式執行setup

更改域服務器:/etc/host.conf

sync:將內存中數據保存到硬盤

###############################  reboot:重啓, 通常在重起之前執行sync多次 ################################

int4:以命令行方式啓動,int3與int4差別在於是否啓動一個服務

int5:以xwindow方式啓動

修改默認啓動方式:/etc/vi inittab修改id:5:initdefault

linux重起的方法:ctrl+alt+backspace

查看ip的命令:ifconfig

############################# linux打開ftp #################################

linux->服務器設置->服務->勾選vsftpd 保存

編輯vsftpd.conf

增加一行:userlist_enable=YES

編輯vsftpd.user_list

username=YES 是拒絕訪問的

username=NO  是接受訪問的

例如:root=NO

編輯vsftpd.ftpusers

出現在這個文件中的用戶都是不能ftp登陸的,註釋掉即可

例如:  #root       此時root用戶就可以ftp登陸了

 

################################### tar命令用法 ############################

tar命令的詳細講解+例子

*****例1:把/home目錄下包括它的子目錄全部做備份文件,備份文件名爲usr.tar。

$ tar cvf usr.tar /home

例2:把/home目錄下包括它的子目錄全部做備份文件,並進行壓縮,備份文件名爲usr.tar.gz 。

$ tar czvf usr.tar.gz /home

例3:把usr.tar.gz這個備份文件還原並解壓縮。

$ tar xzvf usr.tar.gz

例4:查看usr.tar備份文件的內容,並以分屏方式顯示在顯示器上。

$ tar tvf usr.tar | more

要將文件備份到一個特定的設備,只需把設備名作爲備份文件名

例5:用戶在/dev/fd0設備的軟盤中創建一個備份文件,並將/home 目錄中所有的文件都拷貝到備份文件中  

$ tar cf /dev/fd0 /home

要恢復設備磁盤中的文件,可使用xf選項:

$ tar xf /dev/fd0

如果用戶備份的文件大小超過設備可用的存貯空間,如軟盤,您可以創建一個多卷的tar備份文件。M選項指示tar命令提示您使用一個新的存貯設備,當使用M選項向一個軟驅進行存檔時,tar命令在一張軟盤已滿的時候會提醒您再放入一張新的軟盤。這樣您就可以把tar檔案存入幾張磁盤中。

$ tar cMf /dev/fd0 /home

要恢復幾張盤中的檔案,只要將第一張放入軟驅,然後輸入有x和M選項的tar命令。在必要時您會被提醒放入另外一張軟盤。

$ tar xMf /dev/fd0

從測試服務器通過ftp上傳到vmvare的linux服務器

/opt/bea/test/shx3/shx3.tar

/

############################# linux下使用u盤 ######################################

 

cat /proc/partitions 後就可看到USB盤的號sdb和sdb1

操作過程:

1、首先,在/mnt下新建一子目錄:

cd /mnt   

mkdir usb

2 、插入優盤後,用mount裝載:

mount /dev/sdb1

/mnt/usb (或mount &endash;t vfat /dev/sdb1

/mnt/usb)

3、 隨後/mnt/usb即可使用。

4、 用完後,先用umount /mnt/usb卸載,然後可以拔出優盤。

看文件最後200行

tail -200f 文件名

################################# 看系統是64還是32位的 ###############################

[root@tapp1 temp]# uname -a

Linux tapp1 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686 i386 GNU/Linux

[root@tapp1 temp]# more /etc/issue

Red Hat Enterprise Linux ES release 4 (Nahant)

Kernel /r on an /m

從上面可以看出是32位的,如果是64位會有64

############################ 十分有用的ln命令 #################################

ln命令

  該命令在文件之間創建鏈接。這種操作實際上是給系統中已有的某個文件指定另外一個可用於訪問它的名稱。對於這個新的文件名,我們可以爲之指定不同的訪問權限,以控制對信息的共享和安全性的問題。

  如果鏈接指向目錄,用戶就可以利用該鏈接直接進入被鏈接的目錄而不用打一大堆的路徑名。而且,即使我們刪除這個鏈接,也不會破壞原來的目錄。

  語法:ln [選項] 目標 [鏈接名]

     ln [選項] 目標 目錄

  鏈接有兩種,一種被稱爲硬鏈接(Hard Link),另一種被稱爲符號鏈接(Symbolic Link)。建立硬鏈接時,鏈接文件和被鏈接文件必須位於同一個文件系統中,並且不能建立指向目錄的硬鏈接。而對符號鏈接,則不存在這個問題。默認情況下,ln產生硬鏈接。

  在硬鏈接的情況下,參數中的&rdquor;目標”被鏈接至[鏈接名]。如果[鏈接名]是一個目錄名,系統將在該目錄之下建立一個或多個與&rdquor;目標”同名的鏈接文件,鏈接文件和被鏈接文件的內容完全相同。如果[鏈接名]爲一個文件,用戶將被告知該文件已存在且不進行鏈接。如果指定了多個&rdquor;目標”參數,那麼最後一個參數必須爲目錄。

  如果給ln命令加上- s選項,則建立符號鏈接。如果[鏈接名]已經存在但不是目錄,將不做鏈接。[鏈接名]可以是任何一個文件名(可包含路徑),也可以是一個目錄,並且允許它與&rdquor;目標”不在同一個文件系統中。如果[鏈接名]是一個已經存在的目錄,系統將在該目錄下建立一個或多個與&rdquor;目標”同名的文件,此新建的文件實際上是指向原&rdquor;目標”的符號鏈接文件。

  例:$ ln - s lunch /home/xu

假設CVS資源庫目錄爲/opt/cvsroot,另外再建一個連接/opt/cvspublic -> /opt/cvsroot。這個連接是對外公佈的目錄。這樣可以方便地改變CVS資源庫的實際位置。以下操作以root身份進行。

cd /opt

mkdir cvsroot

ln -s cvsroot cvspublic

############################# 創建用戶相關操作 #################################

useradd和adduser一樣

useradd songyc  創建一個songyc用戶

groupadd cvs    創建cvs組

useradd -g cvs songyc   創建一個組用戶

########################## 改變文檔所有權chown #################################

將檔案 file1.txt 的擁有者設爲 songyc 組的使用者設爲cvs :

chown cvs:songyc file1.txt

chown -R songyc:cvs temp_dir   對目前目錄下的所有檔案與子目錄進行相同的擁有者變更(即以遞歸方式逐個變更)

############################## unix shell編程學習筆記 ###########################

UNIX支持用分號隔開多個命令,而成爲複合命令

如:ls -l *.tar; ps -ef|grep java

執行結果如下

[root@localhost root]# ls -l *.class;ps -ef|grep java

-rw-r--r--    1 root     root          410 Dec 25 14:27 A.class

root     15678 15658  0 Apr18 ?        00:10:23 /opt/j2sdk1.4.2_08/bin/java -client -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:MaxPermSize=512m -XX:SurvivorRatio=8 -Xverify:none -Dweblogic.Name=myserver -Dweblogic.management.username=weblogic -Dweblogic.management.password=weblogic -Dweblogic.Producti

root      9125  9100  0 08:59 pts/0    00:00:00 grep java

SHELL的類型

1、Bourne Shell:包括Sh,ksh,bash

2、C Shell:包括csh,tcsh

不同的SHELL會有不同的提示符

SHELL兩種執行模式:

1、交互模式

2、非交互模式

SHELL腳本格式:

第一行必須是:# !/bin/sh         放在其他行會被當作註釋而不被執行。

#表示註釋

簡單示例:

# !/bin/sh

# 使用-F參數可以在列目錄時顯示出文件還是目錄,在目錄後會自動加一個/

ls -F

# 使用-l參數實現一行顯示一個,便於操作

ls -l

# 使用-a參數列出所有隱藏的文件和目錄,也就是以.開頭的

ls -a

# cp命令當目標已經存在是使用-i參數可以給出提示信息避免出現嚴重後果

cp -i test  opt/test

# file命令可以列出文件的類型是普通文件、shell腳本、還是一個庫

file /sbin/sh

# 每一個用戶組都有一個文件定義其權限,可以查看相應的.profile文件

ls -l

除了可以使用&在後臺運行進程,還可以將一個前臺進程移動到後臺。

確定那個鍵可以將進程掛起

[root@localhost songyc]# stty -a

speed 38400 baud; rows 47; columns 132; line = 0;

intr = ^C; quit = ^/; erase = ^H; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;

werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;

-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts

-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel

opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0

isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

#################################### unix shell #######################################

[root@localhost root]# aa="administrator_test"                定義變量

[root@localhost root]# echo "your test is : /n $aa"           輸出引用變量

your test is : /n administrator_test                          輸出的結果

echo 和 printf 功能相同

<script type="text/javascript"></script>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章