Linux Bash Shell 探究
本篇文章参考自:
https://mp.weixin.qq.com/s/rmUXqYulX3pyrNfINk90WQ
https://ixyzero.com/blog/archives/2070.html
https://www.maoyingdong.com/what_is_a_login_shell_and_a_non_login_shell/
https://www.maoyingdong.com/what_is_a_interactive_shell/
https://www.maoyingdong.com/linux_bash_environment_file/
Linux 也算是用了好几年了吧,Shell(主要是 Bash、Zsh)也一直在用,之前其实看到过交互式 Shell、非交互式 Shell、登录 Shell 的内容,但当时什么都不懂,理解也不深,只是脑子里留下了一个印象而已;
现在无意中又碰到了这个话题,作为一个知识的奴隶,补充一下这方面的知识。
注:实验环境为 - CentOS 7 - Bash
Login & Non-Login
经常看 ...
Windows 远程访问服务搭建
有时候学生也会遇到安装方面的问题,避免意外写份文档,方便上课用。
双网卡配置
前情提要:
VMware Workstation 17 Pro
VMnet8 - 代表局域网
VMnet0 - 代表公网
Windows Server 2016(出口网关)
VMnet8 - 10.10.8.140
VMnet0 - 192.168.0.102
Windows 10(内网服务器)
VMnet8 - 10.10.8.138
由于需要配置 Windows NAT 服务器,没两张网卡怎么行,根据如下图进行网卡添加:
远程访问服务安装
点击服务器管理器,选中仪表板,点击添加角色和功能:
进入添加角色和功能向导,可选勾选默认情况下将跳过此页,点击下一步:
由于是在本地安装,选择基于角色或基于功能的安装,点击下一步:
默认即可,点击下一步:
选择安装 远程访问,点击下一步:
默认即可,点击下一步:
默认即可,点击下一步:
默认即可,点击下一步:
选择安装路由:
默认即可,点击下一步:
注:可能有人发现了,怎么还要 ...
Linux 特殊权限位说明
在复杂多变的生产环境中,单纯设置文件的 rwx 权限无法满足我们对安全和灵活性的需求,因此便有了 SUID、SGID 与 SBIT 的特殊权限位。这是一种对文件权限进行设置的特殊功能,可以与一般权限同时使用,以弥补一般权限不能实现的功能。
SUID
SUID(Set User ID)是一种权限机制,通常用于 UNIX 和类 UNIX 系统中。它允许用户在执行特定程序时暂时获取该程序所有者的权限,而不是执行者的权限。这对于一些需要特殊权限才能完成的任务非常有用,例如修改系统文件或执行特定的系统命令。
特点如下:
SUID 权限仅对二进制可执行文件有效;
如果执行者对于该二进制可执行文件具有 x 的权限,执行者将具有该文件的所有者的权限;
本权限仅在执行该二进制可执行文件的过程中有效;
SUID 在权限位置有两种显示方式:
当命令所属用户具有 x 执行权限时为:s;
当命令所属用户不具有 x 执行权限时为:S。
123┌──(root㉿kali)-[~]└─# ls -l /usr/bin/passwd -rwsr-xr-x 1 root root 68 ...
Windows DHCP 搭建
有时候学生也会遇到安装方面的问题,避免意外写份文档,方便上课用。
由于步骤是真的多,所以有些地方省略了,具体看我上课演示吧(我累了,毁灭吧)。
取消 DHCP 服务
这里使用的是 NAT 网卡,但是在 VMware Workstation 中默认网卡都是会开启 DHCP 服务的,容易与我们配置 DHCP 服务器造成冲突,这里直接取消 NAT 网卡的 DHCP 服务即可:
静态 IP 配置
前情提要:
VMware Workstation 17 Pro
Windows Server 2016 - 10.10.8.254
DHCP 地址池范围:10.10.8.1~10.10.8.254
首先将服务器的 IP 地址设置为静态IP地址,如果不设置为静态 IP 地址,服务器一旦重启,所部署的服务就有可能无法使用或者是无法访问:
配置成功后,判断网络联通性及 DNS 服务器配置:
DHCP 服务器安装
点击服务器管理器,选中仪表板,点击添加角色和功能:
进入添加角色和功能向导,可选勾选默认情况下将跳过此页,点击下一步:
由于是在本地安装,选择基于角色或基于功能 ...
Linux 安装宝塔面板
最近也是在上课,需要用到宝塔面板,怕有时候学生也会遇到安装方面的问题,避免意外写份文档,方便上课用。
前情提要
VMware Workstation 17 Pro
虚拟机:Ubuntu 18.04
注:这里没有使用云服务器哦。
安装宝塔
宝塔 Linux 面板是提升运维效率的服务器管理软件,支持一键 LAMP/LNMP/ 集群 / 监控 / 网站 / FTP / 数据库 / JAVA 等 100 多项服务器管理功能。
宝塔支持的 Linux 系统如下:
1Centos-7、Centos-8、Debian10、Debian11、Debian12、Ubuntu18、Ubuntu20、Ubuntu22......
宝塔官网:https://www.bt.cn/new/index.html
由于此处我用的是 Ubuntu,安装命令如下(记得一定要是纯净系统):
1wget -O install.sh https://download.bt.cn/install/install-ubuntu_6.0.sh & ...
Windows DNS 搭建
由于有时候学生也会遇到安装方面的问题,避免意外写份文档,方便上课用。
由于步骤是真的多,所以有些地方省略了,具体看我上课演示吧(我累了,毁灭吧)。
DNS 服务安装(单个)静态 IP 配置
前情提要:
VMware Workstation 17 Pro
Windows Server 2016 - 10.10.8.140
VMware Tools
由于这里并没有配置 DHCP 服务器,DNS 服务器 IP 地址不固定。同样的 Windows Server 作为 DNS 服务器也需要固定其 IP,避免重启后 IP 地址变化导致的 DNS 解析失效。
配置成功后,判断网络联通性及 DNS 服务器配置:
点击服务器管理器,选中仪表板,点击添加角色和功能:
进入添加角色和功能向导,可选勾选默认情况下将跳过此页,点击下一步:
由于是在本地安装,选择基于角色或基于功能的安装,点击下一步:
默认即可,点击下一步:
选择安装 DNS 服务器,点击下一步:
默认即可,点击下一步:
点击下一步:
默认即可,点击下一步:
默认即可,点击下 ...
语雀防盗链问题解决
最近也是遇到了语雀图片上传阿里 OSS 报错的问题,找了一个大佬的工具感觉不错,简单修改一下代码。
原版工具地址(感谢大佬):https://github.com/misaki7in/yuque
新版工具地址(fork):https://github.com/Y0n9zh/yuque_convert
Tool introduction
语雀导出的 Markdown 格式的文档,无法利用 Hexo、CSDN 对其渲染。主要是因为语雀含有防盗链机制,导致图片无法加载上传。
该脚本可以批量获取语雀中 Markdown 中的图片链接,将其自动下载到脚本的同级目录的 image 目录下,并生成新的 md 文档,替换掉原有的图片链接。
注:替换图片链接的功能需要自己将下载后的图片上传至指定图床(OSS),或者自己的 Web 服务器上,并且文件名称不要改变,本工具不会自动帮你上传文件。
Tool use
注:Python 版本使用的是 Python 3。
安装 Python 运行库:
1pip install -r requirements.txt -i https://mirror ...
OpenWRT 安装
之前搭了个 OPNsense,后悔了,感觉不是很好用,换一个之前用过的 OpenWRT 吧,整体功能简洁方便一些。
虽然 OpenWRT 的主要功能是当作软路由使用,但是他的防火墙、NAT、DHCP 功能还是挺人性化的。
参考文章:
https://www.smianao.com/561.html
https://zhuanlan.zhihu.com/p/642643603?utm_id=0
https://www.jamesdailylife.com/openwrt-passwall
https://www.bilibili.com/read/cv21216012/
前期准备工作
VMware Workstation 17 Pro
OpenWRT
StarWindConverter
Xshell
OpenWRT 介绍
OpenWrt 是一个嵌入式设备的 Linux 发行版,以 GPL 许可协议发行。
OpenWrt 系统高度模块化、高度自动化,支持各种处理器架构。无论是对 ARM、X86、PowerPC 或者 MIPS 都有很好的支持。其多达 3000 多种软件包 ...
OPNsense 安装
最近整理网络内容,备到网络部分防火墙那总感觉少点什么,正好市面上这么多防火墙,搭一个给学生玩一玩。
参考文章:
https://gitee.com/callmer/opnsense_toss_notes/tree/main(主要,感谢大佬)
https://blog.51cto.com/u_13298188/5730109
前期工作准备
OPNsense 是基于 FreeBSD 的开源防火墙系统,可以在虚拟化环境或物理机上安装部署。
访问 OPNsense 官网的下载页面 ,下载最新的 OPNsense 镜像文件,并找到镜像文件对应的校验信息。
需要注意的是:
Architecture 选择amd64;
Select the image type选择dvd;
Mirror Location选择Peking University,即北京大学镜像站;
Checksum verification即镜像文件的校验信息。
OPNsense 镜像默认为.bz2压缩格式,因此下载完成并校验文件信息后,需要将镜像的 ISO 文件解压出来。
大佬这里使用的 ...
Hexo 部署到 aliyun
之前个人所有笔记都是放在语雀上,主要除了学生也没啥人看,后面接触多了感觉写写博客好像也蛮不错的。
陆陆续续也搭建过 WordPress 和 Hexo 再三权衡(拖了半年)最后还是选择了 Hexo,并将 Hexo 博客托管在了 GitHub 上并绑定了 yongz.icu 这个域名(现在不用了)。
但总所周知 GitHub 由于某些原因在国内访问速度极慢,hexo deploy 慢的一匹。最后还是下定决心买了阿里云服务器,然后将 Hexo 博客部署到云服务器上,顺便绑个新域名。
本文来自 koenli 大佬:https://www.koenli.com/bda2f0d3.html
服务器配置
CPU
内存
操作系统
Git
Web
2 核
2G
CentOS 7.6
yum install
宝塔
CPU/内存:由于 Hexo 是静态博客,不需要多高的配置,1 核 1G 都是随便带(访问量贼大当我没说)。
操作系统:这里我必须要吐槽,Ubuntu 为什么不行,我装了三遍都不行,最终认命装了 CentOS 7.3 就可以了(我敲)。
Git:大佬博客上写的是 ...