Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function:1) in /www/wwwroot/huua.top/wp-content/themes/argon/functions.php on line 206

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function:1) in /www/wwwroot/huua.top/wp-includes/feed-rss2.php on line 8

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
> VPS教程 – 韶华博客 https://blog.huua.top 记录成长的点点滴滴 Thu, 28 Jan 2021 09:25:44 +0000 zh-CN hourly 1
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
https://wordpress.org/?v=5.4.18 https://blog.huua.top/wp-content/uploads/sites/2/2020/06/cropped-1587309570-760ce961f54198a-32x32.png VPS教程 – 韶华博客 https://blog.huua.top 32 32 完整优雅的卸载腾讯云监控组件 https://blog.huua.top/2021/01/28/550.html https://blog.huua.top/2021/01/28/550.html#respond Thu, 28 Jan 2021 09:25:42 +0000 https://blog.huua.top/?p=550 腾讯云轻量瞬间火热了,供不应求,新加坡迅速售罄。接阿里云新手套餐2.0停止服务,MJJ们迅速将目光转向正则公测阶段的腾讯云轻量服务器,目前阿里云轻量服务器新加坡电信双程CN2,联通去CN2,回绕,移动去绕,回绕/直连,24元/月1TB流量,可奈飞,中文字幕全。

直接在腾讯云服务器上运行以下代码:

/usr/local/qcloud/stargate/admin/uninstall.sh
/usr/local/qcloud/YunJing/uninst.sh
/usr/local/qcloud/monitor/barad/admin/uninstall.sh
]]>
https://blog.huua.top/2021/01/28/550.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
我的世界MCSM面板安装教程(centos) https://blog.huua.top/2021/01/27/548.html https://blog.huua.top/2021/01/27/548.html#respond Wed, 27 Jan 2021 05:35:50 +0000 https://blog.huua.top/?p=548 服务器环境部署

安装node.js

1.安装github

yum install git -y

2.安装node.js管理器等组件

git clone git://github.com/creationix/nvm.git ~/nvm
# 设置nvm 自动运行
echo "source ~/nvm/nvm.sh" >> ~/.bashrc
source ~/.bashrc
# 安装npm的v13版本
nvm install v13.11.0
# 使用v13版本
nvm use v13.11.0

3.关闭终端并重新连接

安装java8

# 安装java8
yum install -y java
# 查看java版本
java -version

安装MCSM

# 克隆目录
git clone https://github.com/suwings/mcsmanager.git
# cd至目录
cd mcsmanager/
# 安装依赖库
npm install
# 启动面板
npm start 
每次重启服务器后要再次输入指令重启面板

提示:
# 每次重启或关闭后需要重新CD到项目目录才能继续执行指令
cd mcsmanager/
# 启动面板
npm start

后台运行

使用screen软件

yum install screen

# 创建一个名为 mcsm 的窗口
screen -S mcsm

# 在此新终端窗口内启动面板
npm start

#重新控制screen
screen -r mcsm

关闭防火墙

# 关闭防火墙,依次执行
systemctl stop firewalld.service
systemctl disable firewalld.service

登录面板

http://你的ip:23333/ 进入面板。

# 开头带“#”为最高管理员权限(注意,管理员与管理员之间账号可互删)不带“#”为用户账户

默认账号:#master
默认密码: 123456
]]>
https://blog.huua.top/2021/01/27/548.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
Linux常用命令 https://blog.huua.top/2021/01/24/546.html https://blog.huua.top/2021/01/24/546.html#respond Sun, 24 Jan 2021 10:58:24 +0000 https://blog.huua.top/?p=546 Linux常用命令

命令 | 描述 | —- | ———————————————————— |
| w | 保存不退出 |
| q | 不保存退出 |
| ! | 强制退出 |
| q! | 表示不保存退出,保留源文件,而另存为其他的文件,可以用w 新文件名 |
| ZZ | 大写Z,保存退出 |

命令提示符

[root@localhost~]#

符号含义
[ ]这是提示符的分隔符号,没有特殊含义
root显示的时当前的登录用户
@分割符号,没有含义
localhost当前系统的简写主机名
~代表当前用户所在的目录,注意这里只显示最后一个子目录
#命令提示符。如果是超级用户显示为#,如果是普通用户显示为$
超级用户的根目录/root
普通用户的根目录/home/用户名

Linux命令的基本格式

[root@localhost~]# 命令 [选项][参数]

命令中的[]代表可选项,也就是一些命令可以不写选项或参数。

选项

加入选项可以实现更多功能,如ls -l意思就是显示文件的详细信息。

参数

参数是命令的操作对象,一般文件、命令、用户和进程等都可以作为参数被命令操作。

目录操作命令

ls -目录操作命令

命令名称:ls

所在路径:usr/bin/ls

执行权限:所有用户

命令格式:ls [选项] [文件名或目录名]

选项:

选项描述
-a显示所有文件(包括隐藏文件)
--color=when支持颜色输出,when的值默认是always(总显示颜色),也可以是never(从不显示颜色)和auto(自动)
-ld显示目录信息,而不是目录下的文件
-lh人性化显示,按照我们习惯的单位显示文件大小
-i显示文件的i节点号
-l长格式显示(详细信息)。ls -l等同于ll

PS:Linux中.开头的文件为隐藏文件。

-l选项
image-20200919191051379

依次表示:权限、引用计数、所属用户、所属组、文件大小(字节)、文件修改时间、文件名称

这里的引用计数代表该目录下有多少个一级子目录。

cd -切换所在目录

所在路径:Shell内置命令

执行权限:所有用户

功能:切换所在目录

命令格式:cd [目录名]

cd命令只要两个选项:

-P指如果切换的目录是软链接目录,则进入其原始的物理目录
-L指如果切换的目录是软链接目录,则直接进入软链接目录
~代表用户的家目录。cd命令直接回车效果是一样的。
代表上次所在目录
.代表当前目录
..代表上级目录

mkdir -创建目录命令

所在路径:/usr/bin/mkdir

执行权限:所有用户

功能描述:创建一个空目录

命令格式:mkdir [选项] 目录名

选项只有一个:-p递归建立所需目录。

就是当需要创建多级目录时,需要-p选项,不加则无法创建多级目录。

如:mkdir -p lm1/lm2/lm3

rmdir -删除目录命令

所在路径:/usr/bin/rmdir

执行权限:所有用户

命令格式:rmdir [选项] 目录名

无选项。

rmdir也可以递归删除目录,不过只能删除空目录,一旦目录中有内容就会报错。

tree -显示目录树

所在路径:/usr/bin/tree

执行权限:所有用户

命令格式:tree 目录名

文件操作命令

touch -修改时间戳

执行权限:所有用户

功能描述:修改时间戳,如没有该文件,则创建一个空文件。

命令格式:touch [选项] 文件名或目录名

选项:

选项描述
-a只修改文件的访问时间
-c如果文件不存在,则不建立新文件
-d把文件的时间改为指定的时间
-m只修改文件的数据修改时间

Linux中分为三个时间,分别为访问时间、数据修改时间、状态修改时间。这三个时间可以通过stat命令查看。

stat -显示文件详细信息

执行权限:所有用户

功能描述:显示文件或文件系统的详细信息

命令格式:stat [选项] 文件或目录名

选项:只有一个选项-f查看文件所在的文件系统信息,而不是查看文件的信息。

cat -查看文件内容

执行权限:所有用户

功能描述:合并文件并打印输出到标准输出

命令格式:cat [选项] 文件名

选项:

选项描述
-A相当于-vET功能的整合,用于列出所有隐藏符号
-E列出每行结尾的回车符$
-n显示行号
-T把Tab键用^I 显示出来
-v列出特殊字符

more -分屏显示内容

执行权限:所有用户

功能描述:分屏显示文件内容

命令格式:more 文件名

常用的交互命令:

命令描述
空格键向下翻页
b向上翻页
回车键向下滚动一页
/字符串搜索指定的字符串
q退出

less -分行显示文件内容

执行权限:全部用户

功能描述:分行显示文件内容

命令格式:less 文件名

进入显示文件后,使用箭头键,用于分行查看文件内容。(每按一次会向上、下显示一行)。

head -显示文件开头的内容

执行权限:全部用户

命令格式:head [选项] 文件名

选项:

选项描述
-n行数:从文件开头开始,显示指定行数,-n20-20效果一样
-v显示文件名

命令默认显示文件前十行内容。

tail -显示文件结尾内容

执行权限:所有用户

命令格式:tail [选项] 文件名

选项

选项描述
-n行数:从文件结尾开始,显示指定行数,-n20-20效果一样
-f监听文件的新增内容

使用-f选项会显示最后10行内容,而且光标不会退出文件,会一直监听文件的新增内容,这个时候使用echo命令向该文件追加内容,在原始的正在监听的终端中就会显示追加的内容。

ln -在文件之间建立链接

执行权限:所有用户

命令格式:ln [选项] 源文件 目标文件

选项:

选项描述
-s建立软链接文件。默认建立硬链接文件
-f强制。如果目标文件已经存在,则删除目标文件后再建立链接文件

建立硬链接:ln /root/test /tmp/test-hard

建立软链接:ln -s /root/test /tmp/test-hard

目录和文件都能操作的命令

rm -删除文件或目录

执行权限:所有用户

命令格式:rm [选项] 文件或目录

选项:

选项描述
-f强制删除
-i这个选项是默认的,交互删除,在删除之前会询问用户
-r可以递归删除,可以删除目录

如果被删除的路径是一个目录,则必须有-r选项,否则会报错。

一般要强制删除一个文件时,用rm -rf 文件路径

cp -复制文件和目录

执行权限:所有用户

命令格式:cp [选项] 源文件 目标文件

选项:

选项描述
-a相当于-dpr选项的集合
-d如果源文件为软链接(对硬链接无效),则复制出的目标文件也为软链接
-i询问,如果目标文件已经存在,则会询问是否覆盖
-l把目标文件建立为源文件的硬链接文件,而不是复制源文件
-s把目标文件建立为源文件的软链接文件,而不是复制源文件
-p复制后目标文件保留源文件的属性(包括所有者、所属组、权限、时间)
-r递归复制,用于复制目录

不改名复制:cp test /tmp/

改名复制:cp test /tmp/test

如需要复制目录,则需要使用-r选项。

mv -移动文件或改名

执行权限:所有用户

命令格式:mv[格式] 源文件 目标文件

选项:

选项描述
-f强制覆盖,如果目标文件已经存在,则不询问,直接强制覆盖
-i交互移动,默认选项
-n如果目标文件已经存在,则不会覆盖移动,而是不询问用户
-v显示详细信息

权限管理命令

权限位的含义

image-20200920153951711

以上详细信息中,第一列就是权限位,其中:

第1位:表示linux的文件类型,如下

-普通文件
b块设备文件
c字符设备文件
d目录文件,Linux中一切皆文件,目录也是一种文件
l软链接文件
p管道符文件
s套接字文件
r代表read,读权限
w代表write,写权限
x代表execute,执行权限

第1组(第2-4位):文件拥有者的权限

第2组(第5-7位):文件所属组的权限

第3组(第8-10位):其他用户

chmod -修改文件的权限

执行权限:所有用户

功能描述:修改文件的权限模式

命令格式:chmod [选项] 权限模式 文件名

选项只有一个-R,递归设置权限,也就是给子目录中的所有文件设定权限。

权限模式:chmod命令的权限模式的格式是[用户身份][[赋予方式][权限]]

用户身份:

用户身份描述
u代表所有者
g代表所属组
o代表其他人
a代表全部身份

赋予方式:

赋予方式描述
+加入权限
-减去权限
=设置权限

权限:

权限描述
r读取权限
w写权限
x执行权限

如:

chmod o=rwx 文件名给其他人设置读写和执行权限。

chmod u+x,g+w 文件名给所有者执行权限,和所属组写权限。

数字权限

数字的含义:

数字含义
1代表x权限
2代表w权限
4代表r权限

如:chmod 755 文件名

第一个数字代表所有者的权限是 4+2+1

第二个数字代表所属组的权限是 4+1

第三个数字代表其他人的权限是 4+1

注意:

①当需要删除一个文件时,需要获取当前文件目录的写权限,光有文件的写权限是不够的。

②root用户是超级用户,就算没有任何权限,也可以执行所有操作。

③在普通用户中,只有文件的所有者才能修改权限。

umask -默认权限

主要让Linux中的新建文件和目录拥有默认权限。

查看系统的umask 默认权限

umask -S直接使用字母来表示默认权限。

修改系统的umask默认权限:

umask 002 修改默认权限为002

用户命令

useradd -创建用户

执行权限:超级用户

命令格式:useradd [选项] 用户名

选项:

选项描述
-u手动指定用户的UID
-d手动指定用户的家目录
-g手动指定用户的组名
-e手动指定用户的失效日期

第一步:添加用户useradd user

第二部:设置用户密码passwd user,输入两次密码确认

passwd -修改用户密码

执行权限:超级用户

命令格式:passwd [选项] 用户名

选项:

选项描述
-S查询用户密码的状态
-l暂时锁定用户
-u解锁用户

su -切换用户

命令格式:su - user切换到指定用户

usermod -修改用户信息

命令格式:usermod [选项] 用户名

userdel -删除用户

命令格式:userdel [-r] 用户名

所有者和所有组命令

chown -修改所有者和所有组

执行权限:所有用户

功能描述:修改文件和目录的所有者和所属组

命令格式:chown [选项] 所有者:所属组 文件(目录)

选项:-R递归设置权限,给子目录中的所有文件设置权限。

修改文件的所有者chown user 文件名

修改文件的所属组chown user:user 文件名

帮助命令

man 显示联级帮助手册

执行权限:所有用户

命令格式:man [选项] 命令

选项:

选项描述
-f查看命令拥有哪个级别的帮助
-k查看和命令相关的所有帮助

如:man ls #获取ls命令帮助信息

info -显示帮助信息的完整资料

man的使用大同小异。

在这个帮助信息中,如果标题的前面有*符号,则表示这是一个可以进入的子页面,按回车进入。

help -获取Shell内置命令帮助

一般使用都是外部命令,所以help使用很少。

搜索命令

whereis -查找命令、源文件和帮助

执行权限:所有用户

命令格式:whereis [选项] 命令

选项:

选项描述
-b只查找二进制命令
-m只查找帮助文档

which -列出命令的所在路径

执行权限:所有用户

命令格式:which 命令

locate -按照文件名搜索

执行权限:所有用户

命令格式:locate [选项] 文件名

选项:-i 忽略大小写。

注意:新建的文件,locate找不到,因为它不会直接去搜索硬盘空间,而是搜索locate数据库。

如果需要,可以使用updatedb命令来更新数据库。这种情况也是有可能会找不到,因为系统可能把该文件认定为临时文件。

find -在目录中搜索文件

执行权限:所有用户

命令格式:find 搜索路径 [选项] 搜索内容

选项:

选项描述
-name按照文件名搜索
-iname按照文件名搜索,不区分文件名大小写
-inum按照inode号搜索
-size[+/-]按照指定大小搜索文件,不加正反号为搜索指定大小文件
-atime[+/-]按照文件访问时间搜索
-mtime[+/-]按照文件数据修改时间搜索
-ctime[+/-]按照文件状态修改时间搜索
-perm[+/-]权限模式按照文件权限搜索

其他的还可以按照所有者,文件类型逻辑与算符

关机和重启命令

sync -数据同步

执行权限:所有用户

可直接执行,无参数。

shutdown -关机和重启

执行权限:超级用户

命令格式:shutdown [选项] 时间 [警告信息]

选项:

选项描述
-c取消已经执行的shutdown命令
-h关机
-r重启

shutdown -r now马上重启

shutdown -r 05:30指定时间重启,会占用终端前台

shutdown -r 05:30 &指定时间重启,会放入后台

shutdown -c取消定时重启

shutdown -r +1010分钟之后重启

shutdown -h now马上关机

shutdown -h 05:30指定时间关机

reboot 重启

直接重启。

haltpoweroff关机

直接关机。

init 重启和关机

init 0关机

init 6重启

改变系统运行级别的形式来完成关机重启的操作。

网络命令

ip -显示和设置网络路由

执行权限:超级用户

功能描述:显示和设置网络路由、路由策略

查看IP地址信息:ip address show

查看本机的路由信息表:ip route show

以下命令需要使用nmmtui工具

临时设定IP地址和删除IP地址:ip address add 192.168.44.31/24 dev ens33

临时设定网关:ip route del default via 192.168.44.1

ifconfig -配置网络接口

执行权限:超级用户

查看IP地址信息:ifconfig

临时配置IP地址:

ifconfig eth0 192.168.44.3

不指定子网掩码就会使用标准的子网掩码

ifconfig eth0 192.168.44.3 netmask 255.255.255.0

指定子网掩码

ifup启用网卡、ifdown关闭网卡

关闭eth0网卡命令:ifdown eth0

启用eth0网卡命令:ifup eth0

ping -向网络主机发送请求

执行权限:所有用户

功能描述:向网络主机发送ICMP请求

命令格式:ping [选项] IP

选项:

选项描述
-b后面加入广播地址,用于对整个网段进行探测
-c次数:用于指定ping的次数。ping -c 3 192.168.103.105
-s字节:指定探测包的大小。

再如:探测网段中可用主机

ping -b -c 3 192.168.103.255

ss -查询网络访问

执行权限:超级用户

命令格式:ss [选项]

选项:

选项描述
-a列出所有网络状态,包括Socket程序
-n使用IP地址和端口号显示,不使用域名和服务名
-p显示PID和程序名
-t显示TCP端口的连接状态
-u显示UDP端口的连接状态
-l查看监听状态

TCP和UDP:

①它们是两个具有代表性的传输层协议;

②TCP面向连接,而UDP是无连接的;

③TCP提供的服务更可靠;

④TCP面向字节流,UDP则是面向报文的;

⑤TCP连接只能是点到点相比,UDP连接方式更加多样化;

⑥UDP的首部开销8个字节比TCP的20字节要小;

在CentOS 7.x中默认没有安装netstat命令,而是通过ss命令取代了netstat命令。

使用方法:

查看本机所有网络连接:ss -an

查询本机开启的端口:ss -tuln

查看本机开启的端口与正在进行的连接:ss -tuan

netstat -查看网络连接

执行权限:所有用户

功能描述:输出网络连接、路由表、接口统计、伪装链接和组播成员

命令格式:netstat [选项]

用法基本与ss一致。

write -向其他用户发送信息

执行权限:所有用户

命令格式:write 用户名 [终端号]

如:write user1 pts/1

wall -给所有登录用户发送信息

命令格式:wall "要发送的信息"

mail -发送和接收电子邮件

执行权限:所有用户

发送邮件:

mail user1
Subject:hello    <-右键标题
Nice to meet you!    <-邮件内容
.                <-使用"."来结束邮件输入

发送文件内容:

mail -s "test mail" root</root/anaconda-ks.cfg

其中-s选项用来指定邮件标题。

查看已经接收的邮件:

mail

打开ssh服务

service sshd start

打开22端口

netstat -ntpl | grep 22

查看防火墙状态

systemctl status firewalld

开启防火墙状态

systemctl start firewalld

关闭防火墙

systemctl stop firewalld

查看当前firewall状态

firewall-cmd --state

重启firewall

firewall-cmd --reload

禁止开启重启

systemctl disable firewalld.service

查看已经开放的端口

firewall-cmd --list-ports

开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

测试端口

telnet 服务器ip地址 端口
#ip地址与端口使用空格隔开

用户和用户组管理

用户配置文件和管理相关文件

用户信息文件:/etc/passwd

保存所有用户的主要信息

影子(密码)文件:/etc/shadow

保存用户的实际加密密码和密码有效期等参数。这个文件只有超级用户才有权限查看。

组信息文件/etc/group/

记录组ID(GID)和组名的对应文件

组密码文件/etc/gshadow

服务器搭建

压缩包解压缩命令:

.tar 
解包:tar xvf FileName.tar 
打包:tar cvf FileName.tar DirName 
(注:tar是打包,不是压缩!) 
——————————————— 
.gz 
解压1:gunzip FileName.gz 
解压2:gzip -d FileName.gz 
压缩:gzip FileName

.tar.gz 和 .tgz 
解压:tar zxvf FileName.tar.gz 
压缩:tar zcvf FileName.tar.gz DirName 
——————————————— 
.bz2 
解压1:bzip2 -d FileName.bz2 
解压2:bunzip2 FileName.bz2 
压缩: bzip2 -z FileName

.tar.bz2 
解压:tar jxvf FileName.tar.bz2 
压缩:tar jcvf FileName.tar.bz2 DirName 
——————————————— 
.bz 
解压1:bzip2 -d FileName.bz 
解压2:bunzip2 FileName.bz 
压缩:未知

.tar.bz 
解压:tar jxvf FileName.tar.bz 
压缩:未知 

启动tomcat

tomcat的bin目录下执行:

./startup.sh

关闭tomcat

./shutdown.sh

安装ssh服务

sudo yum install openssh-server

监听22端口

Port 22
ListenAddress 0.0.0.0
ListenAddress ::
image-20201128154920006

使用ssh服务登录

ssh root@192.168.0.114

打开某个端口号

iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

重新启动网络服务

systemctl restart network
]]>
https://blog.huua.top/2021/01/24/546.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
QQ机器人 https://blog.huua.top/2020/12/21/543.html https://blog.huua.top/2020/12/21/543.html#respond Mon, 21 Dec 2020 13:14:44 +0000 https://blog.huua.top/?p=543 https://blog.huua.top/2020/12/21/543.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
Centos7之Systemd(Service文件)详解 https://blog.huua.top/2020/12/01/536.html https://blog.huua.top/2020/12/01/536.html#respond Tue, 01 Dec 2020 12:58:46 +0000 https://blog.huua.top/?p=536 一、开机启动

  对于那些支持 Systemd 的软件,安装的时候,会自动在/usr/lib/systemd/system目录添加一个配置文件。

  如果你想让该软件开机启动,就执行下面的命令(以httpd.service为例)。

    $ sudo systemctl enable httpd

  上面的命令相当于在/etc/systemd/system目录添加一个符号链接,指向/usr/lib/systemd/system里面的httpd.service文件。

  这是因为开机时,Systemd只执行/etc/systemd/system目录里面的配置文件。这也意味着,如果把修改后的配置文件放在该目录,就可以达到覆盖原始配置的效果。

二、启动服务

  设置开机启动以后,软件并不会立即启动,必须等到下一次开机。如果想现在就运行该软件,那么要执行systemctl start命令。

    $ sudo systemctl start httpd

  执行上面的命令以后,有可能启动失败,因此要用systemctl status命令查看一下该服务的状态。

    $ sudo systemctl status httpd

      httpd.service – The Apache HTTP Server

      Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)

      Active: active (running) since 金 2014-12-05 12:18:22 JST; 7min ago

      Main PID: 4349 (httpd)

      Status: “Total requests: 1; Current requests/sec: 0; Current traffic: 0 B/sec”

      CGroup: /system.slice/httpd.service

        ├─4349 /usr/sbin/httpd -DFOREGROUND

        ├─4350 /usr/sbin/httpd -DFOREGROUND

        ├─4351 /usr/sbin/httpd -DFOREGROUND

        ├─4352 /usr/sbin/httpd -DFOREGROUND

        ├─4353 /usr/sbin/httpd -DFOREGROUND

        └─4354 /usr/sbin/httpd -DFOREGROUND

      12月 05 12:18:22 localhost.localdomain systemd[1]: Starting The Apache HTTP Server…

      12月 05 12:18:22 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

      12月 05 12:22:40 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

  上面的输出结果含义如下。

        Loaded行:配置文件的位置,是否设为开机启动

        Active行:表示正在运行

        Main PID行:主进程ID

        Status行:由应用本身(这里是 httpd )提供的软件当前状态

        CGroup块:应用的所有子进程

        日志块:应用的日志

三、停止服务

  终止正在运行的服务,需要执行systemctl stop命令。

    $ sudo systemctl stop httpd.service

  有时候,该命令可能没有响应,服务停不下来。这时候就不得不”杀进程”了,向正在运行的进程发出kill信号。

    $ sudo systemctl kill httpd.service

  此外,重启服务要执行systemctl restart命令。

    $ sudo systemctl restart httpd.service

四、读懂配置文件

  一个服务怎么启动,完全由它的配置文件决定。下面就来看,配置文件有些什么内容。

  前面说过,配置文件主要放在/usr/lib/systemd/system目录,也可能在/etc/systemd/system目录。找到配置文件以后,使用文本编辑器打开即可。

  systemctl cat命令可以用来查看配置文件,下面以sshd.service文件为例,它的作用是启动一个 SSH 服务器,供其他用户以 SSH 方式登录。

    $ systemctl cat sshd.service

      [Unit]

      Description=OpenSSH server daemon

      Documentation=man:sshd(8) man:sshd_config(5)

      After=network.target sshd-keygen.service

      Wants=sshd-keygen.service

      [Service]

      EnvironmentFile=/etc/sysconfig/sshd

      ExecStart=/usr/sbin/sshd -D $OPTIONS

      ExecReload=/bin/kill -HUP $MAINPID

      Type=simple

      KillMode=process

      Restart=on-failure

      RestartSec=42s

      [Install]

      WantedBy=multi-user.target

  可以看到,配置文件分成几个区块,每个区块包含若干条键值对。

  下面依次解释每个区块的内容。

五、 [Unit] 区块:启动顺序与依赖关系。

  Unit区块的Description字段给出当前服务的简单描述,Documentation字段给出文档位置。

  接下来的设置是启动顺序和依赖关系,这个比较重要。

    After字段:表示如果network.target或sshd-keygen.service需要启动,那么sshd.service应该在它们之后启动。

  相应地,还有一个Before字段,定义sshd.service应该在哪些服务之前启动。

  注意,After和Before字段只涉及启动顺序,不涉及依赖关系。

  举例来说,某 Web 应用需要 postgresql 数据库储存数据。在配置文件中,它只定义要在 postgresql 之后启动,而没有定义依赖 postgresql 。上线后,由于某种原因,postgresql 需要重新启动,在停止服务期间,该 Web 应用就会无法建立数据库连接。

  设置依赖关系,需要使用Wants字段和Requires字段。

    Wants字段:表示sshd.service与sshd-keygen.service之间存在”弱依赖”关系,即如果”sshd-keygen.service”启动失败或停止运行,不影响sshd.service继续执行。

    Requires字段则表示”强依赖”关系,即如果该服务启动失败或异常退出,那么sshd.service也必须退出。

  注意,Wants字段与Requires字段只涉及依赖关系,与启动顺序无关,默认情况下是同时启动的。

六、[Service] 区块:启动行为

  Service区块定义如何启动当前服务。

  6.1 启动命令

    许多软件都有自己的环境参数文件,该文件可以用EnvironmentFile字段读取。

    EnvironmentFile字段:指定当前服务的环境参数文件。该文件内部的key=value键值对,可以用$key的形式,在当前配置文件中获取。

    上面的例子中,sshd 的环境参数文件是/etc/sysconfig/sshd。

    配置文件里面最重要的字段是ExecStart。

    ExecStart字段:定义启动进程时执行的命令。

    上面的例子中,启动sshd,执行的命令是/usr/sbin/sshd -D $OPTIONS,其中的变量$OPTIONS就来自EnvironmentFile字段指定的环境参数文件。

    与之作用相似的,还有如下这些字段。

      ExecReload字段:重启服务时执行的命令

      ExecStop字段:停止服务时执行的命令

      ExecStartPre字段:启动服务之前执行的命令

      ExecStartPost字段:启动服务之后执行的命令

      ExecStopPost字段:停止服务之后执行的命令

  请看下面的例子。

    [Service]

      ExecStart=/bin/echo execstart1

      ExecStart=

      ExecStart=/bin/echo execstart2

      ExecStartPost=/bin/echo post1

      ExecStartPost=/bin/echo post2

  上面这个配置文件,第二行ExecStart设为空值,等于取消了第一行的设置,运行结果如下。

    execstart2

    post1

    post2

  所有的启动设置之前,都可以加上一个连词号(-),表示”抑制错误”,即发生错误的时候,不影响其他命令的执行。比如,EnvironmentFile=-/etc/sysconfig/sshd(注意等号后面的那个连词号),就表示即使/etc/sysconfig/sshd文件不存在,也不会抛出错误。

6.2 启动类型

  Type字段定义启动类型。它可以设置的值如下。

simple(默认值):ExecStart字段启动的进程为主进程

forking:ExecStart字段将以fork()方式启动,此时父进程将会退出,子进程将成为主进程

oneshot:类似于simple,但只执行一次,Systemd 会等它执行完,才启动其他服务

dbus:类似于simple,但会等待 D-Bus 信号后启动

notify:类似于simple,启动结束后会发出通知信号,然后 Systemd 再启动其他服务

idle:类似于simple,但是要等到其他任务都执行完,才会启动该服务。一种使用场合是为让该服务的输出,不与其他服务的输出相混合

  下面是一个oneshot的例子,笔记本电脑启动时,要把触摸板关掉,配置文件可以这样写。

[Unit]

Description=Switch-off Touchpad

[Service]

Type=oneshot

ExecStart=/usr/bin/touchpad-off

[Install]

WantedBy=multi-user.target

  上面的配置文件,启动类型设为oneshot,就表明这个服务只要运行一次就够了,不需要长期运行。

  如果关闭以后,将来某个时候还想打开,配置文件修改如下。

[Unit]

Description=Switch-off Touchpad

[Service]

Type=oneshot

ExecStart=/usr/bin/touchpad-off start

ExecStop=/usr/bin/touchpad-off stop

RemainAfterExit=yes

[Install]

WantedBy=multi-user.target

  上面配置文件中,RemainAfterExit字段设为yes,表示进程退出以后,服务仍然保持执行。这样的话,一旦使用systemctl stop命令停止服务,ExecStop指定的命令就会执行,从而重新开启触摸板。

6.3 重启行为

  Service区块有一些字段,定义了重启行为。

  KillMode字段:定义 Systemd 如何停止 sshd 服务。

  上面这个例子中,将KillMode设为process,表示只停止主进程,不停止任何sshd 子进程,即子进程打开的 SSH session 仍然保持连接。这个设置不太常见,但对 sshd 很重要,否则你停止服务的时候,会连自己打开的 SSH session 一起杀掉。

  KillMode字段可以设置的值如下。

control-group(默认值):当前控制组里面的所有子进程,都会被杀掉

process:只杀主进程

mixed:主进程将收到 SIGTERM 信号,子进程收到 SIGKILL 信号

none:没有进程会被杀掉,只是执行服务的 stop 命令。

  接下来是Restart字段。

  Restart字段:定义了 sshd 退出后,Systemd 的重启方式。

  上面的例子中,Restart设为on-failure,表示任何意外的失败,就将重启sshd。如果 sshd 正常停止(比如执行systemctl stop命令),它就不会重启。

  Restart字段可以设置的值如下。

no(默认值):退出后不会重启

on-success:只有正常退出时(退出状态码为0),才会重启

on-failure:非正常退出时(退出状态码非0),包括被信号终止和超时,才会重启

on-abnormal:只有被信号终止和超时,才会重启

on-abort:只有在收到没有捕捉到的信号终止时,才会重启

on-watchdog:超时退出,才会重启

always:不管是什么退出原因,总是重启

  对于守护进程,推荐设为on-failure。对于那些允许发生错误退出的服务,可以设为on-abnormal。

  最后是RestartSec字段。

  RestartSec字段:表示 Systemd 重启服务之前,需要等待的秒数。上面的例子设为等待42秒。

七、[Install] 区块

Install区块,定义如何安装这个配置文件,即怎样做到开机启动。

WantedBy字段:表示该服务所在的 Target。

Target的含义是服务组,表示一组服务。WantedBy=multi-user.target指的是,sshd 所在的 Target 是multi-user.target。

这个设置非常重要,因为执行systemctl enable sshd.service命令时,sshd.service的一个符号链接,就会放在/etc/systemd/system目录下面的multi-user.target.wants子目录之中。

Systemd 有默认的启动 Target。

$ systemctl get-default

multi-user.target

上面的结果表示,默认的启动 Target 是multi-user.target。在这个组里的所有服务,都将开机启动。这就是为什么systemctl enable命令能设置开机启动的原因。

使用 Target 的时候,systemctl list-dependencies命令和systemctl isolate命令也很有用。

# 查看 multi-user.target 包含的所有服务

$ systemctl list-dependencies multi-user.target

# 切换到另一个 target

# shutdown.target 就是关机状态

$ sudo systemctl isolate shutdown.target

  一般来说,常用的 Target 有两个:一个是multi-user.target,表示多用户命令行状态;另一个是graphical.target,表示图形用户状态,它依赖于multi-user.target。官方文档有一张非常清晰的 Target 依赖关系图。

八、Target 的配置文件

  Target 也有自己的配置文件。

$ systemctl cat multi-user.target

[Unit]

Description=Multi-User System

Documentation=man:systemd.special(7)

Requires=basic.target

Conflicts=rescue.service rescue.target

After=basic.target rescue.service rescue.target

AllowIsolate=yes

  注意,Target 配置文件里面没有启动命令。

  上面输出结果中,主要字段含义如下。

Requires字段:要求basic.target一起运行。

Conflicts字段:冲突字段。如果rescue.service或rescue.target正在运行,multi-user.target就不能运行,反之亦然。

After:表示multi-user.target在basic.target 、 rescue.service、 rescue.target之后启动,如果它们有启动的话。

AllowIsolate:允许使用systemctl isolate命令切换到multi-user.target。

九、修改配置文件后重启

  修改配置文件以后,需要重新加载配置文件,然后重新启动相关服务。

# 重新加载配置文件

$ sudo systemctl daemon-reload

# 重启相关服务

$ sudo systemctl restart foobar

]]>
https://blog.huua.top/2020/12/01/536.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
Centos 8.0 安装图形化界面(超详细) https://blog.huua.top/2020/12/01/532.html https://blog.huua.top/2020/12/01/532.html#respond Tue, 01 Dec 2020 12:12:30 +0000 https://blog.huua.top/?p=532 1. 下载安装图形化界面
  • 执行命令
yum groupinstall "Server with GUI" -y
  • 安装时间较长,出现下图中情况表示安装完毕。
    在这里插入图片描述

2. 切换图形模式为默认启动方式

  • 执行命令
systemctl set-default graphical
  • 下图表示切换成功在这里插入图片描述

3.重启系统

  • 执行命令
reboot

二、VNC连接服务器

1、下载安装VNC

  • 执行命令
yum install tigervnc-server tigervnc-server-module -y
  • 下图为成功情况
    在这里插入图片描述

2、配置VNC密码

  • 执行命令
vncpasswd
  • 下图为执行后情况,一般选n即可
Password:第一次输入密码
Verify:确认密码
Would you like to enter a view-only password (y/n)?:是否创建一个只读用户

3、启动VNC服务端

  • 执行命令
vncserver

4、查看VNC服务端口

  • 执行命令
ps -aux | grep vnc
  • 如下图中 5901即为端口
    在这里插入图片描述
    注意:云服务器需要先添加5901端口在安全组中,具体请自行百度。

5、电脑使用VNC客户端连接服务器

  • 先下载VNC客户端

点击此处跳转官网下载地址

安装好之后点击下图处

2020-12-01_20-05-30.png插图(4)

按照下图配置主机名和端口

2020-12-01_20-09-19.png插图(5)

连接即可(第一次连接可视化界面,需要选择语言之类的东西下一步下一步)

设置开机自动运行vncserver

a. 在/etc/rc.d/rc.local文件中加入下面行
   /etc/init.d/vncserver start
b. 编辑/etc/sysconfig/vncservers
   VNCSERVERS=”1:root”
   VNCSERVERARGS[1]=”-geometry 1920×1200″ –配置启动的桌面
多个用户可以这样写:
VNCSERVERS= “1:user 2:user2 3:user3”


redhat系统上vnc启动命令:
/etc/init.d/vncserver start
查看vnc启动情况
netstat -tulnp
关闭服务器上自己的vnc链接
vncserver -kill :桌面号
例如:关闭上面的vnc链接
vncserver -kill :1  

]]>
https://blog.huua.top/2020/12/01/532.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
wget命令详解 https://blog.huua.top/2020/12/01/530.html https://blog.huua.top/2020/12/01/530.html#respond Tue, 01 Dec 2020 11:49:39 +0000 https://blog.huua.top/?p=530 一 wget简介

wget是linux上的命令行的下载工具。这是一个GPL许可证下的自由软件。wget支持HTTP和FTP协议,支持代理服务器和断点续传功能,能够自动递归远程主机的目录,找到合乎条件的文件并将其下载到本地硬盘上;如果必要,wget将恰当地转换页面中的超级连接以在本地生成可浏览的镜像。由于没有交互式界面,wget可在后台运行,截获并忽略HANGUP信号,因此在用户推出登录以后,仍可继续运行。通常,wget用于成批量地下载Internet网站上的文件,或制作远程网站的镜像。

二 实例

下载

1、下载192.168.1.168首页并且显示下载信息

wget -d http://192.168.1.168

2、下载192.168.1.168首页并且不显示任何信息

wget -q http://192.168.1.168

3、批量下载的情形,把所有需要下载文件的地址放到 filename.txt 中,然后 wget 就会自动为你下载所有文件了。

wget -i filelist.txt

4、下载到指定目录

wget -P/tmp ftp://user:passwd@url/file

把文件file下载到/tmp目录下。

5、下载 http://example.com 网站上 packages 目录中的所有文件。其中,-np 的作用是不遍历父目录,-nd 表示不在本机重新创建目录结构。

wget -r -np -nd http://example.com/packages/

6、仅下载 i386 目录中所有扩展名为 iso 的文件。你也可以指定多个扩展名,只需用逗号分隔即可。

wget -r -np -nd –accept=iso http://example.com/centos-5/i386/

7、断点续传

wget -c http://example.com/really-big-file.iso

8、制作网站镜像ghost

wget -m -k (-H) http://www.example.com/

三 参数

代码:

$ wget –help

GNU Wget 1.9.1,非交互式的网络文件下载工具。

用法: wget [选项]… [URL]…

长选项必须用的参数在使用短选项时也是必须的。

启动:

-V, –version 显示 Wget 的版本并且退出。

-h, –help 打印此帮助。

-b, -background 启动后进入后台操作。

-e, -execute=COMMAND 运行‘.wgetrc’形式的命令。

日志记录及输入文件:

-o, –output-file=文件 将日志消息写入到指定文件中。

-a, –append-output=文件 将日志消息追加到指定文件的末端。

-d, –debug 打印调试输出。

-q, –quiet 安静模式(不输出信息)。

-v, –verbose 详细输出模式(默认)。

-nv, –non-verbose 关闭详细输出模式,但不进入安静模式。

-i, –input-file=文件 下载从指定文件中找到的 URL。

-F, –force-html 以 HTML 方式处理输入文件。

-B, –base=URL 使用 -F -i 文件选项时,在相对链接前添加指定的 URL。

下载:

-t, –tries=次数 配置重试次数(0 表示无限)。

–retry-connrefused 即使拒绝连接也重试。

-O –output-document=文件 将数据写入此文件中。

-nc, –no-clobber 不更改已经存在的文件,也不使用在文件名后添加 .#(# 为数字)的方法写入新的文件。

-c, –continue 继续接收已下载了一部分的文件。

–progress=方式 选择下载进度的表示方式。

-N, –timestamping 除非远程文件较新,否则不再取回。

-S, –server-response 显示服务器回应消息。

–spider 不下载任何数据。

-T, –timeout=秒数 配置读取数据的超时时间 (秒数)。

-w, –wait=秒数 接收不同文件之间等待的秒数。

–waitretry=秒数 在每次重试之间稍等一段时间 (由 1 秒至指定的 秒数不等)。

–random-wait 接收不同文件之间稍等一段时间(由 0 秒至 2*WAIT 秒不等)。

-Y, –proxy=on/off 打开或关闭代理服务器。

-Q, –quota=大小 配置接收数据的限额大小。

–bind-address=地址 使用本机的指定地址 (主机名称或 IP) 进行连接。

–limit-rate=速率 限制下载的速率。

–dns-cache=off 禁止查找存于高速缓存中的 DNS。

–restrict-file-names=OS 限制文件名中的字符为指定的 OS (操作系统) 所允许的字符。

目录:

-nd –no-directories 不创建目录。

-x, –force-directories 强制创建目录。

-nH, –no-host-directories 不创建含有远程主机名称的目录。

-P, –directory-prefix=名称 保存文件前先创建指定名称的目录。

–cut-dirs=数目 忽略远程目录中指定数目的目录层。

HTTP 选项:

–http-user=用户 配置 http 用户名。

–http-passwd=密码 配置 http 用户密码。

-C, –cache=on/off (不)使用服务器中的高速缓存中的数据 (默认是使用的)。

-E, –html-extension 将所有 MIME 类型为 text/html 的文件都加上 .html 扩展文件名。

–ignore-length 忽略“Content-Length”文件头字段。

–header=字符串 在文件头中添加指定字符串。

–proxy-user=用户 配置代理服务器用户名。

–proxy-passwd=密码 配置代理服务器用户密码。

–referer=URL 在 HTTP 请求中包含“Referer:URL”头。

-s, –save-headers 将 HTTP 头存入文件。

-U, –user-agent=AGENT 标志为 AGENT 而不是 Wget/VERSION。

–no-http-keep-alive 禁用 HTTP keep-alive(持久性连接)。

–cookies=off 禁用 cookie。

–load-cookies=文件 会话开始前由指定文件载入 cookie。

–save-cookies=文件 会话结束后将 cookie 保存至指定文件。

–post-data=字符串 使用 POST 方法,发送指定字符串。

–post-file=文件 使用 POST 方法,发送指定文件中的内容。

HTTPS (SSL) 选项:

–sslcertfile=文件 可选的客户段端证书。

–sslcertkey=密钥文件 对此证书可选的“密钥文件”。

–egd-file=文件 EGD socket 文件名。

–sslcadir=目录 CA 散列表所在的目录。

–sslcafile=文件 包含 CA 的文件。

–sslcerttype=0/1 Client-Cert 类型 0=PEM (默认) / 1=ASN1 (DER)

–sslcheckcert=0/1 根据提供的 CA 检查服务器的证书

–sslprotocol=0-3 选择 SSL 协议;0=自动选择,

1=SSLv2 2=SSLv3 3=TLSv1

FTP 选项:

-nr, –dont-remove-listing 不删除“.listing”文件。

-g, –glob=on/off 设置是否展开有通配符的文件名。

–passive-ftp 使用“被动”传输模式。

–retr-symlinks 在递归模式中,下载链接所指示的文件(连至目录则例外)。

递归下载:

-r, –recursive 递归下载。

-l, –level=数字 最大递归深度(inf 或 0 表示无限)。

–delete-after 删除下载后的文件。

-k, –convert-links 将绝对链接转换为相对链接。

-K, –backup-converted 转换文件 X 前先将其备份为 X.orig。

-m, –mirror 等效于 -r -N -l inf -nr 的选项。

-p, –page-requisites 下载所有显示完整网页所需的文件,例如图像。

–strict-comments 打开对 HTML 备注的严格(SGML)处理选项。

递归下载时有关接受/拒绝的选项:

-A, –accept=列表 接受的文件样式列表,以逗号分隔。

-R, –reject=列表 排除的文件样式列表,以逗号分隔。

-D, –domains=列表 接受的域列表,以逗号分隔。

–exclude-domains=列表 排除的域列表,以逗号分隔。

–follow-ftp 跟随 HTML 文件中的 FTP 链接。

–follow-tags=列表 要跟随的 HTML 标记,以逗号分隔。

-G, –ignore-tags=列表 要忽略的 HTML 标记,以逗号分隔。

-H, –span-hosts 递归时可进入其它主机。

-L, –relative 只跟随相对链接。

-I, –include-directories=列表 要下载的目录列表。

-X, –exclude-directories=列表 要排除的目录列表。

-np, –no-parent 不搜索上层目录。

四 FQA

A.使用wget工具

linux所以的主要版本都自带了wget这个下载工具.

bash$ wget http://place.your.url/here

它还能控制ftp来下载整个web站点的各级目录,当然,如果你不小心,可能会把整个网站以及其他和他做链接的网站全部下载下来.

bash$ wget -m http://target.web.site/subdirectory

由于这个工具具有很强的下载能力,所以可以在服务器上把它用作镜像网站的工具.让它按照”robots.txt”的规定来执行.

有很多参数用来控制它如何正确地做镜像,可以限制链接的类型和下载文件的类型等等.例如:只下载有联系的链接并且忽略GIF图片:

bash$ wget -m -L –reject=gif http://target.web.site/subdirectory

wget也能够实现断点续传(-c参数),当然,这种操作是需要远程服务器支持的.

bash$ wget -c http://the.url.of/incomplete/file

可以把断点续传和镜像功能结合起来,这样可以在以前断过多次的情况下继续镜像一个有大量选择性文件的站点.如何自动实现这个目的我们在后面会讨论得更多.

如果你觉得下载时老是断线会影响你办公的话,你可以限制wget重试的次数.

bash$ wget -t 5 http://place.your.url/here

这样重试五次后就放弃了.用”-t inf”参数表示永远不放弃.不停地重试.

B.那对于代理服务该怎么办呢?

可以使用http代理的参数或者在.wgetrc配置文件里指定一个如何通过代理去下载的途径.但是有这么一个问题,如果通过代理来进行断点续传的话可能会有几次失败.如果有一次通过代理下载的过程发生中断,那么代理服务器上缓存里保存是那个完整的文件拷贝. 所以当你用”wget -c”来下载剩余部分的时候代理服务器查看它的缓存,并错误地认为你已经下载了整个文件.于是就发出了错误的信号.这个时候你可以用添加一个特定的请求参数来促使代理服务器清除他们的缓存:

bash$ wget -c –header=”Pragma: no-cache” http://place.your.url/here

这个”–header”参数能够以各种数字,各种方式添加。通过它我们可以更改web服务器或者代理服务器的某些属性。有些站点不提供外部连接的文件服务,只有通过同一个站点上其他的一些页面时内容才会被提交。这个时候你可以用加上”Referer:”参数:

bash$ wget –header=”Referer: http://coming.from.this/page” http://surfing.to.this/page

有些特殊的网站只支持某种特定的浏览器,这个时候可以用”User-Agent:”参数

bash$ wget –header=”User-Agent: Mozilla/4.0 (compatible; MSIE 5.0;Windows NT; DigExt)” http://msie.only.url/here

C.那我怎么设定下载时间呢?

如果你需要在你的办公电脑上通过和其他同事共享的一个连接来下载一些很大的文件,而且你希望你的同事不会因为网络速度的减慢而收到影响,那你就应该尽量避开高峰时段。当然,不需要在办公室里等到所以人都走掉,也不需要在家里用完晚饭后还惦记着要上网下载一次。

用at来就可以很好的定制工作时间:

bash$ at 23:00

warning: commands will be executed using /bin/sh

at> wget http://place.your.url/here

at> press Ctrl-D

这样,我们设定了下载工作在晚上11点进行。为了使这个安排能够正常进行,请确

认atd这个后台程序正在运行。

D.下载要花很多时间?

当你需要下载大量的数据,而且你又没有享有足够的带宽,这个时候你会经常发现在你安排的下载任务还没有完成,一天的工作却又要开始了。

作为一个好同事,你只能停掉了这些任务,而开始另外的工作。然后你又需要反复地重复使用”wget -c”来完成你的下载。这样肯定太繁琐了,所以最好是用crontab来自动执行。创建一个纯文本文件,叫做”crontab.txt”,包含下面的内容:

0 23 * * 1-5 wget -c -N http://place.your.url/here

0 6 * * 1-5 killall wget

这个crontab文件指定某些任务定期地执行。前五列声明是什么时候执行这个命令,而每行的剩余部分则告诉crontab执行什么内容。

前两列指定了每天一到晚上11点就开始用wget下载,一到早上6点就停止一切wget下载。第三四列的*表示每个月的每一天都执行这个任务。第五列则指定了一个星期的哪几天来执行这个程序。 –”1-5″表示从星期一到星期五。

这样在每个工作日的晚上11点,下载工作开始,到了上午的6点,任何的wget任务就被停掉了。你可以用下面的命令来执行crontab:bash$ crontab crontab.txt

wget的这个”-N”参数将会检查目标文件的时间戳,如果匹配了,下载程序就会停止,因为它说明整个文件已经下载完全了。

用”crontab -r”可以删除这个计划安排。我已经多次采用这种方法,通过共享的电话拨号来下载过很多的ISO镜像文件,还是比较实用的。

E.如何下载动态变化的网页

有些网页每天都要根据要求变化好几次.所以从技术上讲,目标不再是一个文件,它没有文件长度.因此”-c”这个参数也就失去了意义.

例如:一个PHP写的并且经常变动的linux周末新闻网页:

bash$ wget http://lwn.net/bigpage.php3

我办公室里的网络条件经常很差,给我的下载带了很大的麻烦,所以我写了个简单的脚本来检测动态页面是否已经完全更新了.

#!/bin/bash

#create it if absent

touch bigpage.php3

#check if we got the whole thing

while ! grep -qi bigpage.php3

do

rm -f bigpage.php3

#download LWN in one big page

wget http://lwn.net/bigpage.php3

done

这个脚本能够保证持续的下载该网页,直到网页里面出现了” “,这就表示该文件已经完全更新了.

F.对于ssl和Cookies怎么办?

如果你要通过ssl来上网,那么网站地址应该是以”https://”来开头的.在这样的情况下你就需要另外一种下载工具,叫做curl,它能够很容易获得.有些网站迫使网友在浏览的时候必须使用cookie.所以你必须从在网站上得到的那个 Cookie里面得到”Cookie:”这个参数.这样才

能保证下载的参数正确.对于lynx和Mozilla的Cookie的文件格式,用下面的:

bash$ cookie=$( grep nytimes ~/.lynx_cookies |awk {printf(”%s=%s;”,$6,$7)} )

就可以构造一个请求Cookie来下载http://www.nytimes.com上的内容.当然,你要已经用这个浏览器在该网站上完成注册.

w3m使用了一种不同的,更小巧的Cookie文件格式:

bash$ cookie=$( grep nytimes ~/.w3m/cookie |awk {printf(”%s=%s;”,$2,$3)} )

现在就可以用这种方法来下载了:

bash$ wget –header=”Cookie: $cookie” http://www.nytimes.com/reuters/technology/tech-tech-supercomput.html

或者用curl工具:

bash$ curl -v -b $cookie -o supercomp.html http://www.nytimes.com/reuters/technology/tech-tech-supercomput.htm

G.如何建立地址列表?

到现在为止我们下载的都是单个文件或者是整个网站.有的时候我们需要下载某个网页上链接的大量文件,但没有必要把它整个网站都镜像下来.比如说我们想从一个依次排列的100首歌里面下载前20首.注意,这里”–accept”和”–reject”参数是不会起作用的, 因为他们只对文件操作起作用.所以一定要用”lynx -dump”参数来代替.

bash$ lynx -dump ftp://ftp.ssc.com/pub/lg/ |grep gz$ |tail -10 |awk {print $2} > urllist.txt

lynx的输出结果可以被各种GNU文本处理工具过虑.在上面的例子里,我们的链接地址是以”gz”结尾的,并且把最后10个文件地址放到urllist.txt文件里.然后我们可以写一个简单的bash脚本来自动下载这个文件里的目标文件:

bash$ for x in $(cat urllist.txt)

> do

> wget $x

> done

这样我们就能够成功下载Linux Gazette网站(ftp://ftp.ssc.com/pub/lg/)上的最新10个论题.

H.扩大使用的带宽

如果你选择下载一个受带宽限制的文件,那你的下载会因为服务器端的限制而变得很慢.下面这个技巧会大大缩短下载的过程.但这个技巧需要你使用curl并且远程服务器有多个镜像可以供你下载.例如,假设你想从下面的三个地址下载Mandrake 8.0:

url1=http://ftp.eecs.umich.edu/pub/linux/mandrake/iso/Mandrake80-inst.iso

url2=http://ftp.rpmfind.net/linux/Mandrake/iso/Mandrake80-inst.iso

url3=http://ftp.wayne.edu/linux/mandrake/iso/Mandrake80-inst.iso

这个文件的长度是677281792个字节,所以用curl程序加”–range”参数来建立三个同时进行的下载:

bash$ curl -r 0-199999999 -o mdk-iso.part1 $url1 &

bash$ curl -r 200000000-399999999 -o mdk-iso.part2 $url2 &

bash$ curl -r 400000000- -o mdk-iso.part3 $url3 &

这样就创建了三个后台进程.每个进程从不同的服务器传输这个ISO文件的不同部分.这个”-r”参数指定目标文件的字节范围.当这三个

进程结束后,用一个简单的cat命令来把这三个文件衔接起来– cat mdk-iso.part? > mdk-80.iso.(强烈建议在刻盘之前先检查md5)

你也可以用”–verbose”参数来使每个curl进程都有自己的窗口来显示传输的过程.

]]>
https://blog.huua.top/2020/12/01/530.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
阿里云服务器安装Ubuntu图形化界面 https://blog.huua.top/2020/11/26/528.html https://blog.huua.top/2020/11/26/528.html#respond Thu, 26 Nov 2020 08:32:56 +0000 https://blog.huua.top/?p=528 升级系统

sudo apt-get update
sudo apt-get upgrade

安装经典桌面环境 Gnome 桌面

sudo apt-get install ubuntu-desktop
sudo apt-get install gnome

2、自定义安装桌面

sudo apt-get install x-window-system-core
sudo apt-get install gnome-core
sudo apt-get install language-pack-gnome-zh-hant
sudo apt-get install scim
sudo apt-get install gdm
sudo apt-get install synaptic

3 Linux Mint 的桌面环境系统 Cinnamon 3.0

sudo apt-get install –no-install-recommends ubuntu-desktop
sudo add-apt-repository ppa:embrosyn/cinnamon
sudo apt update
sudo apt install cinnamon

4 配置root登陆权限

1、默认情况是不允许用root帐号直接登录图形界面的。这可以通过修改 vim/usr/share/lightdm/lightdm.d/50-ubuntu.conf 文件来允许root直接登录,增加
greeter-show-manual-login=true allow-guest=false .

2、登录之后会每次弹一个小错误
,/root/.profile文件中将 mesg n||true 修改为 tty -s && mesg n ||true
更多参阅和通数据库服务器实践文档

]]>
https://blog.huua.top/2020/11/26/528.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
frp实现内网穿透,进行远程桌面和http访问 https://blog.huua.top/2020/10/29/523.html https://blog.huua.top/2020/10/29/523.html#respond Thu, 29 Oct 2020 09:08:17 +0000 https://blog.huua.top/?p=523 使用frp内网穿透工具使处于内网中的电脑能够像访问公网电脑一样方便,比如将公司或个人电脑里面的web项目让别人能够访问以便于自己及时修改,或者是进行远程或ssh连接。能够实现内网穿透的还有花生壳,ngrok等,但frp使用起来更加简便灵活,以及项目一直开源,所以本文选择frp作为示例。官方(项目地址)介绍为:

frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp, udp, http, https 协议。

数据准备:

  • 公网IP: X.X.X.X
  • 内网IP: 192.168.1.101
  • 映射到公网的域名:xxx.com

本文中内网电脑使用的是win7系统,公网电脑为linux系统。

1. 服务端配置

1.1 文件下载

具有公网IP的电脑将作为frp服务端(frps),首先去项目地址的releases页面下载与服务端系统匹配的文件并解压,并且可以删除客户端相关的文件(frpc文件夹,frpc.ini,frpc_full.ini).

5990755-ceb72b6bd01ba9b1.png插图
1.2 编辑配置文件

编辑frps.ini为以下内容:

[common]
bind_port = 7000
vhost_http_port = 8080

bind_port为客户端与服务端进行通信的端口,vhost_http_port为服务端http服务的端口。其它更丰富的配置可参考frps_full.ini和项目帮助文档。

1.3 启动服务端

进行到解压后的frp目录,然后通过./frps -c frps.ini命令即可启动服务端,如下图所示:

5990755-c6fec2ea7352f900.png插图(1)
1.4 设置开机启动和后台运行

上一步中的frps占据了整个命令窗口,所以接下来要考虑如何让它在后台运行并且开机自启:
首先通过vi /etc/systemd/system/frps.service命令新建文件并写入以下内容:

[Unit]
Description=frps daemon
After=syslog.target  network.target
Wants=network.target

[Service]
Type=simple
ExecStart=/usr/frp/frp_0.16.0_linux_386/frps -c /usr/frp/frp_0.16.0_linux_386/frps.ini
Restart= always
RestartSec=1min

[Install]
WantedBy=multi-user.target

注意ExecStart中要配置成自己的路径.
然后使用systemctl start frps即可启动frps, 用systemctl enable frps即可将frps设置为开机启动。

2. 客户端配置

2.1 文件下载

具有内网IP的电脑将作为客户端(frpc), 本文中客户端使用的是win7 64位系统,所以在releases页面下载frp_0.16.0_windows_amd64.zip解压,删除与服务端相关的文件(frps文件夹,frps.ini,frps_full.ini)

2.2 编辑配置文件

编辑frpc.ini为以下内容:

[common]
server_addr = X.X.X.X
server_port = 7000

[RDP]
type = tcp
local_ip = 0.0.0.0
local_port = 3389
remote_port = 6000

[web]
type = http
local_port = 8080
custom_domains = xxx.com

注意sever_addr配置为公网电脑的IP,server_port与frps.ini中的bind_port一致。RDP为远程桌面的配置,web为http通信的配置。web中的custom_domains为绑定到公网IP的域名。

2.3 启动服务端

双击frpc.exe或者用命令 frpc -c frpc.ini即可启动客户端,如下图所示:

5990755-1f2b2eef51c39f56.png插图(2)

随后我们就可以在服务端的命令窗口看到客户端的连接信息,如下所示:

5990755-3473d1e00cf2262f.png插图(3)
2.4 设置开机启动和后台运行

同样的道理,我们也需要对客户端设置后台运行和开机自启。借助 winsw 工具可以将frpc注册为windows系统中的服务。
下载winsw最新版,为了方便将其重命名为winsw.exe, 将该文件和frpc.exe放在一起,然后新建winsw.xml写入以下内容:

<service>
    <id>frp</id>
    <name>frp</name>
    <description>用frp发布本地电脑网站到外网</description>
    <executable>frpc</executable>
    <arguments>-c frpc.ini</arguments>
    <logmode>reset</logmode>
</service>

然后使用winsw installfrpc start命令即可将frpc安装为系统服务。
win+r后通过services.msc进入到服务列表页面找到frp服务。

5990755-e2077fe9512c8ca6.png插图(4)

为了确保frpc在连接失败后自动尝试重新连接,在恢复tap页进行如下设置:

5990755-87c0941ef5c495fc.png插图(5)

3. 效果演示

3.1 远程桌面

首先要开启桌面远程连接,配置如下

5990755-39af677f9701b14b.png插图(6)

在随意一台其它电脑上使用win+r然后 mstsc进入远程桌面连接使用通过域名或外网IP加端口即可成功进行远程桌面连接到内网中的机器。

5990755-a0112ba80e7c9fc6.png插图(7)
3.2 http远程访问

在客户端本地启动一个web项目后,然后随意一台电脑上使用域名加端口即可访问内网中的web项目。

5990755-7ae2c76ecdb68e45.png插图(8)

问题记录

  • 检查是否关闭服务端防火墙或者是开启要用到的端口
  • 域名映射是否正确,检查能不能ping得通域名(域名前面不要忘了www)

作者:Acamy丶
链接:https://www.jianshu.com/p/a6e9627dbe29
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

]]>
https://blog.huua.top/2020/10/29/523.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1
Linux中的screen命令使用 https://blog.huua.top/2020/10/29/515.html https://blog.huua.top/2020/10/29/515.html#respond Thu, 29 Oct 2020 08:41:56 +0000 https://blog.huua.top/?p=515 1、简介

Screen是一款由GNU计划开发的用于命令行终端切换的自由软件。用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换。GNU Screen可以看作是窗口管理器的命令行界面版本。它提供了统一的管理多个会话的界面和相应的功能。

在Screen环境下,所有的会话都独立的运行,并拥有各自的编号、输入、输出和窗口缓存。用户可以通过快捷键在不同的窗口下切换,并可以自由的重定向各个窗口的输入和输出。

2、语法

$> screen [-AmRvx -ls -wipe][-d <作业名称>][-h <行数>][-r <作业名称>][-s ][-S <作业名称>] -A  将所有的视窗都调整为目前终端机的大小。-d   <作业名称>  将指定的screen作业离线。-h   <行数>  指定视窗的缓冲区行数。-m  即使目前已在作业中的screen作业,仍强制建立新的screen作业。-r   <作业名称>  恢复离线的screen作业。-R  先试图恢复离线的作业。若找不到离线的作业,即建立新的screen作业。-s  指定建立新视窗时,所要执行的shell。-S   <作业名称>  指定screen作业的名称。-v  显示版本信息。-x  恢复之前离线的screen作业。-ls或--list  显示目前所有的screen作业。-wipe  检查目前所有的screen作业,并删除已经无法使用的screen作业。

3、常用screen参数

screen -S yourname -> 新建一个叫yourname的sessionscreen -ls         -> 列出当前所有的sessionscreen -r yourname -> 回到yourname这个sessionscreen -d yourname -> 远程detach某个sessionscreen -d -r yourname -> 结束当前session并回到yourname这个session

4、在Session下,使用ctrl+a(C-a) 

C-a ? -> 显示所有键绑定信息C-a c -> 创建一个新的运行shell的窗口并切换到该窗口C-a n -> Next,切换到下一个 window C-a p -> Previous,切换到前一个 window C-a 0..9 -> 切换到第 0..9 个 windowCtrl+a [Space] -> 由视窗0循序切换到视窗9C-a C-a -> 在两个最近使用的 window 间切换 C-a x -> 锁住当前的 window,需用用户密码解锁C-a d -> detach,暂时离开当前session,将目前的 screen session (可能含有多个 windows) 丢到后台执行,并会回到还没进 screen 时的状态,此时在 screen session 里,每个 window 内运行的 process (无论是前台/后台)都在继续执行,即使 logout 也不影响。 C-a z -> 把当前session放到后台执行,用 shell 的 fg 命令则可回去。C-a w -> 显示所有窗口列表C-a t -> time,显示当前时间,和系统的 load C-a k -> kill window,强行关闭当前的 windowC-a [ -> 进入 copy mode,在 copy mode 下可以回滚、搜索、复制就像用使用 vi 一样    C-b Backward,PageUp     C-f Forward,PageDown     H(大写) High,将光标移至左上角     L Low,将光标移至左下角     0 移到行首     $ 行末     w forward one word,以字为单位往前移     b backward one word,以字为单位往后移     Space 第一次按为标记区起点,第二次按为终点     Esc 结束 copy mode C-a ] -> paste,把刚刚在 copy mode 选定的内容贴上

5、常用操作

创建会话(-m 强制):

screen -dmS session_name# session_name session名称

关闭会话:

screen -X -S [session # you want to kill] quit

查看所有会话:

screen -ls

进入会话:

screen -r session_name
]]>
https://blog.huua.top/2020/10/29/515.html/feed 0
Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1

Warning: chmod(): No such file or directory in /www/wwwroot/huua.top/wp-includes/plugin.php(446) : runtime-created function on line 1