Linux基本命令及使用方法(二)

 命令目录

目录

 curl:(从服务器传输数据或向服务器传输数据。支持大多数协议,包括HTTP,FTP和POP3。)

wget:( 从Web下载文件。支持HTTP,HTTPS和FTP。)

nohup:(允许终端关闭后继续执行)

ssh:(Secure Shell是一种用于安全登录远程系统的协议。它可用于在远程服务器上记录或执行命令。)

ps:(有关运行进程的信息。)

cat:(打印并连接文件)

ln:(创建指向文件或文件夹的链接)

mv:(移动或重命名文件或目录)

git:(分布式版本控制系统,官网https://git-scm.com/)



声明

在大家疑问这篇博文的意义之前声明,本文只是一篇用于记忆命令的博文。

 curl:(从服务器传输数据或向服务器传输数据。支持大多数协议,包括HTTP,FTP和POP3。)

将URL的内容下载到文件:

curl {{http://example.com}} -o {{filename}}

下载文件,将输出保存在URL指示的文件名下:

curl -O {{http://example.com/filename}}

在[L] ocation重定向后下载文件,并自动[C]继续(恢复)以前的文件传输:

curl -O -L -C - {{http://example.com/filename}}

发送表单编码数据(类型的POST请求application/x-www-form-urlencoded):

curl -d {{'name=bob'}} {{http://example.com/form}}

使用自定义HTTP方法发送带有额外标头的请求:

curl -H {{'X-My-Header: 123'}} -X {{PUT}} {{http://example.com}}

以JSON格式发送数据,指定适当的内容类型标头:

curl -d {{'{"name":"bob"}'}} -H {{'Content-Type: application/json'}} {{http://example.com/users/1234}}

传递用于服务器身份验证的用户名和密码:

curl -u myusername:mypassword {{http://example.com}}

传递客户端证书和资源密钥,跳过证书验证:

curl --cert {{client.pem}} --key {{key.pem}} --insecure {{https://example.com}}

wget:( 从Web下载文件。支持HTTP,HTTPS和FTP。)

将URL的内容下载到文件(在本例中名为“foo”):

wget {{https://example.com/foo}}

将URL的内容下载到文件(在本例中名为“bar”):

wget -O {{bar}} {{https://example.com/foo}}

下载单个网页及其所有资源(脚本,样式表,图像等):

wget --page-requisites --convert-links {{https://example.com/somepage.html}}

下载完整的网站,请求间隔为3秒:

wget --mirror --page-requisites --convert-links --wait=3 {{https://example.com}}

下载目录及其子目录中的所有列出文件(不下载嵌入页面元素):

wget --mirror --no-parent {{https://example.com/somepath/}}

通过经过身份验证的FTP下载URL的内容:

wget --ftp-user={{username}} --ftp-password={{password}} {{ftp://example.com}}

继续下载不完整:

wget -c {{https://example.com}}

启用安静模式以抑制输出:

wget -q {{https://example.com}}

nohup:(允许终端关闭后继续执行)

运行可以超越终端的进程: 

nohup {{command options}}

ssh:(Secure Shell是一种用于安全登录远程系统的协议。它可用于在远程服务器上记录或执行命令。)

连接到远程服务器:

ssh {{username}}@{{remote_host}}

连接到具有特定标识(私钥)的远程服务器:

ssh -i {{path/to/key_file}} {{username}}@{{remote_host}}

使用特定端口连接到远程服务器:

ssh {{username}}@{{remote_host}} -p {{2222}}

在远程服务器上运行命令:

ssh {{remote_host}} {{command -with -flags}}

SSH隧道:动态端口转发(localhost上的SOCKS代理:9999):

ssh -D {{9999}} -C {{username}}@{{remote_host}}

SSH隧道:将特定端口(localhost:9999转发到slashdot.org:80)以及禁用远程命令的伪[t] ty分配和执行[n]:

ssh -L {{9999}}:{{slashdot.org}}:{{80}} -N -T {{username}}@{{remote_host}}

SSH跳转:通过跳转主机连接到远程服务器(可以用逗号字符指定多跳跳跃):

ssh -J {{username}}@{{jump_host}} {{username}}@{{remote_host}}

代理转发:将身份验证信息转发到远程计算机(man ssh_config有关可用选项,请参阅):

ssh -A {{username}}@{{remote_host}}

ps:(有关运行进程的信息。)

列出所有正在运行的进程

ps aux

列出所有正在运行的进程,包括完整的命令

ps auxww

搜索与字符串匹配的进程:

ps aux | grep {{string}}

以额外的完整格式列出当前用户的所有进程:

ps --user $(id -u) -F

将当前用户的所有进程列为树:

ps --user $(id -u) f

获取进程的父pid:

ps -o ppid= -p {{pid}}

cat:(打印并连接文件)

将文件内容打印到标准输出:

cat {{file}}

将几个文件连接到目标文件中:

cat {{file1}} {{file2}} > {{target_file}}

将多个文件附加到目标文件中:

cat {{file1}} {{file2}} >> {{target_file}}

编号所有输出行:

cat -n {{file}}

ln:(创建指向文件或文件夹的链接)

创建指向文件或目录的符号链接(软连接 soft):

ln -s {{path/to/file_or_directory}} {{path/to/symlink}}

覆盖现有符号以指向不同的文件:

ln -sf {{path/to/new_file}} {{path/to/symlink}}

创建文件的硬链接(硬链接 tough):

ln {{path/to/file}} {{path/to/hardlink}}

mv:(移动或重命名文件或目录)

在任意位置移动文件:

mv {{source}} {{target}}

在覆盖现有文件之前不要提示确认:

mv -f {{source}} {{target}}

无论文件权限如何,在覆盖现有文件之前提示确认:

mv -i {{source}} {{target}}

不要覆盖目标上的现有文件:

mv -n {{source}} {{target}}

以详细模式移动文件,在移动文件后显示文件:

mv -v {{source}} {{target}}

git:(分布式版本控制系统,官网https://git-scm.com/

检查Git版本:

git --version

致电一般帮助:

git --help

调用命令的帮助:

git help {{command}}

执行Git命令:

git {{command}}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值