Linux系统中远程传输命令scp

linux系统可以实现把文件通过网络从一台主机传输至另一台主机,而且所有的数据都进行加密处理。

准备两台测试主机pc1和pc2,均为RHEL7,网络连接方式为桥接方式,可以连接外网。

测试基本用法,从pc1向pc2中传输数据。

1、登录pc1,查看IP,测试外网,创建测试目录、测试数据

[root@pc1 ~]# ifconfig | head -n 3  ## 查看pc1IP地址
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.20  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::20c:29ff:fee4:f7b9  prefixlen 64  scopeid 0x20<link>
[root@pc1 ~]# ping -c 3 www.baidu.com  ## 测试外网,联通
PING www.a.shifen.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14: icmp_seq=1 ttl=51 time=16.7 ms
64 bytes from 39.156.66.14: icmp_seq=2 ttl=51 time=16.3 ms
64 bytes from 39.156.66.14: icmp_seq=3 ttl=51 time=16.4 ms

--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 8041ms
rtt min/avg/max/mdev = 16.376/16.541/16.778/0.201 ms
[root@pc1 ~]# pwd
/root
[root@pc1 ~]# mkdir dir1
[root@pc1 ~]# cd dir1/
[root@pc1 dir1]# seq 5 > a.txt
[root@pc1 dir1]# mkdir testdir
[root@pc1 dir1]# seq 3 > testdir/b.txt
[root@pc1 dir1]# tree  ## 测试数据及目录
.
├── a.txt
└── testdir
    └── b.txt

1 directory, 2 files

 

2、登录pc2,查看IP地址,测试外网,创建测试目录

[root@pc2 ~]# ifconfig | head -n 3  ## 查看pc2IP地址
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.13  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::20c:29ff:feaa:2b29  prefixlen 64  scopeid 0x20<link>
[root@pc2 ~]# ping -c 3 www.baidu.com  ## 测试外网
PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data.
64 bytes from 39.156.66.18: icmp_seq=1 ttl=51 time=14.6 ms
64 bytes from 39.156.66.18: icmp_seq=2 ttl=51 time=14.4 ms
64 bytes from 39.156.66.18: icmp_seq=3 ttl=51 time=14.4 ms

--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 8037ms
rtt min/avg/max/mdev = 14.413/14.482/14.604/0.086 ms
[root@pc2 ~]# mkdir dir2
[root@pc2 ~]# cd dir2/
[root@pc2 dir2]# pwd  ## 测试目录
/root/dir2
[root@pc2 dir2]# ls -a
.  ..

 

3、在pc1主机中,使用scp命令向pc2主机/root/dir2目录中传输文件a.txt及x.txt

 基本格式:scp    [参数]    本地文件    远程账户@远程IP地址:远程目录

[root@pc1 dir1]# ls
a.txt  testdir
[root@pc1 dir1]# scp a.txt root@192.168.3.13:/root/dir2/  ## 从pc1主机中向pc2主机/root/dir2/目录中传输文件a.txt
root@192.168.3.13's password: ## 此处输入pc2的root密码
a.txt                                                                                                              100%   10     0.0KB/s   00:00
[root@pc1 dir1]# cp a.txt x.txt  ## 将a.txt复制为x.txt,作为另一份测试数据
[root@pc1 dir1]# ls
a.txt  testdir  x.txt
## root用户情况下,测试不输入远程用户能够传输,可以 [root@pc1 dir1]# scp x.txt
192.168.3.13:/root/dir2/ root@192.168.3.13's password: ## 此处输入pc2的root密码 x.txt 100% 10 0.0KB/s 00:00

 

4、在pc2/root/dir2/目录下检查是否接收到了传输的文件

[root@pc2 dir2]# pwd
/root/dir2
[root@pc2 dir2]# ll  ## 查看接收的文件
total 8
-rw-r--r--. 1 root root 10 Nov  4 15:07 a.txt
-rw-r--r--. 1 root root 10 Nov  4 15:08 x.txt

 

5、在pc1主机中向pc2主机/root/dir2目录中传输目录testdir,需要在正常传输的基础上加 -r参数,表示递归传输

[root@pc1 dir1]# ls
a.txt  testdir  x.txt
[root@pc1 dir1]# scp -r testdir/ root@192.168.3.13:/root/dir2/  ## 传输目录,在正常传输的基础上添加-r参数
root@192.168.3.13's password:   ## 此处输入pc2的root密码
b.txt                                                                                                              100%    6     0.0KB/s   00:00
[root@pc1 dir1]# cp -r testdir/ testdir2
[root@pc1 dir1]# ls
a.txt  testdir  testdir2  x.txt
[root@pc1 dir1]# scp -r testdir2/ 192.168.3.13:/root/dir2/  ## root情况下,忽略远程用户@也可以正常传输
root@192.168.3.13's password:   ## 此处输入pc2的root密码
b.txt                                                                                                              100%    6     0.0KB/s   00:00

 

6、在pc2主机/root/dir2/目录中的检查是否接收到目录testdir、testdir2

[root@pc2 dir2]# pwd
/root/dir2
[root@pc2 dir2]# ll  ## 接收到传输的目录
total 8
-rw-r--r--. 1 root root 10 Nov  4 15:07 a.txt
drwxr-xr-x. 2 root root 18 Nov  4 15:24 testdir
drwxr-xr-x. 2 root root 18 Nov  4 15:25 testdir2
-rw-r--r--. 1 root root 10 Nov  4 15:08 x.txt

 

测试利用scp从远程主机下载文件到本地

基本用法:scp   远程用户@远程用户IP地址:传输的文件   本地接收目录

 

1、删除pc1主机/root/dir1/目录下的所有文件及目录

[root@pc1 dir1]# pwd
/root/dir1
[root@pc1 dir1]# rm -rf *
[root@pc1 dir1]# ls -a
.  ..

 

2、查看pc2主机/root/dir2目录下的文件及目录

[root@pc2 dir2]# pwd
/root/dir2
[root@pc2 dir2]# ls
a.txt  testdir  testdir2  x.txt
[root@pc2 dir2]# tree
.
├── a.txt
├── testdir
│   └── b.txt
├── testdir2
│   └── b.txt
└── x.txt

2 directories, 4 files

 

3、在pc1主机中,从pc2主机/root/dir2/目录中下载a.txt和x.txt

[root@pc1 dir1]# pwd
/root/dir1
[root@pc1 dir1]# ls -a
.  ..
[root@pc1 dir1]# scp root@192.168.3.13:/root/dir2/a.txt ./  ##在pc1主机中,从pc2主机远程下载a.txt
root@192.168.3.13's password:  ## 此处输入pc2的root密码
a.txt                                                                                                              100%   10     0.0KB/s   00:00
[root@pc1 dir1]# ls -a
.  ..  a.txt
[root@pc1 dir1]# scp 192.168.3.13:/root/dir2/x.txt ./   ## root登录下,可以忽略远程用户@
root@192.168.3.13's password:  ## 此处输入pc2的root密码
x.txt                                                                                                              100%   10     0.0KB/s   00:00
[root@pc1 dir1]# ls -a
.  ..  a.txt  x.txt

 

4、在pc1主机中,从pc2主机/root/dir2/目录中远程下载目录testdir和testdir2,需要在正常传输的基础上加-r参数

[root@pc1 dir1]# pwd
/root/dir1
[root@pc1 dir1]# ls -a
.  ..  a.txt  x.txt
[root@pc1 dir1]# scp -r root@192.168.3.13:/root/dir2/testdir ./  ## 在正常传输的基础上,加-r参数,实现目录的递归传输
root@192.168.3.13's password:   ## 此处输入pc2的root密码
b.txt                                                                                                              100%    6     0.0KB/s   00:00
[root@pc1 dir1]# ls -a
.  ..  a.txt  testdir  x.txt
[root@pc1 dir1]# scp -r 192.168.3.13:/root/dir2/testdir2 ./
root@192.168.3.13's password:   ## 此处输入pc2的root密码
b.txt                                                                                                              100%    6     0.0KB/s   00:00
[root@pc1 dir1]# ls -a
.  ..  a.txt  testdir  testdir2  x.txt
[root@pc1 dir1]# tree
.
├── a.txt
├── testdir
│   └── b.txt
├── testdir2
│   └── b.txt
└── x.txt

2 directories, 4 files

 

普通用户使用scp远程传输及下载文件及目录?

 

1、在pc1主机中切换至普通用户linuxprobe,创建测试目录及文件

[root@pc1 dir1]# su - linuxprobe
Last login: Sun Nov 1 15:41:04 CST 2020 on :0
[linuxprobe@pc1 ~]$ cd ~
[linuxprobe@pc1 ~]$ mkdir dir1
[linuxprobe@pc1 ~]$ cd dir1/
[linuxprobe@pc1 dir1]$ pwd
/home/linuxprobe/dir1
[linuxprobe@pc1 dir1]$ ls -a
.  ..
[linuxprobe@pc1 dir1]$ seq 7 > a.txt
[linuxprobe@pc1 dir1]$ mkdir testdir
[linuxprobe@pc1 dir1]$ cp a.txt testdir/b.txt
[linuxprobe@pc1 dir1]$ ls -a
.  ..  a.txt  testdir
[linuxprobe@pc1 dir1]$ tree  ## 测试目录及数据
.
├── a.txt
└── testdir
    └── b.txt

1 directory, 2 files

 

2、在pc2中切换至普通用户,创建测试目录

[root@pc2 ~]# su - usertest
[usertest@pc2 ~]$ cd ~
[usertest@pc2 ~]$ mkdir dir2
[usertest@pc2 ~]$ cd dir2/
[usertest@pc2 dir2]$ pwd  ## 测试目录
/home/usertest/dir2
[usertest@pc2 dir2]$ ls -a
.  ..

 

3、在普通用户模式下,在pc1主机中,向pc2主机传输文件

[linuxprobe@pc1 dir1]$ pwd
/home/linuxprobe/dir1
[linuxprobe@pc1 dir1]$ ls -a
. .. a.txt testdir
[linuxprobe@pc1 dir1]$ scp a.txt usertest@192.168.3.13:/home/usertest/dir2
usertest@192.168.3.13's password:  ## 此处输入用户usertest的密码
a.txt 100% 14 0.0KB/s 00:00
[linuxprobe@pc1 dir1]$ cp a.txt x.txt
[linuxprobe@pc1 dir1]$ ls -a
.  ..  a.txt  testdir  x.txt
[linuxprobe@pc1 dir1]$ scp x.txt 192.168.3.13:/home/usertest/dir2  ## 在普通用户登录情况下,省略远程用户@,无论root密码和普通用户密码,不能实现传输
linuxprobe@192.168.3.13's password:
Permission denied, please try again.
linuxprobe@192.168.3.13's password:
Permission denied, please try again.
linuxprobe@192.168.3.13's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
lost connection

 

4、在pc2主机中,检测是否接收到传输文件

[usertest@pc2 dir2]$ pwd
/home/usertest/dir2
[usertest@pc2 dir2]$ ls -a
.  ..  a.txt

 

5、在pc1主机中,测试远程传输目录到pc2主机,需要在正常传输的基础上,加-r参数

[linuxprobe@pc1 dir1]$ pwd
/home/linuxprobe/dir1
[linuxprobe@pc1 dir1]$ ls -a
.  ..  a.txt  testdir  x.txt
[linuxprobe@pc1 dir1]$ scp -r testdir/ usertest@192.168.3.13:/home/usertest/dir2  ## 加 -r参数,从pc1向pc2中传输目录
usertest@192.168.3.13's password:
b.txt                                                                                                              100%   14     0.0KB/s   00:00
[linuxprobe@pc1 dir1]$ cp -r testdir/ testdir2
[linuxprobe@pc1 dir1]$ scp -r testdir2/ 192.168.3.13:/home/usertest/dir2   ## 普通用户登录情况下,不能省略远程用户@
linuxprobe@192.168.3.13's password:
Permission denied, please try again.
linuxprobe@192.168.3.13's password:
Permission denied, please try again.

 

6、在pc2主机中验证是否接收到目录

[usertest@pc2 dir2]$ pwd
/home/usertest/dir2
[usertest@pc2 dir2]$ ls -a
.  ..  a.txt  testdir

 

普通用户登录下,从远程下载文件及目录:

1、pc1删除/home/linuxprobe/dir1/下所有文件及目录

[linuxprobe@pc1 dir1]$ pwd
/home/linuxprobe/dir1
[linuxprobe@pc1 dir1]$ rm -rf *

 

2、查看pc2主机/home/usertest/dir2/目录下文件及目录

[usertest@pc2 dir2]$ pwd
/home/usertest/dir2
[usertest@pc2 dir2]$ ls -a
.  ..  a.txt  testdir

 

3、在pc1中,从pc2远程下载文件及目录

[linuxprobe@pc1 dir1]$ pwd
/home/linuxprobe/dir1
[linuxprobe@pc1 dir1]$ ls -a
.  ..
[linuxprobe@pc1 dir1]$ scp usertest@192.168.3.13:/home/usertest/dir2/a.txt ./
usertest@192.168.3.13's password:
a.txt                                                                                                              100%   14     0.0KB/s   00:00
[linuxprobe@pc1 dir1]$ ls -a
.  ..  a.txt
[linuxprobe@pc1 dir1]$ scp -r usertest@192.168.3.13:/home/usertest/dir2/testdir ./
usertest@192.168.3.13's password:
b.txt                                                                                                              100%   14     0.0KB/s   00:00
[linuxprobe@pc1 dir1]$ ls -a
.  ..  a.txt  testdir
[linuxprobe@pc1 dir1]$ tree
.
├── a.txt
└── testdir
    └── b.txt

1 directory, 2 files

 

4、删除pc1主机和pc2主机的测试目录及测试数据,均切换回root用户

[linuxprobe@pc1 ~]$ whoami
linuxprobe
[linuxprobe@pc1 ~]$ rm -rf /home/linuxprobe/dir1/
[linuxprobe@pc1 ~]$ su - root
Password:
Last login: Wed Nov  4 14:38:06 CST 2020 from 192.168.3.4 on pts/0
[usertest@pc2 ~]$ whoami
usertest
[usertest@pc2 ~]$ rm -rf /home/usertest/dir2/
[usertest@pc2 ~]$ su - root
Password:
Last login: Wed Nov  4 14:38:20 CST 2020 from 192.168.3.4 on pts/0

 

scp命令实现远程免密传输?

root模式下,测试pc2主机向pc1主机远程免密传输文件、目录;pc2免密从pc1主机下载文件及目录

1、查看测试目录及数据

[root@pc2 dir2]# pwd
/root/dir2
[root@pc2 dir2]# ls -a
.  ..  a.txt  testdir
[root@pc2 dir2]# tree
.
├── a.txt
└── testdir
    └── b.txt

1 directory, 2 files
[root@pc1 dir1]# pwd
/root/dir1
[root@pc1 dir1]# ls -a
.  ..

 

 

2、在pc2主机中,使用ssh-keygen -t rsa命令生成密钥对

[root@pc2 dir2]# cd ~
[root@pc2 ~]# ls -a
.   anaconda-ks.cfg  .bash_logout   .bashrc  .config  .dbus    dir2       Downloads  .ICEauthority         .local  Pictures  .tcshrc    Videos
..  .bash_history    .bash_profile  .cache   .cshrc   Desktop  Documents  .esd_auth  initial-setup-ks.cfg  Music   Public    Templates  .viminfo
[root@pc2 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): ## 回车
Enter same passphrase again:  ## 回车
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:  ## 回车
3d:90:7e:cc:73:bc:d6:83:cf:d7:19:c5:ee:0c:18:60 root@pc2
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|         .E      |
|        o. .   . |
|       . = ..   o|
|        S B oo ..|
|         . +.+...|
|            + o++|
|           . o o=|
|              o. |
+-----------------+
[root@pc2 ~]# ls -a
.                .bash_history  .bashrc  .cshrc   dir2       .esd_auth             .local    Public   Templates
..               .bash_logout   .cache   .dbus    Documents  .ICEauthority         Music     .ssh     Videos
anaconda-ks.cfg  .bash_profile  .config  Desktop  Downloads  initial-setup-ks.cfg  Pictures  .tcshrc  .viminfo
[root@pc2 ~]# ls -a .ssh/
.  ..  id_rsa  id_rsa.pub

 

2、查看pc1主机root目录下文件及目录

[root@pc1 ~]# pwd
/root
[root@pc1 ~]# ls -a
.   anaconda-ks.cfg  .bash_logout   .bashrc  .config  .dbus    dir1       Downloads  .ICEauthority         .local  Pictures  .tcshrc    Videos
..  .bash_history    .bash_profile  .cache   .cshrc   Desktop  Documents  .esd_auth  initial-setup-ks.cfg  Music   Public    Templates

 

3、在pc2主机中,将密钥对中的公钥传输至pc1主机

[root@pc2 ~]# ssh-copy-id 192.168.3.20
The authenticity of host '192.168.3.20 (192.168.3.20)' can't be established.
ECDSA key fingerprint is 55:84:57:c6:8d:66:a0:1d:72:35:24:5d:ba:7d:1d:50.
Are you sure you want to continue connecting (yes/no)? yes  ## 此处输入yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.3.20's password:  ## 此处输入pc1root密码

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.3.20'"
and check to make sure that only the key(s) you wanted were added.

 

4、查看pc1主机/root/目录下文件:

[root@pc1 ~]# pwd
/root
[root@pc1 ~]# ls -a
.   anaconda-ks.cfg  .bash_logout   .bashrc  .config  .dbus    dir1       Downloads  .ICEauthority         .local  Pictures  .ssh     Templates
..  .bash_history    .bash_profile  .cache   .cshrc   Desktop  Documents  .esd_auth  initial-setup-ks.cfg  Music   Public    .tcshrc  Videos
[root@linuxprobe ~]# ls -a .ssh/  ## pc1主机已经接收到公钥文件
. .. authorized_keys

 

5、查看pc1测试目录

[root@pc1 dir1]# pwd
/root/dir1
[root@pc1 dir1]# ls -a
.  ..

 

6、测试从pc2主机远程免密向pc1主机传输文件及目录

[root@pc2 dir2]# pwd
/root/dir2
[root@pc2 dir2]# ls -a
.  ..  a.txt  testdir
[root@pc2 dir2]# scp a.txt root@192.168.3.20:/root/dir1/  ## 免密传输文件
a.txt                                                                                                              100%   10     0.0KB/s   00:00
[root@pc2 dir2]# scp -r testdir/ 192.168.3.20:/root/dir1/  ## 免密传输目录
b.txt                                                                                                              100%   10     0.0KB/s   00:00

 

7、查看pc1主机 /root/dir1/目录是否接收到文件

[root@pc1 dir1]# pwd
/root/dir1
[root@pc1 dir1]# ls -a  ## 接收到免密传输的文件
.  ..  a.txt  testdir

 

8、删除pc2主机/root/dir2/目录文件及目录

[root@pc2 dir2]# pwd
/root/dir2
[root@pc2 dir2]# ls -a
.  ..  a.txt  testdir
[root@pc2 dir2]# rm -rf *
[root@pc2 dir2]# ls -a
.  ..

 

9、在pc2主机测试从pc1主机免密下载文件及目录

[root@pc2 dir2]# pwd
/root/dir2
[root@pc2 dir2]# ls -a
.  ..
[root@pc2 dir2]# scp root@192.168.3.20:/root/dir1/a.txt ./
a.txt                                                                                                              100%   10     0.0KB/s   00:00
[root@pc2 dir2]# ls -a
.  ..  a.txt
[root@pc2 dir2]# scp -r root@192.168.3.20:/root/dir1/testdir ./
b.txt                                                                                                              100%   10     0.0KB/s   00:00
[root@pc2 dir2]# ls -a  ## 可以实现免密下载文件及目录
.  ..  a.txt  testdir

 

注:后经过测试,主机在不联外网的情况下,但是两台主机之间可以ping通的情况下也可以实现scp传输文件,两台主机之间不能ping通的情况下,不能实现传输。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


系ubuntu 下面打开终端输入:sudo apt-get install sendmail一般就安装完成噶啦跟住进入 /etc/mail/目录输入:m4 sendmail.mc &gt; sendmail.cf意思系跟住.mc文件 生成 sendmial.cf文件输入呢个命令:ps aux | g
依家我有1个软件goagent目录(大家懂得) 放在/home/gateman/Programs/ 下 1. proxy.py 入面有1个 proxy.py 文件 放在/home/gateman/Programs/goagent/local/ 入面 2.breakwall.sh 我在 proxy.p
其实我想讲的是 cp -L关于-L参数的解释:-L, --dereference always follow symbolic links in SOURCE意思是如果复制目标是1个软链接,则复制链接的目标 不是链接本身做个例子: 例如 ~/tmp/fo1 入面有1个c.txt 文件 和 指向他的软
原地址:http://www.rjgc.net/control/content/content.php?nid=4418 1、将文件checkout到本地目录svn checkout path(path是服务器上的目录)例如:svn checkout svn://192.168.1.1/pro/do
chroot,即 change root directory (更改 root 目录)。在 linux 系统中,系统默认的目录结构都是以 `/`,即是以根 (root) 开始的。而在使用 chroot 之后,系统的目录结构将以指定的位置作为 `/` 位置。实例:用live CD ubuntu假设你的
简单解析下, stdin就是标准输入, stdout就是标准。举个例子, 在当前我要打包1个文件夹 /var/log/ 到当前目录下,并用zip压缩,那么我们可以分步执行#tar -cvf log.tar /var/log/#zip -r log.tar.zip log.tar#rm -rf log
转自:http://man.ddvip.com/linux/Mandrakelinuxref/process-priority.html系统中运行的每个进程都有一个优先级(亦称“nice 值”),其范围从 -20 (最高优先级)到 19 (最低优先级)。默认情况下,进程的优先级是 0 (“基本”调度
str=&quot;/home/gateman&quot; if [ ${str:0:1} = &quot;/&quot; ]; then echo &quot;yes&#39;fi ${str:0:1} 中0表示从第几个字符开始,1表示截取多长
转自:http://kwokchivu.blog.51cto.com/1128937/694347 在RedHat系统下用usermod 命令可把某用户添加进多个附属组,默认情况下,一次性添加多个附属组可用以下方式来添加: usermod -G 附属组1,附属组2,...,附属组X 用户名 但在添加
有个文件 test.txt 内容如下:bash-3.00$ cat test.txt user user user_hiuser #注:呢行系空行T JGATEMANGATTTTTEMANGABBEMANAAABbash-3.00$下面介绍下常用的通配符 配合grep 命令:1. &quot;.&q
linux系统为每1个文件都分配有i索引节点(inode),系统根据呢d节点从磁盘找出数据。 一般来讲,每1个文件名(包含全路径)实际上都链接住1个i索引节点。inode实际上系乜咧? 其实可以算系1个指向磁盘具体位置(柱面,扇区之类)的指针, 系统分析某个文件的inode,得出磁盘柱面,扇区等数据
grep 可以立即为筛选, 一般的用法系 grep + 要查询的字段 + 文件(或者内容 例如| 传递既内容)1.grep + 要查询的字段 + 文件gateman@GPC:~/shell/SQL_GSI$ grep OID a.sqlWHERE OID=@BuildNOWHERE OID INWH
原文转自:http://www.ibm.com/developerworks/cn/linux/l-cn-vimcolumn/index.html开始之前人类大脑对文字的处理是平面式的,所以我们浏览文章、查找资料或者重构代码,要么是横向读,要么是纵向读,要么使用搜索功能,将文字作为一个平面整体。而在
PS:偶很喜欢用scp这个命令来传输数据。scp命令跟cp命令类似,只不过cp命令是在同一台机器上用的,scp是在两台机器上复制传输数据的命令。scp实质相当于利用SSH协议来传输数据的cp命令。 用法举例: 1、复制远程服务器的文件到本地: scp -P888 root@120.18.50.33:
打开终端,进入/bin/ls 一下会见到 bash sh 呢两个文件。其实距地系两个唔同既shell 解析器。如果在脚本a.sh 开头写入#!/bin/sh那么执行./a.sh 时候 就相当于 sh a.sh同理 开头写入#!/bin/bash执行./a.sh 时候 就相当于 bash a.sh如果
find查找文件的时候排除某个或几个文件或目录转自:http://www.cnblogs.com/starspace/archive/2008/10/20/1315380.html比如要在/usr/sam目录下查找不在dir1子目录之内的所有文件find /usr/sam -path &quot;/
假设有变量 var=http://www.google.com/test.htm一 # 号截取,删除左边字符,保留右边字符。echo ${var#*//}其中 var 是变量名,# 号是运算符,*// 表示从左边开始删除第一个 // 号及左边的所有字符即删除 http://结果是 :www.goog
转自: http://edyfox.codecarver.org/html/_vimrc_for_beginners.htmlVIM 中可供用户定制的选项非常非常多,作为初学者,我们没有必要了解这么多东西。下面,滇狐简单列出了一些最常用的配置项,大家可以根据自己的需要将这些内容添加到自己的 .vim
转自:http://www.einit.com/user1/11/archives/2006/3603.htmlUnix/Linux下一般想让某个程序在后台运行,很多都是使用 &amp; 在程序结尾来让程序自动运行。比如我们要运行mysql在后台: /usr/local/mysql/bin/mysq
首先, mount是类unix系统, 挂载设备到1个文件夹的操作命令, 注意系设备阿正常来讲,mount 是不能挂在文件夹到文件夹的。例如, 在我的~/tmp/ 目录中有两个文件夹fo1 fo2其中fo1 中有3个文件a.txt b.txt c.txt fo2 有4个 e.txt d.txt e.t