About UNIX and other opensource technology.
按网段ping主机返回在线状态
通过以下命令,可以按网段ping所有的主机,并返回那些ip状态为在线,前提是安装nmap
命令: nmap -sP 220.181.38.0/24
运行结果如下:
➜ ~ nmap -sP 220.181.38.0/24 Starting Nmap 6.40 ( http://nmap.org ) at 2021-06-26 11:27 CST Nmap scan report for 220.181.38.97 Host is up (0.16s latency). Nmap scan report for 220.181.38.98 Host is up (0.16s latency). Nmap scan report for 220.181.38.99 Host is up (0.18s latency). Nmap scan report for 220.181.38.129 Host is up (0.16s latency). Nmap scan report for 220.181.38.130 Host is up (0.16s latency).…
显示当前使用的网络接口
$ ip addr | awk '/state UP/ {print $2}' | sed 's/.$//'
输出结果
eth0
eth1 …
将时间从纪元格式转换为ISO格式
printf '%(%FT%T)T\n' 1606752450
无需perl, awk, 或 /usr/bin/date,bash内置"printf"函数就能搞定。
输出
2020-11-30T11:07:30…
Ubuntu21.04安装Gnome40
ubuntu21.04可以通过PPA源的方法安装gnome40,方法如下:
sudo add-apt-repository ppa:shemgp/gnome-40 #添加PPA源 sudo apt install mutter gnome-shell sudo apt upgrade 安装完成后重启系统,在会话选择中选择GNOME即可进入。
删除GNOME方法如下:
sudo apt install ppa-purge && sudo ppa-purge ppa:shemgp/gnome-40 sudo apt remove gnome-session …
v2rayA客户端使用实例
v2rayA是一款Project V的Linux Web GUI客户端,支持V2Ray,Xray,SS,SSR,Trojan和Pingtunnel
安装v2rayA之前需要先安装v2ray,命令如下:
➜ ~ curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh #下载安装脚本 ➜ ~ bash ./install-release.sh #运行安装脚本 ➜ ~ sudo systemctl enable v2ray #开启v2ray service Created symlink /etc/systemd/system/multi-user.target.wants/v2ray.service → /etc/systemd/system/v2ray.service. ➜ ~ sudo systemctl start v2ray 运行v2ray service ubuntu中安装v2rayA ubuntu下可以使用添加sources.list源来安装v2rayA
➜ ~wget -qO - https://apt.v2raya.mzz.pub/key/public-key.asc | sudo apt-key add - #添加public key ➜ ~echo "deb https://apt.v2raya.mzz.pub/ v2raya main" | sudo tee /etc/apt/sources.list.d/v2raya.list #添加apt源 ➜ ~sudo apt update #更新源 ➜ ~ sudo apt install v2raya #安装V2RayA 正在读取软件包列表.…
通过批处理控制网卡接口
将内网网卡名改为"lan",将外网网卡名改为"wlan"
REM copyright unixetc.com @echo off set /p input=a:内网/b:外网/c:禁用/d:开启 if "%input%"=="a" goto MA if "%input%"=="b" goto MB if "%input%"=="c" goto MC if "%input%"=="d" goto MD if not "%input%"== "a" (if not "%input%"=="b"(if not "%input%"=="c" (if not "%input%"=="d" goto ME))) :MA echo 单开内网 netsh interface set interface "lan" enabled netsh interface set interface "wlan" disabled ping 133.64.8.1 -n 10 echo 设置完成! pause>nul exit :MB echo 单开外网 netsh interface set interface "lan" disabled netsh interface set interface "wlan" enabled ping baidu.…
文本加密和猴子分桃
两道编程小题:
1、某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换。
#include <iostream> using namespace std; int main () { int n[ 4 ]= {3,5,7,9}; int p[4]={0,0,0,0 }; int jh =0 ; for (int c=0;c<4;c++) { p[c]=(n[c]+5)%10; } jh=p[0];p[0]=p[3];p[3]=jh; jh=p[1];p[1]=p[2];p[2]=jh; cout<<endl<<"Encrypted Code: "; for ( int j = 0; j < 4; j++ ) { cout << p[ j ] ; } return 0; } 2、海滩上有一堆桃子,五只猴子来分。第一只猴子把这堆桃子平均分为五份,多了一个,这只猴子把多的一个扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了一个,它同样把多的一个扔入海中,拿走了一份,第三、第四、第五只猴子都是这样做的,问海滩上原来最少有多少个桃子?
#include <iostream> using namespace std; int main() { int s, l, t,i; l = 1; for (i=1; i<5; i++) l *= 5; s = 1+5*(l-1); t = s; for (i=1; i<=4; i++) t = (t-1)/5*4; cout<<s<<endl; return 0; } …
JingOS试用体验
JingOS-全球首个基于ARM架构,专为平板打造的Linux。
此次为虚拟机安装试用体验,虚拟机配置如下:
LiveCD系统体验 磁盘检查&引导加载
欢迎界面
默认的PIN为123456
锁屏界面,上划解锁
home页,底部为dash区域
左上角下滑为通知区,右上角下滑为快速设置区
快捷截图以及完成提示
蓝牙设置
显示设置
系统信息
账户设置
移动网络设置
时间日期设置
虚拟键盘设置
终端程序
软件管理器
安装JingOS到本地磁盘 打开终端输入以下命令开始安装
sudo -E calamares 按照提示一步步安装完成即可重启使用。…
将Hugo站点部署到Cloudflare Pages
建立Hugo站点 参考使用hugo建立静态个人网站,将新建的站点push到github上。
设置Cloudflare Pages 登录https://dash.cloudflare.com/,打开Cloudflare Pages,点击Get started开始设置。
点击创建项目
接下来选择存储库,通过gihub账户授权后,选择账户下的hugo存储库,点击开始设置
进入设置构建和部署,参考下图设置好后点击保存并部署开始部署。
以下为一次部署成功的详细信息,点击其中的二级域名即可浏览。
构建日志如下:
20:05:17.479 Initializing build environment 20:05:44.784 Finished 20:05:44.784 Cloning repo 20:05:48.384 Finished 20:05:49.122 Installing dependencies 20:05:49.165 Python version set to 2.7 20:05:52.705 v12.18.0 is already installed. 20:05:53.071 Now using node v12.18.0 (npm v6.14.4) 20:05:53.092 Started restoring cached build plugins 20:05:53.103 Finished restoring cached build plugins 20:05:53.594 Attempting ruby version 2.7.1, read from environment 20:05:54.935 Using ruby version 2.7.1 20:05:55.260 Using PHP version 5.…
使用hugo建立静态个人网站
安装Hugo Hugo程序可以从这里下载
Windows建议下载hugo_extended_0.81.0_Windows-64bit.zip,其他系统可下载对应版本。
另,CentOS安装hugo可参考此文
使用hugo 首先使用hugo new test来建立新的站点。
$ hugo new site test Congratulations! Your new Hugo site is created in D:\test. Just a few more steps and you're ready to go: 1. Download a theme into the same-named folder. Choose a theme from https://themes.gohugo.io/ or create your own with the "hugo new theme <THEMENAME>" command. 2. Perhaps you want to add some content. You can add single files with "hugo new <SECTIONNAME>\<FILENAME>.…