十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
一、使用工具:xshell、linux redhat。
站在用户的角度思考问题,与客户深入沟通,找到丰林网站设计与丰林网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都做网站、网站制作、企业官网、英文网站、手机端网站、网站推广、国际域名空间、网络空间、企业邮箱。业务覆盖丰林地区。
二、上传步骤:
1、连接设置(linux客户端)
2、linux服务器端设置
在linux主机上,安装上传下载工具包rz及sz; 如果不知道你要安装包的具体名称,可以使用yum provides */name
进行查找系统自带软件包的信息;
一般会列出软件包的名称及版本,还有安装路径;查询到软件包名后,使用yum
install -y 包名 进行安装。
lrzsz包安装完成后包括上传rz、下载sz命令;只需要安装这个包即可。
[root@localhost src]# yum install -y lrzsz
3、从Windows上传文件,上传命令为rz;在Linux命令行下输入rz,上传的文件在当前命令行的目录下;
[root@localhost src]# rz
输入rz命令后,会弹出对话框,选择你要上传的文件,选择打开就上传到Linux主机。上传完可以使用ls
查看;
4、从Linux主机下载文件,下载命令为sz
,后面跟要下载的文件名;可以选择下载的保存文件夹;
[root@xyx-vsver01 webapps]# sz 文件名称
三、注意事项:
1.正确填写用户名和密码;
2.在ZMODEM 添加上图设置
Linux服务器应该开放了ssh服务的,这样方便远程管理,可以利用ssh服务上传文件的,用ssh服务上传文件时的权限,和你用ssh远程登录的那个用户的权限是一样的,这样就不用考虑权限设置的问题。下面是上传文件的方法:如果你的本地电脑是Linux系统,可以打开终端,不需要登录Linux服务器,直接用scp命令上传文件。scp命令是scp协议的命令,scp协议就是利用ssh连接来传输文件的一个协议。使用scp命令时需要将登录的用户名作为它的参数(参数的一部分),接着scp命令会提示你输入登录密码,如果连接成功就会直接传输文件了。scp命令的具体用法可以自行百度一下,很简单的,就不介绍了。 如果你的本地电脑是Windows就更好办了,可以安装一个WinSCP,这个软件是免费的,打开WinSCP软件,要选择scp协议,然后输入ssh登录的用户名和密码,连接成功后,WinSCP软件界面的左边是本地文件,右边是Linux的目录,然后就能随便上传文件到Linux服务器了。
怎样通过命令行给linux传输文件,方法如下
一、从服务器下载文件到本机
1、修改文件所属
由于只能下载文件所属为自己的文件,所以要做修改文件所属的操作。
chown hudelei /opt/logs/tomcat/app/tomcat_stk_nm/stk-time.log
2、下载到本机
scp hi@10.10.30.10:/opt/logs/tomcat/app/tomcat_stk_nm/stk-time.log /Users/hvvi/Desktop
3、输入密码
二、上传文件夹到服务器
1、scp -r /Users/hddvvi/Desktop/load hi@10.10.30.10:/opt/logs/tomcat/app/tomcat_stk_nm/
注意:加上 -r,否则会报错:not a regular file
2、输入密码3、文件移动上上层 mv filename.java 。。/
注:本文使用的是mac本机和linux服务器。
你是你是要通过git命令上传东西,还是想上传git到服务器上面,你可以先通过yum安装git
# yum install git
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds linuxprobe.com from cached hostfile
base | 3.7 kB 00:00
epel | 4.3 kB 00:00
epel/primary_db | 5.9 MB 00:05
extras | 3.4 kB 00:00
hhvm | 2.9 kB 00:00
shells_fish_release_2 | 1.2 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 821 kB 00:01
upgrade | 1.9 kB 00:00
virtualbox/signature | 181 B 00:00
virtualbox/signature | 1.1 kB 00:00 ...
包 git-1.7.1-8.el6.x86_64 已安装并且是最新版本
无须任何处理
#git --help
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
[--help] COMMAND [ARGS]
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG
See 'git help COMMAND' for more information on a specific command.
下面我给介绍一种从本地上传到服务器的命令:
命令rz和sz命令,首先你需要安装lrzsz库
#rz --help
rz version 0.12.20
Usage: rz [options] [filename.if.xmodem]
Receive files with ZMODEM/YMODEM/XMODEM protocol
(X) = option applies to XMODEM only
(Y) = option applies to YMODEM only
(Z) = option applies to ZMODEM only
-+, --append append to existing files
-a, --ascii ASCII transfer (change CR/LF to LF)
-b, --binary binary transfer
-B, --bufsize N buffer N bytes (N==auto: buffer whole file)
-c, --with-crc Use 16 bit CRC (X)
-C, --allow-remote-commands allow execution of remote commands (Z)
-D, --null write all received data to /dev/null
--delay-startup N sleep N seconds before doing anything
-e, --escape Escape control characters (Z)
-E, --rename rename any files already existing
--errors N generate CRC error every N bytes (debugging)
-h, --help Help, print this usage message
-m, --min-bps N stop transmission if BPS below N
-M, --min-bps-time N for at least N seconds (default: 120)
-O, --disable-timeouts disable timeout code, wait forever for data
--o-sync open output file(s) in synchronous write mode
-p, --protect protect existing files
-q, --quiet quiet, no progress reports
-r, --resume try to resume interrupted file transfer (Z)
-R, --restricted restricted, more secure mode
-s, --stop-at {HH:MM|+N} stop transmission at HH:MM or in N seconds
-S, --timesync request remote time (twice: set local time)
--syslog[=off] turn syslog on or off, if possible
-t, --timeout N set timeout to N tenths of a second
-u, --keep-uppercase keep upper case filenames
-U, --unrestrict disable restricted mode (if allowed to)
-v, --verbose be verbose, provide debugging information
-w, --windowsize N Window is N bytes (Z)
-X --xmodem use XMODEM protocol
-y, --overwrite Yes, clobber existing file if any
--ymodem use YMODEM protocol
-Z, --zmodem use ZMODEM protocol
short options use the same arguments as the long ones
#sz --help
sz version 0.12.20
Usage: sz [options] file ...
or: sz [options] -{c|i} COMMAND
Send file(s) with ZMODEM/YMODEM/XMODEM protocol
(X) = option applies to XMODEM only
(Y) = option applies to YMODEM only
(Z) = option applies to ZMODEM only
-+, --append append to existing destination file (Z)
-2, --twostop use 2 stop bits
-4, --try-4k go up to 4K blocksize
--start-4k start with 4K blocksize (doesn't try 8)
-8, --try-8k go up to 8K blocksize
--start-8k start with 8K blocksize
-a, --ascii ASCII transfer (change CR/LF to LF)
-b, --binary binary transfer
-B, --bufsize N buffer N bytes (N==auto: buffer whole file)
-c, --command COMMAND execute remote command COMMAND (Z)
-C, --command-tries N try N times to execute a command (Z)
-d, --dot-to-slash change '.' to '/' in pathnames (Y/Z)
--delay-startup N sleep N seconds before doing anything
-e, --escape escape all control characters (Z)
-E, --rename force receiver to rename files it already has
-f, --full-path send full pathname (Y/Z)
-i, --immediate-command CMD send remote CMD, return immediately (Z)
-h, --help print this usage message
-k, --1k send 1024 byte packets (X)
-L, --packetlen N limit subpacket length to N bytes (Z)
-l, --framelen N limit frame length to N bytes (l=L) (Z)
-m, --min-bps N stop transmission if BPS below N
-M, --min-bps-time N for at least N seconds (default: 120)
-n, --newer send file if source newer (Z)
-N, --newer-or-longer send file if source newer or longer (Z)
-o, --16-bit-crc use 16 bit CRC instead of 32 bit CRC (Z)
-O, --disable-timeouts disable timeout code, wait forever
-p, --protect protect existing destination file (Z)
-r, --resume resume interrupted file transfer (Z)
-R, --restricted restricted, more secure mode
-q, --quiet quiet (no progress reports)
-s, --stop-at {HH:MM|+N} stop transmission at HH:MM or in N seconds
--tcp build a TCP connection to transmit files
--tcp-server open socket, wait for connection
-u, --unlink unlink file after transmission
-U, --unrestrict turn off restricted mode (if allowed to)
-v, --verbose be verbose, provide debugging information
-w, --windowsize N Window is N bytes (Z)
-X, --xmodem use XMODEM protocol
-y, --overwrite overwrite existing files
-Y, --overwrite-or-skip overwrite existing files, else skip
--ymodem use YMODEM protocol
-Z, --zmodem use ZMODEM protocol
short options use the same arguments as the long ones
More information can be used for reference linuxprobe.com。