- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
Shell支持自定义变量。定义变量定义变量时,变量名不加美元符号($),如:variableName="value"注意,变量名和等号之间不能有空格,这可能和你熟悉的所有编程语言都不一样。同时,变量名的命名须遵循如下规则:首个字符必须为字母(a-z,A-Z)。中间不能有空格,可以使用下划线(_)。不能使用标点符号。不能使用bash里的关键字(可用help命令查看保留关键字)。变量定义举例:myUrl="http://see.xidian.edu.cn/cpp/linux/"myNum=100使用变量使用一个定义过的变量,只要在变量名前面加美元符号($)即可,如:your_name="mozhiyan"echo $your_nameecho ${your_name}变量名外面的花括号是可选的,加不加都行,加花括号是为了帮助解释器识别变量的边界,比如下面这种情况:for skill in Ada Coffe Action Javadoecho "I am good at ${skill}Script"done如果不给skill变量加花括号,写成echo "I am good at $skillScript",解释器就会把$skillScript当成一个变量(其值为空),代码执行结果就不是我们期望的样子了。推荐给所有变量加上花括号,这是个好的编程习惯。重新定义变量已定义的变量,可以被重新定义,如:myUrl="http://see.xidian.edu.cn/cpp/linux/"echo ${myUrl}myUrl="http://see.xidian.edu.cn/cpp/shell/"echo ${myUrl}这样写是合法的,但注意,第二次赋值的时候不能写 $myUrl="http://see.xidian.edu.cn/cpp/shell/",使用变量的时候才加美元符($)。只读变量使用 readonly 命令可以将变量定义为只读变量,只读变量的值不能被改变。下面的例子尝试更改只读变量,结果报错:#!/bin/bashmyUrl="http://see.xidian.edu.cn/cpp/shell/"readonly myUrlmyUrl="http://see.xidian.edu.cn/cpp/danpianji/"运行脚本,结?如下:/bin/sh: NAME: This variable is read only.删除变量使用 unset 命令可以删除变量。语法:unset variable_name变量被删除后不能再次使用;unset 命令不能删除只读变量。举个例子:#!/bin/shmyUrl="http://see.xidian.edu.cn/cpp/u/xitong/"unset myUrlecho $myUrl上面的脚本没有任何输出。变量类型运行shell时,会同时存在三种变量:1) 局部变量局部变量在脚本或命令中定义,仅在当前shell实例中有效,其他shell启动的程序不能访问局部变量。2) 环境变量所有的程序,包括shell启动的程序,都能访问环境变量,有些程序需要环境变量来保证其正常运行。必要的时候shell脚本也可以定义环境变量。3) shell变量shell变量是由shell程序设置的特殊变量。shell变量中有一部分是环境变量,有一部分是局部变量,这些变量保证了shell的正常运行
先用who命令查看所有登陆终端 #who -uH 输出如下:NAME LINE TIME IDLE PID COMMENTroot :0 2010-03-01 19:13 ? 2436root pts/0 2010-03-01 19:13 06:44 2851 (:0)root pts/1 2010-03-02 00:52 00:03 29584 (:0)root pts/2 2010-03-02 01:26 00:19 23321 (:0)root pts/3 2010-03-02 01:42 . 26511 (192.168.79.1)然后给最后一个用户发送消息:#write root pts/3输出错误如下:write: you have write permission turned off解决方案输入命令:#mesg y 然后重新输入:#write root pts/3就可以发消息了。
Linux zipinfo命令用于列出压缩文件信息。执行zipinfo指令可得知zip压缩文件的详细信息。语法zipinfo [-12hlmMstTvz][压缩文件][文件...][-x <范本样式>]参数:-1 只列出文件名称。-2 此参数的效果和指定"-1"参数类似,但可搭配"-h","-t"和"-z"参数使用。-h 只列出压缩文件的文件名称。-l 此参数的效果和指定"-m"参数类似,但会列出原始文件的大小而非每个文件的压缩率。-m 此参数的效果和指定"-s"参数类似,但多会列出每个文件的压缩率。-M 若信息内容超过一个画面,则采用类似more指令的方式列出信息。-s 用类似执行"ls -l"指令的效果列出压缩文件内容。-t 只列出压缩文件内所包含的文件数目,压缩前后的文件大小及压缩率。-T 将压缩文件内每个文件的日期时间用年,月,日,时,分,秒的?序列出。-v 详细显示压缩文件内每一个文件的信息。-x<范本样式> 不列出符合条件的文件的信息。-z 如果压缩文件内含有注释,就将注释显示出来。实例显示压缩文件信息[root@w3cschool.cc a]# zipinfo cp.zip Archive: cp.zip 486 bytes 4 files-rw-r--r-- 2.3 unx 0 bx stor 24-May-10 18:54 a.c-rw-r--r-- 2.3 unx 0 bx stor 24-May-10 18:54 b.c-rw-r--r-- 2.3 unx 0 bx stor 24-May-10 18:54 c.c-rw-r--r-- 2.3 unx 0 bx stor 24-May-10 18:54 e.c4 files, 0 bytes uncompressed, 0 bytes compressed: 0.0%[root@w3cschool.cc a]#显示压缩文件中每个文件的信息[root@w3cschool.cc a]# zipinfo -v cp.zip Archive: cp.zip 486 bytes 4 filesEnd-of-central-directory record:------------------------------- Actual offset of end-of-central-dir record: 464 (000001D0h) Expected offset of end-of-central-dir record: 464 (000001D0h) (based on the length of the central directory and its expected offset) This zipfile constitutes the sole disk of a single-part archive; its central directory contains 4 entries. The central directory is 248 (000000F8h) bytes long, and its (expected) offset in bytes from the beginning of the zipfile is 216 (000000D8h). There is no zipfile comment.Central directory entry #1:--------------------------- a.c offset of local header from start of archive: 0 (00000000h) bytes file system or operating system of origin: Unix version of encoding software: 2.3 minimum file system compatibility required: MS-DOS, OS/2 or NT FAT minimum software version required to extract: 1.0 compression method: none (stored) file security status: not encrypted extended local header: no file last modified on (DOS date/time): 2010 May 24 18:54:26 file last modified on (UT extra field modtime): 2010 May 24 18:54:26 local file last modified on (UT extra field modtime): 2010 May 24 10:54:26 UTC 32-bit CRC value (hex): 00000000 compressed size: 0 bytes uncompressed size: 0 bytes length of filename: 3 characters length of extra field: 13 bytes length of file comment: 0 characters disk number on which file begins: disk 1 apparent file type: binary Unix file attributes (100644 octal): -rw-r--r-- MS-DOS file attributes (00 hex): none The central-directory extra field contains: - A subfield with ID 0x5455 (universal time) and 5 data bytes. The local extra field has UTC/GMT modification/access times. - A subfield with ID 0x7855 (Unix UID/GID) and 0 data bytes. There is no file comment.Central directory entry #2:--------------------------- b.c offset of local header from start of archive: 54 (00000036h) bytes file system or operating system of origin: Unix version of encoding software: 2.3 minimum file system compatibility required: MS-DOS, OS/2 or NT FAT minimum software version required to extract: 1.0 compression method: none (stored) file security status: not encrypted extended local header: no file last modified on (DOS date/time): 2010 May 24 18:54:26 file last modified on (UT extra field modtime): 2010 May 24 18:54:26 local file last modified on (UT extra field modtime): 2010 May 24 10:54:26 UTC 32-bit CRC value (hex): 00000000 compressed size: 0 bytes uncompressed size: 0 bytes length of filename: 3 characters length of extra field: 13 bytes length of file comment: 0 characters disk number on which file begins: disk 1 apparent file type: binary Unix file attributes (100644 octal): -rw-r--r-- MS-DOS file attributes (00 hex): none The central-directory extra field contains: - A subfield with ID 0x5455 (universal time) and 5 data bytes. The local extra field has UTC/GMT modification/access times. - A subfield with ID 0x7855 (Unix UID/GID) and 0 data bytes. There is no file comment.Central directory entry #3:--------------------------- c.c offset of local header from start of archive: 108 (0000006Ch) bytes file system or operating system of origin: Unix version of encoding software: 2.3 minimum file system compatibility required: MS-DOS, OS/2 or NT FAT minimum software version required to extract: 1.0 compression method: none (stored) file security status: not encrypted extended local header: no file last modified on (DOS date/time): 2010 May 24 18:54:26 file last modified on (UT extra field modtime): 2010 May 24 18:54:26 local file last modified on (UT extra field modtime): 2010 May 24 10:54:26 UTC 32-bit CRC value (hex): 00000000 compressed size: 0 bytes uncompressed size: 0 bytes length of filename: 3 characters length of extra field: 13 bytes length of file comment: 0 characters disk number on which file begins: disk 1 apparent file type: binary Unix file attributes (100644 octal): -rw-r--r-- MS-DOS file attributes (00 hex): none The central-directory extra field contains: - A subfield with ID 0x5455 (universal time) and 5 data bytes. The local extra field has UTC/GMT modification/access times. - A subfield with ID 0x7855 (Unix UID/GID) and 0 data bytes. There is no file comment.Central directory entry #4:--------------------------- e.c offset of local header from start of archive: 162 (000000A2h) bytes file system or operating system of origin: Unix version of encoding software: 2.3 minimum file system compatibility required: MS-DOS, OS/2 or NT FAT minimum software version required to extract: 1.0 compression method: none (stored) file security status: not encrypted extended local header: no file last modified on (DOS date/time): 2010 May 24 18:54:26 file last modified on (UT extra field modtime): 2010 May 24 18:54:26 local file last modified on (UT extra field modtime): 2010 May 24 10:54:26 UTC 32-bit CRC value (hex): 00000000 compressed size: 0 bytes uncompressed size: 0 bytes length of filename: 3 characters length of extra field: 13 bytes length of file comment: 0 characters disk number on which file begins: disk 1 apparent file type: binary Unix file attributes (100644 octal): -rw-r--r-- MS-DOS file attributes (00 hex): none The central-directory extra field contains: - A subfield with ID 0x5455 (universal time) and 5 data bytes. The local extra field has UTC/GMT modification/access times. - A subfield with ID 0x7855 (Unix UID/GID) and 0 data bytes. There is no file comment.
Linux gzip命令用于压缩文件。gzip是个使用广泛的压缩程序,文件经它压缩过后,其名称后面会多出".gz"的扩展名。语法gzip [-acdfhlLnNqrtvV][-S <压缩字尾字符串>][-<压缩效率>][--best/fast][文件...] ? gzip [-acdfhlLnNqrtvV][-S <压缩字尾字符串>][-<压缩效率>][--best/fast][目录]参数:-a或--ascii 使用ASCII文字模式。-c或--stdout或--to-stdout 把压缩后的文件输出到标准输出设备,不去更动原始文件。-d或--decompress或----uncompress 解开压缩文件。-f或--force 强行压缩文件。不理会文件名称或硬连接是否存在以及该文件是否为符号连接。-h或--help 在线帮助。-l或--list 列出压缩文件的相关信息。-L或--license 显示版本与版权信息。-n或--no-name 压缩文件时,不保存原来的文件名称及时间戳记。-N或--name 压缩文件时,保存原来的文件名称及时间戳记。-q或--quiet 不显示警告信息。-r或--recursive 递归处理,将指定目录下的所有文件及子目录一并处理。-S<压缩字尾字符串>或----suffix<压缩字尾字符串> 更改压缩字尾字符串。-t或--test 测试压缩文件是否正确无误。-v或--verbose 显示指令执行过程。-V或--version 显示版本信息。-<压缩效率> 压缩效率是一个介于1-9的数值,预设值为"6",指定愈大的数值,压缩效率就会愈高。--best 此参数的效果和指定"-9"参数相同。--fast 此参数的效果和指定"-1"参数相同。实例压缩文件[root@w3cschool.cc a]# ls //显示当前目录文件a.c b.h d.cpp[root@w3cschool.cc a]# gzip * //压缩目录下的所有文?[root@w3cschool.cc a]# ls //显示当前目录文件a.c.gz b.h.gz d.cpp.gz[root@w3cschool.cc a]#接范例1, 列出详细的信息[root@w3cschool.cc a]# gzip -dv * //解压文件,并列出详细信息a.c.gz: 0.0% -- replaced with a.c b.h.gz: 0.0% -- replaced with b.h d.cpp.gz: 0.0% -- replaced with d.cpp[root@w3cschool.cc a]#接范例1,显示压缩文件的信息[root@w3cschool.cc a]# gzip -l * compressed uncompressed ratio uncompressed_name 24 0 0.0% a.c 24 0 0.0% b.h 26 0 0.0% d.cpp
Linux bzip2命令是.bz2文件的压缩程序。bzip2采用新的压缩演算法,压缩效果比传统的LZ77/LZ78压缩演算法来得好。若没有加上任何参数,bzip2压缩完文件后会产生.bz2的压缩文件,并删除原始的文件。语法bzip2 [-cdfhkLstvVz][--repetitive-best][--repetitive-fast][- 压缩等级][要压缩的文件]参数:-c或--stdout 将压缩与解压缩的结果送到标准输出。-d?--decompress 执行解压缩。-f或--force bzip2在压缩或解压缩时,若输出文件与现有文件同名,预设不会覆盖现有文件。若要覆盖,请使用此参数。-h或--help 显示帮助。-k或--keep bzip2在压缩或解压缩后,会删除原始的文件。若要保留原始文件,请使用此参数。-s或--small 降低程序执行时内存的使用量。-t或--test 测试.bz2压缩文件的完整性。-v或--verbose 压缩或解压缩文件时,显示详细的信息。-z或--compress 强制执行压缩。-L,--license,-V或--version 显示版本信息。--repetitive-best 若文件中有重复出现的资料时,可利用此参数提高压缩效果。--repetitive-fast 若文件中有重复出现的资料时,可利用此参数加快执行速度。-压缩等级 压缩时的区块大小。实例解压.bz2文件[root@w3cschool.cc ~]# bzip2 -v temp.bz2 //解压文件显示详细处理信息压缩文件[root@w3cschool.cc ~]# bzip2 -c a.c b.c c.c检查文件完整性[root@w3cschool.cc ~]# bzip2 -t temp.bz2
pstree命令以树状图显示进程间的关系(display a tree of processes)。ps命令可以显示当前正在运行的那些进程的信息,但是对于它们之间的关系却显示得不够清晰。在Linux系统中,系统调用fork可以创建子进程,通过子shell也可以创建子进程,Linux系统中进程之间的关系天生就是一棵树,树的根就是进程PID为1的init进程。常用参数格式:pstree以树状图显示进程,只显示进程的名字,且相同进程合并显示。格式:pstree -p以树状图显示进程,还显示进程PID。格式:pstree <pid>格式:pstree -p <pid>以树状图显示进程PID为<pid>的进程以及子孙进程,如果有-p参数则同时显示每个进程的PID。格式:pstree -a以树状图显示进程,相同名称的进程不合并显示,并且会显示命令行参数,如果有-p参数则同时显示每个进程的PID。因为pstree输出的信息可能比较多,所以最好与more/less配合使用。 相关资?【1】Linux Operating System How to use pstree an alternative to ps 【2】THE GEEK STUFF tree and pstree: Visualize Unix Processes and Directories in Hierarchical Structure 【3】Linux basic configurations Introduction to Linux process and daemons 【4】LINFO The pstree Command
注意使用logtamper,只能清除日志痕迹,而且主要针对utmp,wtmp,lastlog。而事实上,linux系统重要的会留下你的痕迹日志有:lastlog、utmp、wtmp、messages、syslog、sulog,所以不能完全依赖工具。此外,各种shell还会记录用户使用的命令历史,它使用用户主目录下的文件来记录这些命令历史,通常这个文件的名字为.sh_history (ksh),.history (csh),或.bash_history (bash)等。对于.bash_history(bash),可以简单的使用 histroy -c来清除记录。logtamper version1.1logtamper是一款*修改*linux日志的工具,在修改日志文件的同时,能够保留被修改文件的时间信息(atime没改,觉得没必要)。[root@localhost logtamper]# ./logtamper-static Logtamper v 1.1 for linux Copyright (C) 2008 by xi4oyu logtamper [-f utmp_filename] -h username hostname hide username connected from hostname logtamper [-f wtmp_filename] -w username hostname erase username from hostname in wtmp file logtamper [-f lastlog_filename] -m username hostname ttyname YYYY[:MM[:DD[:hh[:mm[:ss]]]]] modify lastlog info-f 选项:用于指定要修改的文件的路径的,是个可选项。由于不同系统的日志存放路径不一样,可以手工指定。默认的日志存放地点是: #define UTMPFILE “/var/run/utmp” #define WTMPFILE “/var/log/wtmp” #define LASTLOGFILE “/var/log/lastlog”-h 选项: 有时候你和管理员同时在线,管理员w一下就能看到你了。使用-h选项用户躲避管理员w查看,如下:[root@localhost logtamper]# w 21:27:25 up 5 days, 13:48, 4 users, load average: 0.00, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty1 – Fri14 18:24m 0.33s 0.33s -bash root pts/3 192.168.80.1 21:21 6:22 0.04s 0.04s -bash root pts/2 192.168.80.1 21:06 0.00s 0.13s 0.00s w root pts/4 192.168.80.1 21:21 5:52 0.03s 0.03s -bash我们是从192.168.80.1机器连上来的,现在隐藏下:[root@localhost logtamper]# ./logtamper-static -h root 192.168.80.1 Logtamper v 1.1 for linux Copyright (C) 2008 by xi4oyu Seems you’re invisible Now…Check it out! [root@localhost logtamper]# w 21:27:46 up 5 days, 13:48, 1 user, load average: 0.00, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty1 – Fri14 18:24m 0.33s 0.33s -bash [root@localhost logtamper]#-w 选项:用于清除你的登录日志,现在上的linux日志除工具做的很粗燥啊,这个可以指定清除某些hostname过来的机器。[root@localhost logtamper]# last root tty1 Wed Oct 1 21:30 – 21:30 (00:00) root pts/4 192.168.80.1 Wed Oct 1 21:21 still logged in root pts/3 192.168.80.1 Wed Oct 1 21:21 still logged in wtmp begins Wed Oct 1 06:01:46 2008 清除192.168.80.1的登录日志: [root@localhost logtamper]# ./logtamper-static -w root 192.168.80.1 Logtamper v 1.1 for linux Copyright (C) 2008 by xi4oyu Aho,you are now invisible to last…Check it out! [root@localhost logtamper]# last root tty1 Wed Oct 1 21:30 – 21:30 (00:00) wtmp begins Wed Oct 1 06:01:46 2008 [root@localhost logtamper]#-m 选项:用于修改上次登录地点,我们使用ssh登录的时候可能会注意到这点 login as: root Sent username “root” root@192.168.80.128’s password: Last login: Wed Oct 1 21:31:40 2008 from 192.168.80.45 [root@localhost ~]#如果不修改lastlog的话,管理员下次登录就会提示从我们的机器IP登录。使用-m选项可以编辑这个选项: [root@localhost logtamper]# ./logtamper-static -m root 1.2.3.4 tty10 2008:1:1:1:1:1 Logtamper v 1.1 for linux Copyright (C) 2008 by xi4oyu Aho, now you never come here before…Check it out! [root@localhost logtamper]#当然,这只是个举例,在使用中各位请根据具体信息修改,下次管理员登录,登录界面就成了login as: root Sent username “root” root@192.168.80.128’s password: Last login: Tue Jan 1 01:01:01 2008 from 1.2.3.4 [root@localhost ~]#
常规篇: 首先,用ps查看进程,方法如下:$ ps -ef……smx 1822 1 0 11:38 ? 00:00:49 gnome-terminalsmx 1823 1822 0 11:38 ? 00:00:00 gnome-pty-helpersmx 1824 1822 0 11:38 pts/0 00:00:02 bashsmx 1827 1 4 11:38 ? 00:26:28 /usr/lib/firefox-3.6.18/firefox-binsmx 1857 1822 0 11:38 pts/1 00:00:00 bashsmx 1880 1619 0 11:38 ? 00:00:00 update-notifier……smx 11946 1824 0 21:41 pts/0 00:00:00 ps -ef或者:$ ps -aux……smx 1822 0.1 0.8 58484 18152 ? Sl 11:38 0:49 gnome-terminalsmx 1823 0.0 0.0 1988 712 ? S 11:38 0:00 gnome-pty-helpersmx 1824 0.0 0.1 6820 3776 pts/0 Ss 11:38 0:02 bashsmx 1827 4.3 5.8 398196 119568 ? Sl 11:38 26:13 /usr/lib/firefox-3.6.18/firefox-binsmx 1857 0.0 0.1 6688 3644 pts/1 Ss 11:38 0:00 bashsmx 1880 0.0 0.6 41536 12620 ? S 11:38 0:00 update-notifier……smx 11953 0.0 0.0 2716 1064 pts/0 R+ 21:42 0:00 ps -aux此时如果我想杀了火狐的进程就在终端输入:$ kill -s 9 1827其中-s 9 制定了传递给进程的信号是9,即强制、尽快终止进程。各个终止信号及其作用见附录。1827则是上面ps查到的火狐的PID。简单吧,但有个问题,进程少了则无所谓,进程多了,就会觉得痛苦了,无论是ps -ef 还是ps -aux,每次都要在一大串进程信息里面查找到要杀的进程,看的眼都花了。进阶篇:改进1:把ps的查询结果通过管道给grep查找包含特定字符串的进程。管道符“|”用来隔开两个命令,管道符左边命令的输出会作为管道符右边命令的输入。$ ps -ef | grep firefoxsmx 1827 1 4 11:38 ? 00:27:33 /usr/lib/firefox-3.6.18/firefox-binsmx 12029 1824 0 21:54 pts/0 00:00:00 grep --color=auto firefox这次就清爽了。然后就是$kill -s 9 1827还是嫌打字多?改进2——使用pgrep:一看到pgrep首先会想到什么?没错,grep!pgrep的p表明了这个命令是专门用于进程查询的grep。$ pgrep firefox1827看到了什么?没错火狐的PID,接下来又要打字了:$kill -s 9 1827改进3——使用pidof:看到pidof想到啥?没错pid of xx,字面翻译过来就是 xx的PID。$ pidof firefox-bin1827和pgrep相比稍显不足的是,pidof必须给出进程的全名。然后就是老生常谈:$kill -s 9 1827无论使用ps 然后慢慢查找进程PID 还是用grep查找包含相应字符串的进程,亦或者用pgrep直接查找包含相应字符串的进程PID,然后手动输入给kill杀掉,都稍显麻烦。有没有更方便的方法?有!改进4:$ps -ef | grep firefox | grep -v grep | cut -c 9-15 | xargs kill -s 9说明:“grep firefox”的输出结果是,所有含有关键字“firefox”的进程。“grep -v grep”是在列出的进程中去除含有关键字“grep”的进程。“cut -c 9-15”是截取输入行的第9个字符到第15个字符,而这正好是进程号PID。“xargs kill -s 9”中的xargs命令是用来把前面命令的输出结果(PID)作为“kill -s 9”命令的参数,并执行该命令。“kill -s 9”会强行杀掉指定进程。难道你不想抱怨点什么?没错太长了改进5:知道pgrep和pidof两个命令,干嘛还要打那么长一串!$ pgrep firefox | xargs kill -s 9改进6:$ ps -ef | grep firefox | awk '{print $2}' | xargs kill -9kill: No such process有一个比较郁闷的地方,进程已经正确找到并且终止了,但是执行完却提示找不到进程。其中awk '{print $2}' 的作用就是打印(print)出第二列的内容。根据常规篇,可以知道ps输出的第二列正好是PID。就把进程相应的PID通过xargs传递给kill作参数,杀掉对应的进程。改进7:难道每次都要调用xargs把PID传递给kill?答案是否定的:$kill -s 9 `ps -aux | grep firefox | awk '{print $2}'`改进8:没错,命令依?有点长,换成pgrep。$kill -s 9 `pgrep firefox`改进9——pkill:看到pkill想到了什么?没错pgrep和kill!pkill=pgrep+kill。$pkill -9 firefox说明:"-9" 即发送的信号是9,pkill与kill在这点的差别是:pkill无须 “s”,终止信号等级直接跟在 “-“ 后面。之前我一直以为是 "-s 9",结果每次运行都无法终止进程。改进10——killall:killall和pkill是相似的,不过如果给出的进程名不完整,killall会报错。pkill或者pgrep只要给出进程名的一部分就可以终止进程。$killall -9 firefox附录:各种信号及其用途SignalDescriptionSignal number on Linux x86[1]SIGABRTProcess aborted6SIGALRMSignal raised by alarm14SIGBUSBus error: "access to undefined portion of memory object"7SIGCHLDChild process terminated, stopped (or continued*)17SIGCONTContinue if stopped18SIGFPEFloating point exception: "erroneous arithmetic operation"8SIGHUPHangup1SIGILLIllegal instruction4SIGINTInterrupt2SIGKILLKill (terminate immediately)9SIGPIPEWrite to pipe with no one reading13SIGQUITQuit and dump core3SIGSEGVSegmentation violation11SIGSTOPStop executing temporarily19SIGTERMTermination (request to terminate)15SIGTSTPTerminal stop signal20SIGTTINBackground process attempting to read from tty ("in")21SIGTTOUBackground process attempting to write to tty ("out")22SIGUSR1User-defined 110SIGUSR2User-defined 212SIGPOLLPollable event29SIGPROFProfiling timer expired27SIGSYSBad syscall31SIGTRAPTrace/breakpoint trap5SIGURGUrgent data available on socket23SIGVTALRMSignal raised by timer counting virtual time: "virtual timer expired"26SIGXCPUCPU time limit exceeded24SIGXFSZFile size limit exceeded25
安装了CentOS7,选择了最小安装包模式,安装完毕之后想查看一下本机的ip地址,发现报错# ifconfig-bash: ifconfig: command not found谷歌了一下,整理了一下解决思路 查看ifconfig命令是否存在 查看 /sbin/ifconfig是否存在 如果ifconfig命令存在,查看环境变量设置 #echo $PATH 如果环境变量中没有包含ifconfig命令的路径 临时修改环境变量:在shell中输入 $export PATH = $PATH:/sbin 然后再输入ifconfig命令即可,但是这只是临时更改了shell中的PATH,如果关闭shell,则修改消失,下次还需要重复如上操作 永久修改PATH变量使之包含/sbin路径: 打开/etc/profile文件,在其中输入export PATH=$PATH:/sbin,保存并重启即可,这样一来,PATH路径永久修改成功,以后任何时候只输入ifconfig命令即可 3. 如果ifconfig命令不存在yum upgradeyum install net-tools
出现这个错误是在我们启动网卡时候报错#ifup eth0问题原因:配置文件里的MAC地址和实的MAC不一样。 含有MAC信息的配置文件是/etc/sysconfig/network-scripts/ifcfg-eth0。 查看本机实际MAC的命令是 ifconfig eth0解决办法:1.查看配置文件/etc/sysconfig/network-scripts/ifcfg-eth0 中的HWADDR 参数是什么2. 用命令ifconfig etho, 看看实际的MAC地址是什么
Linux swatch命令用于系统监控程序。swatch可用来监控系统记录文件,并在发现特定的事件时,执行指定的动作。swatch所监控的事件以及对应事件的动作都存放在swatch的配置文件中。预设的配置文件为拥护根目录下的.swatchrc。然而在Red Hat Linux的预设用户根目录下并没有.swatchrc配置文件,您可将/usr/doc/swatch-2.2/config_files/swatchrc.personal文件复制到用户根?录下的.swatchrc,然后修改.swatchrc所要监控的事件及执行的动作。语法1swatch [-A <分隔字符>][-c <设置文件>][-f <记录文件>][-I <分隔字符>][-P <分隔字符>][-r <时间>][-t <记录文件>]参数说明:-A<分隔字符> 预设配置文件中,动作的分隔字符,预设为逗号。-c<设置文件> 指定配置文件,而不使用预设的配置文件。-f<记录文件> 检查指定的记录文件,检查完毕后不会继续监控该记录文件。-I<分隔字符> 指定输入记录的分隔字符,预设为换行字符。-P<分隔字符> 指定配置文件中,事件的分隔字符,预设为逗号。-r<时间> 在指定的时间重新启动。-t<记录文件> 检查指定的记录文件,并且会监控加入记录文件中的后继记录。
执行这项指令可得知目前有那些用户登入系统,单独执行who指令会列出登入帐号,使用的终端机,登入时间以及从何处登入或正在使用哪个X显示器linux who 命令 详解 Linux最常用命令之一 功能说明:显示目前登入系统的用户信息。 语 法:who [-Himqsw][--help][--version][am i][记录文件] 补充说明:执行这项指令可得知目前有那些用户登入系统,单独执行who指令会列出登入帐号,使用的 终端机,登入时间以及从何处登入或正在使用哪个X显示器。 参 数? -H或--heading 显示各栏位的标题信息列。 -i或-u或--idle 显示闲置时间,若该用户在前一分钟之内有进行任何动作,将标示成"."号,如果该用户已超过24小时没有任何动作,则标示出"old"字符串。 -m 此参数的效果和指定"am i"字符串相同。 -q或--count 只显示登入系统的帐号名称和总人数。www.jb51.com linux安全网 扩展,使用who或者w命令查看到非法用户正在登陆系统,想踢掉怎么办 who命令示例 要显示关于谁正在使用本地系统节点的信息,请输入: who 显示类似于以下内容的信息: joe lft/0 Jun 8 08:34 要显示您的用户名,请输入: who am i 显示类似于以下内容的信息: george lft/0 Jun 8 08:34 要显示登录、注销、系统启动和系统关闭的历史记录,请输入: who /var/adm/wtmp 显示类似于以下内容的信息: hank lft/0 Jun 8 08:34 (ausnix5) john lft/0 Jun 8 08:34 (JIKey) mary lft/0 Jun 8 08:22 (machine.austin.ibm) jan pts4 Jun 8 09:19 (puff.wisc.edu) 要显示本地系统节点的运行级别,请输入: who -r 显示类似于以下内容的信息: . run-level 2 Jun 8 04:15 2 0 s 要显示任何当前活动的和以前已由 init 生成的活动进程,请输入: who -p 显示类似于以下内容的信息 srcmstr . Jun 8 04:15 old 2896 cron . Jun 8 04:15 old 4809 uprintfd . Jun 8 04:15 old 5158 要通过指定 -bdlprtTu 标志来处理 /var/adm/wtmp 文件,请输入: who -a /var/adm/wtmp 显示类似于以下内容的信息: . system boot Jun 19 10:13 . run-level 2 Jun 19 10:13 . . Jun 19 10:14 old . . Jun 19 10:14 old . . Jun 19 10:14 old rc - . Jun 19 10:13 old . . Jun 19 10:16 old . . Jun 19 10:14 old srcmstr - . Jun 19 10:14 old rctcpip - . Jun 19 10:14 old rcdce - . Jun 19 10:14 old rccm - . Jun 19 10:15 old dceupdt - . Jun 19 10:15 old rcnfs - . Jun 19 10:15 old cron - . Jun 19 10:16 old piobe - . Jun 19 10:16 old qdaemon - . Jun 19 10:16 old writesrv - . Jun 19 10:16 old uprintfd - . Jun 19 10:16 old . . Jun 19 10:16 old LOGIN - lft0 Jun 19 10:16 old . . Jun 19 10:16 old . . Jun 19 10:16 old
TOP命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况。TOP是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占前台,直到用户终止该程序为止.比较准确的说,top命令提供了实时的对系统处理器的状态监视.它将显示系统中CPU最“敏感”的任务列表.该命令可以按CPU使用.内存使用和执行时间对任务进行排序;而且该命令的很多特性都可以通过交互式命令或者在个人定制文件中进行设定.top - 12:38:33 up 50 days, 23:15, 7 users, load average: 60.58, 61.14, 61.22Tasks: 203 total, 60 running, 139 sleeping, 4 stopped, 0 zombieCpu(s) : 27.0%us, 73.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%stMem: 1939780k total, 1375280k used, 564500k free, 109680k buffersSwap: 4401800k total, 497456k used, 3904344k free, 848712k cachedPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 4338 oracle 25 0 627m 209m 207m R 0 11.0 297:14.76 oracle 4267 oracle 25 0 626m 144m 143m R 6 7.6 89:16.62 oracle 3458 oracle 25 0 672m 133m 124m R 0 7.1 1283:08 oracle 3478 oracle 25 0 672m 124m 115m R 0 6.6 1272:30 oracle 3395 oracle 25 0 672m 122m 113m R 0 6.5 1270:03 oracle 3480 oracle 25 0 672m 122m 109m R 8 6.4 1274:13 oracle 3399 oracle 25 0 672m 121m 110m R 0 6.4 1279:37 oracle 4261 oracle 25 0 634m 100m 99m R 0 5.3 86:13.90 oracle 25737 oracle 25 0 632m 81m 74m R 0 4.3 272:35.42 oracle 7072 oracle 25 0 626m 72m 71m R 0 3.8 6:35.68 oracle 16073 oracle 25 0 630m 68m 63m R 8 3.6 175:20.36 oracle 16140 oracle 25 0 630m 66m 60m R 0 3.5 175:13.42 oracle 16122 oracle 25 0 630m 66m 60m R 0 3.5 176:47.73 oracle 786 oracle 25 0 627m 63m 63m R 0 3.4 1:54.93 oracle 4271 oracle 25 0 627m 59m 58m R 8 3.1 86:09.64 oracle 4273 oracle 25 0 627m 57m 56m R 8 3.0 84:38.20 oracle 22670 oracle 25 0 626m 50m 49m R 0 2.7 84:55.82 oracle 一. TOP前五行统计信息统计信息区前五行是?统整体的统计信息。1. 第一行是任务队列信息同 uptime 命令的执行结果:[root@localhost ~]# uptime 13:22:30 up 8 min, 4 users, load average: 0.14, 0.38, 0.25其内容如下:12:38:33当前时间up 50days系统运行时间,格式为时:分1 user当前登录用户数load average: 0.06, 0.60, 0.48系统负载,即任务队列的平均长度。 三个数值分别为 1分钟、5分钟、15分钟前到现在的平均值。2. 第二、三行为进程和CPU的信息当有多个CPU时,这些内容可能会超过两行。内容如下:Tasks: 29 total进程总数1 running正在运行的进程数28 sleeping睡眠的进程数0 stopped停止的进程数0 zombie僵尸进程数Cpu(s): 0.3% us用户空间占用CPU百分比1.0% sy内核空间占用CPU百分比0.0% ni用户进程空间内改变过优先级的进程占用CPU百分比98.7% id空闲CPU百分比0.0% wa等待输入输出的CPU时间百分比0.0% hi0.0% si3. 第四五行为内存信息。内容如下:Mem: 191272k total物理内存总量173656k used使用的物理内存总量17616k free空闲内存总量22052k buffers用作内核缓存的内存量Swap: 192772k total交换区总量0k used使用的交换区总量192772k free空闲交换区总量123988k cached缓冲的交换区总量。 内存中的内容被换出到交换区,而后又被换入到内存,但使用过的交换区尚未被覆盖, 该数值即为这些内容已存在于内存中的交换区的大小。相应的内存再次被换出时可不必再对交换区写入。二. 进程信息列名含义PID进程idPPID父进程idRUSERReal user nameUID进程所有者的用户idUSER进程所有者的用户名GROUP进程所有者的组名TTY?动进程的终端名。不是从终端启动的进程则显示为 ?PR优先级NInice值。负值表示高优先级,正值表示低优先级P最后使用的CPU,仅在多CPU环境下有意义%CPU上次更新到现在的CPU时间占用百分比TIME进程使用的CPU时间总计,单位秒TIME+进程使用的CPU时间总计,单位1/100秒%MEM进程使用的物理内存百分比VIRT进程使用的虚拟内存总量,单位kb。VIRT=SWAP+RESSWAP进程使用的虚拟内存中,被换出的大小,单位kb。RES进程使用的、未被换出的物理内存大小,单位kb。RES=CODE+DATACODE可执行代码占用的物理内存大小,单位kbDATA可执行代码以外的部分(数据段+栈)占用的物理内存大小,单位kbSHR共享内存大小,单位kbnFLT页面错误次数nDRT最后一次写入到现在,被修改过的页面数。S进程状态。 D=不可中断的睡眠状态 R=运行 S=睡眠 T=跟踪/停止 Z=僵尸进程COMMAND命令名/命令行WCHAN若该进程在睡眠,则显示睡眠中的系统函数名Flags任务标志,参考 sched.htop 的man 命令解释如下: Listed below are top's available fields. They are always associated with the letter shown, regardless of the position you may have established for them with the 'o' (Order fields) interactive command.Any field is selectable as the sort field, and you control whether they are sorted high-to-low or low-to-high. For additional information on sort provisions see topic 3c. TASK Area Commands.a: PID -- Process Id The task's unique process ID, which periodically wraps, though never restarting at zero.b: PPID -- Parent Process Pid The process ID of a task's parent.c: RUSER -- Real User Name The real user name of the task's owner.d: UID -- User Id The effective user ID of the task's owner.e: USER -- User Name The effective user name of the task's owner.f: GROUP -- Group Name The effective group name of the task's owner.g: TTY -- Controlling Tty The name of the controlling terminal. This is usually the device (serial port, pty, etc.) from which the process was started, and which it uses for input oroutput. However, a task need not be associated with a terminal, in which case you'll see '?' displayed.h: PR -- Priority The priority of the task.i: NI -- Nice value The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task's dispatchability.j: P -- Last used CPU (SMP) A number representing the last used processor. In a true SMP environment this will likely change frequently since the kernel intentionally uses weak affinity. Also, the very act of running top may break this weak affinity and cause more processes to change CPUs more often (because of the extra demand for cpu time).k: %CPU -- CPU usage The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.l: TIME -- CPU Time Total CPU time the task has used since it started. When 'Cumulative mode' is On, each process is listed with the cpu time that it and its dead children has used. You toggle 'Cumulative mode' with 'S', which is a command-line option and an interactive command. See the 'S' interactive command for additional information regarding this mode.m: TIME+ -- CPU Time, hundredths The same as 'TIME', but reflecting more granularity through hundredths of a sec ond.n: %MEM -- Memory usage (RES) A task's currently used share of available physical memory.o: VIRT -- Virtual Image (kb) The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out. (Note: you can define the STATSIZE=1 environment variable and the VIRT will be calculated from the /proc/#/state VmSize field.) VIRT = SWAP + RES.p: SWAP -- Swapped size (kb) The swapped out portion of a task's total virtual memory image.q: RES -- Resident size (kb) The non-swapped physical memory a task has used. RES = CODE + DATA.r: CODE -- Code size (kb) The amount of physical memory devoted to executable code, also known as the'text resident set' size or TRS.s: DATA -- Data+Stack size (kb) The amount of physical memory devoted to other than executable code, also known the 'data resident set' size or DRS.t: SHR -- Shared Mem size (kb) The amount of shared memory used by a task. It simply reflects memory that could be potentially shared with other processes.u: nFLT -- Page Fault count The number of major page faults that have occurred for a task. A page fault occurs when a process attempts to read from or write to a virtual page that is not currently present in its address space. A major page fault is when disk access is involved in making that page available.v: nDRT -- Dirty Pages count The number of pages that have been modified since they were last written to disk. Dirty pages must be written to disk before the corresponding physical memory location can be used for some other virtual page.w: S -- Process Status The status of the task which can be one of: 'D' = uninterruptible sleep 'R' = running 'S' = sleeping 'T' = traced or stopped 'Z' = zombie Tasks shown as running should be more properly thought of as 'ready to run' --their task_struct is simply represented on the Linux run-queue. Even without a true SMP machine, you may see numerous tasks in this state depending on top's delay interval and nice value.x: Command -- Command line or Program name Display the command line used to start a task or the name of the associated program. You toggle between command line and name with 'c', which is both a command-line option and an interactive command. When you've chosen to display command lines, processes without a command line (like kernel threads) will be shown with only the program name in parentheses, as in this example: ( mdrecoveryd ) Either form of display is subject to potential truncation if it's too long to fit in this field's current width. That width depends upon other fields selected, their order and the current screen width. Note: The 'Command' field/column is unique, in that it is not fixed-width. When displayed, this column will be allocated all remaining screen width (up to the maximum 512 characters) to provide for the potential growth of program names into command lines.y: WCHAN -- Sleeping in Function Depending on the availability of the kernel link map ('System.map'), this field will show the name or the address of the kernel function in which the task is currently sleeping. Running tasks will display a dash ('-') in this column. Note: By displaying this field, top's own working set will be increased by over 700Kb. Your only means of reducing that overhead will be to stop and restart top.z: Flags -- Task Flags This column represents the task's current scheduling flags which are expressed in hexadecimal notation and with zeros suppressed. These flags are officially documented in <linux/sched.h>. Less formal documentation can also be found on the 'Fields select' and 'Order fields' screens. 默认情况下仅显示比较重要的 PID、USER、PR、NI、VIRT、RES、SHR、S、%CPU、%MEM、TIME+、COMMAND 列。2.1 用快捷键更改显示内容。(1)更改显示内容通过 f键可以选择显示的内容。 按 f 键之后会显示列的列表?按 a-z 即可显示或隐藏对应的列,最后按回车键确定。(2)按o键可以改变列的显示顺序。 按小写的 a-z 可以将相应的列向右移动,而大写的 A-Z 可以将相应的列向左移动。最后按回车键确定。 按大写的 F 或 O 键,然后按 a-z 可以将进程按照相应的列进行排序。而大写的 R 键可以将当前的排序倒转。 设置完按回车返回界面。三. 命令使用详细内容可以参考MAN 帮助文档。这里列举部分内容:命令格式:top [-] [d] [p] [q] [c] [C] [S] [n]参数说明:d: 指定每两次屏幕信息刷新之间的时间间隔。当然用户可以使用s交互命令来改变之。p: 通过指定监控进程ID来仅仅监控某个进程的状态。q:该选项将使top没有任何延迟的进行刷新。如果调用程序有超级用户权限,那么top将以尽可能高的优先级运行。S: 指定累计模式s : 使top命令在安全模式中运行。这将去除交互命令所带来的潜在危险。i: 使top不显示任何闲置或者僵死进程。c: 显示整个命令行而不只是显示命令名在top命令的显示窗口,我们还可以输入以下字母,进行一些交互:帮助文档如下:Help for Interactive Commands - procps version 3.2.7Window 1:Def: Cumulative mode Off. System: Delay 4.0 secs; Secure mode Off. Z,B Global: 'Z' change color mappings; 'B' disable/enable bold l,t,m Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info 1,I Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode f,o . Fields/Columns: 'f' add or remove; 'o' change display order F or O . select sort field <,> . Move sort field: '<' next col left; '>' next col right R,H . Toggle: 'R' normal/reverse sort; 'H' show threads c,i,S . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time x,y . Toggle highlights: 'x' sort field; 'y' running tasks z,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y') u . Show specific user only n or # . Set maximum tasks displayed k,r Manipulate tasks: 'k' kill; 'r' renice d or s Set update interval W Write configuration file q Quit ( commands shown with '.' require a visible task display window )Press 'h' or '?' for help with Windows,h或者? : 显示帮助画面,给出一些简短的命令总结说明。k :终止一个进程。系统将提示用户输入需要终止的进程PID,以及需要发送给该进程什么样的信号。一般的终止进程可以使用15信号;如果不能正常结束那就使用信号9强制结束该进程。默认值是信号15。在安全模式中此命令被屏蔽。i:忽略闲置和僵死进程。这是一个开关式命令。q: 退出程序。r: 重新安排一个进程的优先级别。系统提示用户输入需要改变的进程PID以及需要设置的进程优先级值。输入一个正值将使优先级降低,反之则可以使该进程拥有更高的优先权。默认值是10。S:切换到累计模式。s : 改变两次刷新之间的延迟时间。系统将提示用户输入新的时间,单位为s。如果有小数,就换算成ms。输入0值则系统将不断刷新,默认值是5 s。需要注意的是如果设置太小的时间,很可能会引起不断刷新,从而根本来不及看清显示的情况,而且系统负载也会大大增加。f或者F :从当前显示中添加或者删除项目。o或者O :改变显示项目的顺序。l: 切换显示平均负载和启动时间信息。即显示影藏第一行m: 切换显示内存信息。即显示影藏内存行t : 切换显示进程和CPU状态信息。即显示影藏CPU行c: 切换显示命令名称和完整命令行。 显示完整的命令。 这个功能很有用。M : 根据驻留内存大小进行排序。P:根据CPU使用百分比大小进行排序。T: 根据时间/累计时间进行排序。W: 将当前设置写入~/.toprc文件中。这是写top配置文件的推荐方法。
这个问题的解决方法为: 运行dcomcnfg点 组件服务-》服务-》电脑-》我的电脑-》DCOM 配置找到“Windows Management and Instrumentation”,右击属性--安全--编辑--将ASPNET用户权限添加进去重启电脑
rsync是类unix系统下的数据镜像备份工具。它的特性如下:可以镜像保存整个目录树和文件系统。可以很容易做到保持原来文件的权限、时间、软硬链接等等。无须特殊权限即可安装。快速:第一次同步时 rsync 会复制全部内容,但在下一次只传输修改过的文件。rsync 在传输数据的过程中可以实行压缩及解压缩操作,因此可以使用更少的带宽。安全:可以使用scp、ssh等方式来传输文件,当然也可以通过直接的socket连接。支持匿名传输,以方便进行网站镜象。rsync的安装,centos默认已经自带就安装了程序。无需安装。准备:检查是否已经安装rpm -qa rsync1、安装yum install rsync2、命令输入rsync出现以下表示安装成功:rsync version 3.0.6 protocol version 30Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others.Web site: http://rsync.samba.org/Capabilities: 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, append, ACLs, xattrs, iconv, symtimesrsync使用服务端-客户端同步文式双机备份配置:服务端:网上有很多教程使用xinet.d来启动rsync服务端。这里使用rsync自带的来启动服务端如:rsync --daemon --config=/home/leyewen/etc/rsync/rsyncd.conf1、配置rsyncd.conf如?: # 全局参数# 运行rsync守护进程的用户uid = root # 运行rsync守护进程的组gid = root # 不使?chrootuse chroot = no # 最大连接数为4max connections = 2 # 是否检查口令文件的权限strict modes = yes # 默认端口873 这里最好改成1024以上端口 并且port = 873 #pid文件的存放位置pid file = /usr/local/rsync/rsyncd.pid #锁文件的存放位置lock file = /usr/local/rsync/rsync.lock log file = /usr/local/rsync/log/rsyncd.logmotd file = /usr/local/rsync/rsyncd.motd# 模块参数# 这里是认证的模块名,在client端需要指定[backup] # 需要做镜像的目录 不可缺少path = /home/rsync/data # 这个模块的注释信息comment = My Backup # 可以忽略一些无关的IO错误ignore errors # 只读read only = no # 不允许列文件list = no # 认证的用户名 如果没有这行则表明是匿名 此用户与系统无关--->这里的auth users =与rsync.pass中的用户名一致auth users = sensor # 密码和用户名对比表,密码文件自己生成secrets file = /usr/local/rsync/rsync.pass # 允许主机# hosts allow = 192.168.1.1,10.10.10.10 # 禁止主机# hosts deny = 0.0.0.0/0 #transfer logging = yes 2、配置rsync密码(在上边的配置文件中已经写好路径) /usr/local/rsync/rsync.pass (名字随便写,只要和上边配置文件里的一致即可),格式(一行一个用户)账号:密码vi /usr/local/rsync/rsync.pass 例子:sensor:passwd权限:因为rsync.pas存储了rsync服务的用户名和密码,所以非常重要。要将rsync.pas设置为root拥有, 且权限为600。chmod 600 /usr/local/rsync/rsync.pass 3、启动rsync服务端rsync --daemon --config=/usr/local/rsync/rsyncd.conf客户端:rsync -avz --progress --delete --port=873 --password-file=/home/leyewen/etc/rsync/rsync-client.pass --exclude=.svn/ --exclude=WEB-INF/ /home/leyewen/svn/* leyewen@192.168.1.112::back这里同步本地的svn下所有文件到服务端配置的备份目录--exclude=.svn/ --exclude=WEB-INF/ 过滤svn和WEB-INF目录配置说明 rsync -avz /home/rsync/data/* sensor@211.144.76.142::backup rsync -avz 同步目录|文件 用户名@IP::模块名 -a 参数,相当于-rlptgoD,-r 是递归 -l 是链接文件,意思是拷贝链接文件;-p 表示保持文件原有权限;-t 保持文件原有时间;-g 保持文件原有用户组;-o 保持文件原有属主;-D 相当于块设备文件;-z 传输时压缩;-P 传输进度;-v 传输时的进度等信息,和-P有点关系,自己试试。可以看文档; 另外:定制欢迎信息文件rsyncd.motd 如:[root@211 rsync]# cat rsyncd.motd++++++++++++++++++++++++++++ wellcome rsyncd ++++++++++++++++++++++++++++ 注意: --password-file=/home/leyewen/etc/rsync/rsync-client.pass 通过--password-file指定密码文件,1,注意修改.pass 文件为chmod 600 2,rsync 服务端格式为usrname:pwd 但客户端格式为pwd ,所以这里容易出错!!
服务热线:
4006-75-4006(7*24小时在线)
总机直拨:
0871-63886388(工作日9:00-18:00)
售前咨询
售后咨询
备案咨询
电话
二维码
TOP