linux命令之使用篇【以后会不断丰富】

以下所有的命令均在aix6.1.0.0下通过(查看aix版本信息的命令为oslevel)

1、chown

参考网站

http://baike.baidu.com/view/1229019.htm

 

使用:

chown beps:beps  /cnaps2/rel/beps/bin/BE*

 

2、passwd文件解析

网站:

http://www.dzsc.com/data/html/2009-8-5/78085.html

文件一部分:

root:!:0:0::/:/usr/bin/ksh

解析:

用户登录名:登录口令:用户标识号:组标识号:用户主目录:命令解释程序

 

3、su

网站

http://zhidao.baidu.com/question/142357453.html

 

应用实例

su - beps -c "cd /cnaps2/src/beps/source

 

man su的例子:

Examples
       1    To obtain root user authority, enter:

            su

            This command runs a subshell with the effective user ID and privileges of the root user. You will be asked for the
            root password. Press End-of-File, Ctrl+D key sequence, to end the subshell and return to your original shell
            session and privileges.
       2    To obtain the privileges of the jim user, enter:

            su jim

            This command runs a subshell with the effective user ID and privileges of jim.
       3    To set up the environment as if you had logged in as the jim user, enter: su - jim

            This starts a subshell using jim's login environment.
       4    To run the backup command with root user authority and then return to your original shell, enter:

            su root "-c /usr/sbin/backup -9 -u"

            This runs the backup command with root user authority within root's default shell. You must give the correct root
            password when queried for the command to execute.


3、ls

http://blog.csdn.net/freedom2028/article/details/7104014


4、grep 命令的实用外加解说

4.1 搜索当前目录下带wxp这个三个字符(不区分大小写)的文本并标出其所在行号

grep -rin wxp *

4.2 在group 文件中搜索行尾带root的行,同时在group文件里面搜索行首为sys的行

说明:

'^':指匹配的字符串在行首,
'$':指匹配的字符串在行尾,

grep root$ group 

grep ^sys group



-r 递归遍历目录下的所有文件夹

-i 不区分大小写

-n 标出内容所在行号


结果如下:

mytest/wxp.txt:1:WXP
mytest/wxp.txt:2:wxp
x.txt:3:dddddddwxpi


4.3 grep -v '123'

-v 搜索不匹配的行


4.4 -c 统计行数

4.5 -e 可以搜索一个或者多个字符

模式:

grep -v -e "pattern" -e "pattern"

比如:

创建如下例子文件

$ cat test-file.txt
a
b
c
d

$ grep -v -e "a" -e "b" -e "c" test-file.txt
d


5. vi 命令介绍

5.1 跳到一行的末尾 $

5.2 跳到一行的开始 ^

5.3 跳到文件的末尾行shift+g(这个命令好像是跳到文件末尾行的开始)

5.4  跳到文件的开始行:0,然后回车 

5.5 删除光标所在行用dd


6 tar命令详解  出处:鸟哥的私房菜(3版本)

tar 命令参数详解

-c 新建打包文件

-t 查看打包文件的内容含有哪些文件名

-x 解打包或解压缩的功能

-v 在解压缩过程中,将正在处理的文件名显示出来

-f filename -f后面要接被处理的文件名 建议-f单独写一个参数

-C 压缩的时候指定要压缩的文件路径(前提是压缩文件的时候使用了绝对路径,而不是相对路径)


将wxp.tar压缩文件解压到指定目录(前提是压缩的时候使用了绝对路径,或者说tar包里面包含了你要解压的路径,这样才能解压到指定路径下面去)

tar -xvf wxp.tar -C /tmp

前提:wxp目录下的文件属主为ibps

wxp.tar 用户的属主为root

操作系统为aix


创建一个归档文件

G2DBT1:/wxp#tar -cv -f wxp.tar ./
a ./
a ./301.txt 20 blocks.
a ./sml 1 blocks.
a ./test
a ./test/301.txt 20 blocks.
a ./test/sml 1 blocks.
wxp.tar same as archive file, not archived




查看归档文件:

G2DBT1:/wxp#tar -tv -f wxp.tar
drwxr-xr-x 503 402       0 Apr 13 20:17:37 2013 ./
-rwxr-xr-x 503 402   10240 Apr 13 19:34:24 2013 ./301.txt
-rw-r--r-- 503 402      11 Apr 08 16:21:31 2013 ./sml
drwxr-xr-x 503 402       0 Apr 13 19:47:20 2013 ./test/
-rwxr-xr-x 503 402   10240 Apr 13 19:34:24 2013 ./test/301.txt
-rw-r--r-- 503 402      11 Apr 08 16:21:31 2013 ./test/sml


归档的时候会把文件的用户以及用户组也保存下来


解压开归档文件:

G2DBT1:/wxp/wxp_2#tar -xv -f ../wxp.tar 
x .
x ./301.txt, 10240 bytes, 20 media blocks.
x ./sml, 11 bytes, 1 media blocks.
x ./test
x ./test/301.txt, 10240 bytes, 20 media blocks.
x ./test/sml, 11 bytes, 1 media blocks.
G2DBT1:/wxp/wxp_2#ls
301.txt  sml      test


7 mount命令

 *    the node (if the mount is remote)
       *    the object mounted
       *    the mount point
       *    the virtual-file-system type
       *    the time mounted
       *    any mount options

8 文件结束符的快捷键

ctrl+d


9、ftp

1)、open 后跟IP就是连接到IP所在的机器上

2)、user 跟上用户名,按回车会提示输入密码,输入密码正确,连接主机成功

3)、pwd可以查看远程主机的当前目录

4)、cd 可以切换远程主机的目录

5)、lcd dir  将本地工作目录切换到dir下

6)、get  文件   传输一个文件

7)、mget 文件列表  传输多个文件

8)、bin  二进制传输文件

9)、prompt off  关闭交互  比如上传很多东西的时候,没有该条指令,那么就是传一个文件,就会提示一个输入Y,以进行下一个文件的传输

10)、close  与 open对应,中断与远程服务器连接

11 )bye 退出ftp会话过程


10、 svmon

http://www.eygle.com/digest/2009/07/ibm_aix_svmon.html


11、ldd与nm

ldd  Lists dynamic dependencies.

nm Displays information about symbols in object files, executable files, and object-file libraries.


12、ps

-T pid

Displays the process hierarchy rooted at a given pid in a tree format using ASCII art. This flag can be used in combination with the -f, -F, -o, and -l flags.

IBPS_compiler1:/#ps -T 7733438
      PID    TTY  TIME CMD
  7733438      -  0:00 cics
  5963870      -  0:00    |\--cicsrl
  6881404      -  0:00    |\--cicsic
  7274532      -  0:00    |\--cicslm
 10485830      -  0:00    |    \--cicsip
 10158188      -  0:07    |\--cicsam
  7929960      -  0:00    |   |\--cicsas
  9240676      -  0:07    |   |\--cicsas
  9306152      -  0:00    |   |\--cicsas
  9437246      -  0:00    |   |\--cicsas
  9502766      -  0:00    |   |\--cicsas
  9633846      -  0:00    |   |\--cicsas
  9764914      -  0:00    |   |\--cicsas
  9830478      -  0:00    |   |\--cicsas
  9895992      -  0:02    |   |\--cicsas
  9961530      -  0:01    |   |\--cicsas
 10027068      -  0:01    |   |\--cicsas
 10092772      -  0:00    |   |\--cicsas
 10354758      -  0:00    |   |\--cicsas
 10420292      -  0:00    |   |\--cicsas
 10551372      -  0:00    |   |\--cicsas
 10616912      -  0:00    |   |\--cicsas
 10682452      -  0:00    |   |\--cicsas
 12517588      -  0:00    |   |\--cicsas
 12845266      -  0:00    |   |\--cicsas
 12976376      -  0:00    |    \--cicsas
 12779586      -  0:00     \--cicsld


13 ln

作用:

当我们需要在不同的目录,用到相同的文件时,我们不需要在每一个需要的目录下都放一个必须相同的文件,我们只要在某个固定的目录,放上该文件,然后在其它的目录下用ln命令链接(link)它就可以,不必重复的占用磁盘空间

硬链接

只适用于同一个文件系统之下,且ln默认的操作(不加任何参数)为硬链接。特点:会在你选定的位置上生成一个和源文件大小相同的文件

软链接:

可以跨文件系统,ln -s 源文件 目标文件  特点:只会在你选定的位置上生成一个文件的镜像,不会占用磁盘空间

共同点:

无论是符号链接还是硬链接,文件都保持同步变化

不同点:

除了各自的特点外,硬链接结果是目标文件与源文件具有相同的i-node,而软链接的结果是目标文件与源文件具有不相同的i-node,如果删除源文件,符号链接的目标文件将不可用。


Sample:

81994 -rw-r--r--    2 cics     cics         171027 Jun 07 17:16 222
81994 -rw-r--r--    2 cics     cics         171027 Jun 07 17:16 IBPS_1
82011 lrwxrwxrwx    1 cics     cics              3 Jun 20 11:56 x -> 111

x将不可用

14 linux环境变量的设置(只在当前Session中有效)

14.1 新增环境变量

export wxp=123

14.2 增加环境变量

export wxp=$wxp:345

14.4 显示环境变量

env---显示所有环境变量

echo $wxp

14.5 清除环境变量

unset wxp

15 查看目录下文件大小的命令

输出目录下所有文件的大小,并按升序显示

du -H ./*/* | sort -n      



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值