Windows下shell命令

 

持续输出文件:

- output.log 文件名

Get-Content "output.log" -Wait  

 

测试端口连通性

telnet <host_name_or_ip> <port>

 

清除DNS缓存

ipconfig /flushdns

 

 

运行rust输出日志:

cargo run 2>&1 | Out-File -FilePath output.log -Encoding utf8

 

运行npm服务:

npm run serve

 

开启ssh功能

Start-Service sshd

 

开机自动启动OpenSSH:

Set-Service -Name sshd -StartupType 'Automatic'

 

ssh连接建立隧道:

- Nv 只隧道

ssh -L 0.0.0.0:5555:127.0.0.1:5555 root@host -Nv

ssh 用户名@ip地址

 

查看当前公网(用ipconfig.me)

curl ipconfig.me

 

显示当前ip:

ipconfig (linux为 ifconfig)

 

获取系统信息:

Get-ComputerInfo

 

杀死进程:

Stop-Process -Name <process_name>

 

获取当前系统下的网络连接信息

Get-NetTCPConnection

 

查看服务状态

Get-Service

 

启动服务

Start-Service -Name <service_name>

 

停止服务

Stop-Service -Name <service_name>

 

检查磁盘服务:

chkdsk

 

关机命令:

shutdown /s /f /t 0
#0 表示立即关机,/f 强制关闭正在运行的程序。

 

重启命令:

shutdown /r /f /t 0
#/r 表示重启,0 表示立即重启。

 

注销当前用户命令:

shutdown /l

 

posted on 2025-01-11 11:04  GhostSugar  阅读(35)  评论(0)    收藏  举报