选中桌面中的计算机图标,右键,点击管理
系统工具
本地用户和组
用户
选中Administrator,然后重命名
重启电脑
win+r 打开运行
输入 gpedit.msc 打开策略组
计算机配置
windows设置
安全设置
本地策略
安全选项
拉到最下面
双击这个选选项 重命名系统管理员帐户
重启电脑
win+r 打开运行
输入 netplwiz
选中Administrator,然后双击,然后修改
重启电脑
win+r 打开运行
输入 gpedit.msc 打开策略组
计算机配置
windows 设置
安全设置
本地策略
安全选项
拉到最下面
禁用 使用空密码的本地账户只允许控制台登录
电脑提示“账户名与安全标识间无任何映射完成” 一般是修改玩用户名后没有重启导致的。
因为公司的电脑不能设密码,同时我又想远程桌面公司的电脑,考虑到安全问题,不能用默认用户名裸奔,所以修改用户名和设置无密码的远程桌面
python -m pip install shadowsocks
# 如果上面那句下载失败,可以尝试用这句安装
python -m pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U
# 如果上面那句还是下载失败,可以尝试先把 master.zip 文件下载到本地,再安装
ssserver -p 61813 -k windows@163.qq -m aes-256-cfb
-p 是端口号
-k 是密码
-m 是加密方式
上面那条命令需要在 服务器的策略组 和 防火墙 放行 61813 端口
https://download.libsodium.org/libsodium/releases/
python -m pip install --upgrade shadowsocks
# 如果上面那句更新失败,可以尝试这样更新,先卸载再重新安装,卸载前记得先备份当前的版本
python -m pip show shadowsocks
python -m pip uninstall shadowsocks
python -m pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U
https://github.com/shadowsocks/shadowsocks/wiki/Shadowsocks-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E
Visual Studio 6.0 | VC6 |
Visual Studio .NET 2002 | VC7.0 |
Visual Studio .NET 2003 | VC7.1 |
Visual Studio 2005 | VC8 |
Visual Studio 2008 | VC9 |
Visual Studio 2010 | VC10 |
Visual Studio 2012 | VC11 |
Visual Studio 2013 | VC12 |
Visual Studio 2015 | VC14 |
Visual Studio 2017 | VC15 |
Visual Studio 2019 | VS16 |
Visual Studio 2022 | VS17 |
5.2 | vc6 |
5.3 | vc9 |
5.4 | vc9 |
5.5 | vc11 |
5.6 | vc11 |
7.0 | vc14 |
7.1 | vc14 |
7.2 | vc15 |
7.3 | vc15 |
7.4 | vc15 |
8.0 | vs16 |
使用 Windows 自带的程序
start 下载地址
(new-object System.Net.WebClient).DownloadFile('https://www.php.net/distributions/php-7.4.9.tar.gz', 'E:/php-7.4.9.tar.gz')
Invoke-WebRequest -Uri 'https://www.php.net/distributions/php-7.4.10.tar.gz' -OutFile 'E:/php-7.4.10.tar.gz'
Start-BitsTransfer -Source "<File URL>" -Destination "<File Name>"
Start-BitsTransfer -Source "https://www.unicode.org/Public/UNIDATA/Unihan.zip" -Destination "Unihan.zip"
U盘 弹出失败的原因是进程占用了 U盘 ,只要占用 U盘 的进程都不在占用 U盘 或 都结束了, U盘 就可以安全地弹出了。
所以,让 U盘 安全地弹出的关键是找到占用 U盘 的进程。
当占用 U盘 的进程结束后,有时立即弹出 U盘 还是会失败的,这时再等待五六秒,再试一次弹出 U盘 就可以了。
可以安全退出 U盘 时也不要马上拔 U盘 ,最好等个五六秒再拔 U盘 。
这是各种方法的总结
笔者通常在直接弹出 U盘 失败后,会多试几次,然后通过 日志 找到对应的进程,然后通过 任务管理器 结束对应的进程,如果结束进程失败,还是会再次在网上搜索解决方法。 脱机 和 关闭写缓存都有一点副作用; 关闭文件夹,重启 explorer.exe ,注销,关机,这类都有点麻烦。
treminal , tty , console 是一开始都是硬件的概念。
一台电脑只有一个 console ,一般有电源开关等硬件操作的, 一台电脑可以有很多个 terminal 。 terminal 是负责 shell 的输入和输出。 console 也可以当作一个特殊的 terminal ,就是一个多了电源开关等硬件操作的 terminal 。 tty 是电传打印机。电传打印机是一种把键盘作为输入,纸带作为输出的硬件,是一种 terminal 。 一开始 terminal 就是指 tty 。 后来出现了使用显示器输出的 terminal 。使用显示器输出的 terminal 被称为 video terminal 简称 vt 。
旧时代的大型电脑为了能让多个用户可以同时使用,会提供多个物理终端。
软件意义上的终端出现,是为了让个人电脑的用户可以直接使用他的个人电脑来与大型计算机联系,而不必使用专门的物理终端。 现在的终端会被称为 emulator treminal 或 virtual terminal 。 因为现在已经没有物理意义上的终端了,都是由软件实现。 现在的 treminal , tty , console 都是指一种可以用来显示 shell 的软件, shell 可以是本地的也可以是远程的。
shell 是软件的概念。 shell 负责接收外部输入,调用各种程序或系统命令,然后输出结果。简单但不严谨的解释,负责人机交互的可以称为 shell ,负责显示 shell 的可以称为 terminal 。 shell 是通常是指命令行解释器,但图形界面一样可以有 GUI shll ,例如 Windows 的 explorer.exe 。 shell 通常会被翻译成 外壳 或 壳层。 shell 的概念其实是相对于操作系统内核 (kernel) 而言的。
shell 还可以分为 interactive 和 non-interactive 直接输入的命令运行在 interactive shell 上, shell 脚本代码就运行在 non-interactive shell 中。
词汇表
参考
https://www.zhihu.com/question/65280843
https://www.cnblogs.com/sparkdev/p/11605804.html
https://www.cnblogs.com/sparkdev/p/11460821.html
http://docs.linuxtone.org/ebooks/C&CPP/c/ch34s01.html
https://blog.csdn.net/dog250/article/details/78818612
https://taoshu.in/tty.html
全称 | 简称 | 备注 |
---|---|---|
thompson shell | sh | 第一个 unix like shell 。1971年至1975年随 Unix 第一版至第六版发布 |
borune shell | sh | 1978年随Version 7 Unix首次发布 |
borune again shell | bash | 在1987年由布莱恩·福克斯(Brian Fox)为了GNU计划而编写,是当前最常用的 shell |
almquist shell | ash | 派生于 borune shell ,最初作为 bsd 的 shell ,目前已不再被广泛使用 |
debian almquist shell | dash | 派生于 almquist shell ,是 debian 的 shell |
c shell | csh | 语法类似于C语言, c shell 目前已不再被广泛使用 |
tenex c shell | tcsh | csh 的增强版, FreeBSD 中的默认 shell |
korn shell | ksh | AIX 中的默认 shell ,兼容 borune shell ,同时加入了一些 c shell 的特性 |
zsh | zsh | zsh 对 borune shell 做出了大量改进,同时加入了 bash , ksh 及 tcsh 的某些功能。 zsh 现在是 mac 的默认 shell |
friendly interactive shell | fish | fish 的语法既不派生于 borune shell 也不派生于 c shell ,故被分类为一种“外来” shell 。 |
各种 shell 的发展脉络
+------------------------------------------------------------------------------------------------------------------+
| |
| |
| |
| Thompson shell |
| +----------+ +--------------------------+ |
| | | |
| | | |
| v v |
| c shell Bourne shell |
| + + |
| | | |
| +-----+-----------------+ | +------------------> |
| | | | | |
| v v v v |
| tenex c shell korn shell Bourne-Again shell almquist shell |
| + + + + |
| | | | | |
| +--------------------------v--------+---------------+ | |
| | v |
| | debian almquist shell |
| v |
| zsh fish |
| |
+------------------------------------------------------------------------------------------------------------------+
sh 通常是指遵循 POSIX 标准的 shell 。 bash 有 3 种方式使其遵循 POSIX 标准 https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html
通常情况下 shell 脚本以这句开头 #!/bin/sh ,就是表示这份脚本遵循 POSIX 标准。 如果想脚本足够的通用,最好不要用 bash 的语法。
现在绝大部分 unix like 系统中, /bin/sh 和 /usr/bin/sh 一般都是链接文件,指向真正的默认 shell 。 现在绝大部分 shell 都兼容 POSIX 标准,但同时又会有一些自己的拓展。
新版本的 powershell 也能运行在 linux 上。
remote terminal <----> ssh server <----> shell <----> tmux client <----> tmux server <----> shell
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
vi deamon.c
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
int main(int argc, char *argv[])
{
pid_t pid = fork();
if (pid > 0) {
exit(0); // 1.父进程退出
} else if (pid == 0) {
// 2.变为会话组长,脱离了控制终端 setsid()调用成功后,进程成为新的会话组长和新的进程组长,并与原来的登录会话和进程组脱离
setsid();
// 3.改变进程的工作目录
chdir("/var");
// 4. 重置文件掩码
umask(0);
// 5. 关闭文件描述符
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
// 6. 执行核心操作
// 每三秒一条记录到日志文件里,执行100次
int fd = open("/var/temp-deamon-log.txt", O_CREAT | O_WRONLY | O_APPEND, 0664);
int i;
for (i = 0; i < 100; i++) {
sleep(3);
time_t curtime;
time(&curtime);
char* pt = ctime(&curtime);
write(fd, pt, strlen(pt) + 1);
}
close(fd);
}
return EXIT_SUCCESS;
}
gcc deamon.c && \
./a.out && \
sleep 30 && \
cat -n /var/temp-deamon-log.txt && \
kill `ps -elf | grep a.out | awk '{print $4}'` && \
rm /var/temp-deamon-log.txt
nohup php queue.php >> out.log 2>&1 &
* * * * * php queue.php >> out.log 2>&1
编译的四个步骤
编译的四个步骤对应的 gcc 命令
gcc -E test.c -o test.i
gcc -S test.i -o test.s
gcc -c test.s -o test.o
gcc test.o -o test
实际上 gcc 这个命令只是这些后台程序的包装,它会根据不同的参数要求去调用预处理器cpp、预编译程序cc1、汇编器as、链接器ld
cpp test.c -o test.i
cc1 test.i -o test.s
as test.s -o test.o
ld test.o -o test
其它
# 没使用 pkg-config
gcc test.c -o test -I/usr/local/Cellar/opencv3/3.1.0_4/include/opencv -I/usr/local/Cellar/opencv3/3.1.0_4/include
# 使用了 pkg-config
gcc test.c -o test $(pkg-config opencv --cflags)
参考
感觉 GNU 真的除了内核之外,什么都有了。
用来测试网站对 ipv6 的支持,也可以用来查看 DNSSEC 的支持 https://ipv6.ustc.edu.cn/onlinechecklog.php
echo '{ "name": "xiaohong", "age": 18 }' | python -m json.tool
echo '{ "name": "xiaohong", "age": 18 }' | json_pp
echo '{"type":"image","offset":0,"count":20}' | ConvertFrom-Json | ConvertTo-Json
配合 curl 使用
curl -s -k https://localhost/dev.json | json_pp
curl -s -k https://localhost/dev.json | python -m json.tool
配合 PowerShell 的 Invoke-WebRequest 使用
Invoke-WebRequest https://localhost/dev.json -UseBasicParsing -SkipCertificateCheck | Select -ExpandProperty Content | ConvertFrom-Json | ConvertTo-Json
Invoke-WebRequest https://localhost/dev.json -UseBasicParsing -SkipCertificateCheck | Select -ExpandProperty Content | python -m json.tool
如果 Invoke-WebRequest 出现了这种错误。
因为 Internet Explorer 引擎不可用,或者 Internet Explorer 的首次启动配置不完整
可以尝试以下步骤来解决
windows10 之的系统在修改 path 时要注意分号 ;
在 JDK1.5 以后,classpath 并不是必须配置了,在 JDK1.5 之前,是没有办法在当前目录下加载类的(找不到 JDK 目录下 lib 文件夹中的 .jar 文件),所以我们需要通过配置 classpath ,但 JDK1.5 之后, JRE 能自动搜索目录下类文件,并且加载 dt.jar 和 tool.jar 的类。 dt.jar 是关于运行环境的类库,主要是用于 swing 的包,如果不使用可以不配置。 tools.jar 是工具类库。
编译和运行时可以通过参数 -classpath 指定 classpath 的路径,例如这样
javac -encoding UTF-8 -classpath .;./junit4.jar;./org.hamcrest.core_1.3.0.jar AaaTest.java JunitRunner.java
java -Dfile.encoding=UTF-8 -classpath .;./junit4.jar;./org.hamcrest.core_1.3.0.jar JunitRunner
通常是执行策略的原因导致的。
设置脚本执行策略,通常把 策略 设为 RemoteSigned 就可以了
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
查看 powershell 脚本执行策略
Get-ExecutionPolicy
Get-ExecutionPolicy -List
https://docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.2
python 一行命令启动 http 服务
# 最简单的 http 服务
python -m http.server
# 有 cgi 的 http 服务
python -m http.server --cgi
# 有 cgi 的和指定端口号的 http 服务
python -m http.server --cgi 8081
# 有 cgi 的,指定端口号的和指定ip地址的 http 服务
python -m http.server --cgi 8081 --bind 127.0.0.1
# 有 cgi 的,指定端口号的,指定ip地址的和指定站点根目录的 http 服务
python -m http.server --cgi 8081 --bind 127.0.0.1 --directory _book
请求 cgi 脚本的例子
curl 127.0.0.1:8000/cgi-bin/test.py
cgi 脚本的例子
#!/usr/bin/python3
print ("Content-type:text/html")
print () # 空行,告诉服务器结束头部
print ('<html>')
print ('<head>')
print ('<meta charset="utf-8">')
print ('<title>Hello Word</title>')
print ('</head>')
print ('<body>')
print ('<h2>Hello Word!</h2>')
print ('</body>')
print ('</html>')
#!/usr/bin/python3
print ("Content-type: application/json")
print () # 空行,告诉服务器结束头部
print ('{"result": "this is a test"}')
这个例子大致相当于这个命令 python -m http.server 8888
from http.server import HTTPServer, SimpleHTTPRequestHandler
if __name__ == '__main__':
host = ('0.0.0.0', 8888)
server = HTTPServer(host, SimpleHTTPRequestHandler)
print('Serving HTTP on {host} port {port} (http://{host}:{port}/) ...'.format(host=host[0], port=host[1]))
server.serve_forever()
这个例子大致相当于这个命令 python -m http.server --cgi 8888
from http.server import HTTPServer, CGIHTTPRequestHandler
if __name__ == '__main__':
host = ('0.0.0.0', 8888)
server = HTTPServer(host, CGIHTTPRequestHandler)
print('Serving HTTP on {host} port {port} (http://{host}:{port}/) ...'.format(host=host[0], port=host[1]))
server.serve_forever()
不使用命令行的 http 服务例子,这是单线程的
from http.server import HTTPServer, BaseHTTPRequestHandler
import json
class myHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps({'result': 'this is a test'}).encode())
if __name__ == '__main__':
host = ('0.0.0.0', 8888)
server = HTTPServer(host, myHandler)
print('Serving HTTP on {host} port {port} (http://{host}:{port}/) ...'.format(host=host[0], port=host[1]))
server.serve_forever()
不使用命令行的 http 服务例子,这是多线程的
from http.server import HTTPServer, BaseHTTPRequestHandler
from socketserver import ThreadingMixIn
import json
class ThreadingHttpServer(ThreadingMixIn, HTTPServer):
pass
class myHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps({'result': 'this is a test'}).encode())
if __name__ == '__main__':
host = ('0.0.0.0', 8888)
server = ThreadingHttpServer(host, myHandler)
print('Serving HTTP on {host} port {port} (http://{host}:{port}/) ...'.format(host=host[0], port=host[1]))
server.serve_forever()
不使用命令行的 http 服务例子,这是多线程的,再加上 cgi 的支持
from http.server import HTTPServer, CGIHTTPRequestHandler
from socketserver import ThreadingMixIn
class ThreadingHttpServer(ThreadingMixIn, HTTPServer):
pass
if __name__ == '__main__':
host = ('0.0.0.0', 8888)
server = ThreadingHttpServer(host, CGIHTTPRequestHandler)
print('Serving HTTP on {host} port {port} (http://{host}:{port}/) ...'.format(host=host[0], port=host[1]))
server.serve_forever()
HTTPServer 和 BaseHTTPRequestHandler 是两个关键的类,一个用于接收 http 请求,一个用于处理请求,其它类基本是派生自这两个类
BaseHTTPRequestHandler -> SimpleHTTPRequestHandler -> CGIHTTPRequestHandler
HTTPServer -> ThreadingHttpServer
参考文档
因为要经常部署和重装系统,所以就整理了这样一句命令,可能会因为 docker 的更新而失效,要注意修命令里的版本号
具体环境
这是文档 https://docs.docker.com/engine/install/debian/
sudo apt-get remove -y docker docker-engine docker.io containerd runc ; \
sudo apt-get update && \
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release && \
if [ -e /usr/share/keyrings/docker-archive-keyring.gpg ] ; \
then rm /usr/share/keyrings/docker-archive-keyring.gpg; \
else curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg ;fi && \
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
sudo apt-get update && \
sudo apt-get install -y docker-ce docker-ce-cli containerd.io && \
sudo docker run --rm hello-world && \
sudo curl -L --retry 100 --retry-delay 2 "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
sudo chmod +x /usr/local/bin/docker-compose && \
docker-compose --version
如果 docker-compose 总是下载失败,可以尝试使用这样的脚本下载
COMMAND="curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose"
for ((i=0;i<100;i++))
do
$COMMAND
if [ $? -eq 0 ]; then
exit 0;
fi
done
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
例子
curl -C - -o php-7.3.11.tar.gz https://www.php.net/distributions/php-7.3.11.tar.gz
解释
-L 允许重定向
-C 开启断点续传
- 这个表示开始和结束位置,一般就这样就可以了
--retry 100 超时重试 100 次,也可以是断点续传时的重试
--retry-delay 5 每次超时后等待 5 秒再重试
--connect-timeout 5 连接超过 5 秒算超时
一次连接超时时间。如果出错, 提示形如:curl: (28) connect() timed out!
--max-time 10 单次请求的最大时间
一次连接过程最大的允许时间。出错提示如:curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received
--max-time 要大于 --connect-timeouts
--retry-max-time 30 整体请求的最大时间
-o 参数将服务器的回应保存成文件
-O 参数将服务器回应保存成文件,并将 URL 的最后部分当作文件名。
如果服务器主动返回 失败 例如 reset 这类的,就会直接退出的了,不论有没有设置 --retry
github 好像不支持断点下载
alias ll="ls -l "
alias ll="ls -l "
因为 github 的 pull 和 push 总是超时,所以写了两段脚本用于失败后的自动重试
#!/bin/bash
# ./git_help.sh pull
# ./git_help.sh push
GIT_COMMAND="git "
case $1 in
"push"|"pull")
GIT_COMMAND=$GIT_COMMAND$1
;;
*)
echo "only input push or pull";
exit 1;
;;
esac
for ((i=0;i<100;i++))
do
$GIT_COMMAND
if [ $? -eq 0 ]; then
exit 0;
fi
done
# ./git_help.ps1 pull
# ./git_help.ps1 push
param($a)
$GIT_COMMAND = "git "
if ($a -eq "push") {
$GIT_COMMAND = $GIT_COMMAND + $a
} elseif ($a -eq "pull") {
$GIT_COMMAND = $GIT_COMMAND + $a
} else {
echo "only input push or pull"
exit 1
}
for ($i = 1; $i -lt 100; $i++) {
echo $i" "$GIT_COMMAND
PowerShell -command $GIT_COMMAND
# Invoke-Expression $GIT_COMMAND
# Invoke-Command -ScriptBlock {Write-Host $GIT_COMMAND}
# Invoke-Command -ScriptBlock {$GIT_COMMAND}
if ($? -eq $true) {
break
}
}