首页 > 代码库 > linux学习——拷文件

linux学习——拷文件

1、本地拷文件

cp [option] 源文件 目标文件

-a 尽可能将档案状态、权限等资料都照原状予以复制。

-r 若 source 中含有目录名,则将目录下之档案亦皆依序拷贝至目的地。

-f 若目的地已经有相同档名的档案存在,则在复制前先予以删除再行复制。

[syscom@sleeper test]$ cp helloworld.c ../
[syscom@sleeper test]$ cd ..
[syscom@sleeper liyan]$ ls -lt
total 2000
-rw-rw-r-- 1 syscom syscom     985 Jan 20 21:05 helloworld.c

2、远程拷文件

scp user@ip:源文件 目标文件(远程拷到本地)

scp 源文件 user@ip:目标文件(本地拷到远程)

3、ftp/sftp

sftp user@ip(连到远程主机)

sftp> help
Available commands:
bye                                Quit sftp(退出)
cd path                            Change remote directory to ‘path‘
chgrp grp path                     Change group of file ‘path‘ to ‘grp‘
chmod mode path                    Change permissions of file ‘path‘ to ‘mode‘
chown own path                     Change owner of file ‘path‘ to ‘own‘

df [-hi] [path]                    Display statistics for current directory or
filesystem containing ‘path‘(显示当前目录或包含‘path‘的文件系统的统计信息) exit Quit sftp get [-P] remote-path [local-path] Download file help Display this help text lcd path Change local directory to ‘path‘ lls [ls-options [path]] Display local directory listing lmkdir path Create local directory ln oldpath newpath Symlink remote file lpwd Print local working directory ls [-1aflnrSt] [path] Display remote directory listing lumask umask Set local umask to ‘umask‘ mkdir path Create remote directory progress Toggle display of progress meter put [-P] local-path [remote-path] Upload file pwd Display remote working directory quit Quit sftp rename oldpath newpath Rename remote file rm path Delete remote file rmdir path Remove remote directory symlink oldpath newpath Symlink remote file version Show SFTP version !command Execute ‘command‘ in local shell ! Escape to local shell ? Synonym for help

 

linux学习——拷文件