进程管理
Windows
# 查找进程 PID
tasklist | findstr "uvicorn"
# 终止进程(将 12345 替换为实际 PID)
taskkill /F /PID 12345
Linux
# 查找进程 PID
ps -ef | grep "python"
# 终止进程(将 12345 替换为实际 PID)
kill -9 12345
文件操作
Windows
# 查找文件
dir /s /p "C:\Users\用户名\Downloads\*.pdf"
# 删除文件
del /s /q "C:\Users\用户名\Downloads\*.pdf"
Linux
# 查找文件
find /home/用户名/Downloads -name "*.pdf"
# 删除文件
rm -rf /home/用户名/Downloads/*.pdf
解压文件
Windows
# 解压 zip 文件
expand "C:\Users\用户名\Downloads\file.zip" "C:\Users\用户名\Downloads\file"
# 解压 rar 文件
rar x "C:\Users\用户名\Downloads\file.rar" "C:\Users\用户名\Downloads\file"
Linux
# 解压 zip 文件
unzip "file.zip" -d "file"
# 解压 rar 文件
unrar x "file.rar" "file"
移动文件
Windows
# 移动文件
move "C:\Users\用户名\Downloads\file" "C:\Users\用户名\Documents"
Linux
# 移动文件
mv "file" "Documents"
Linux常用指令
-
文件目录类
|格式|示例|说明|
|:—:|:—:|:—:|
|ls
|ls -l
|列出目录内容|
|cd
|cd Documents
|切换目录|
|pwd
|pwd
|显示当前目录|
|mkdir
|mkdir new_folder
|创建新目录|
|rmdir
|rmdir empty_folder
|删除空目录|
|rm
|rm file
|删除文件|
|cp
|cp file1 file2
|复制文件|
|mv
|mv file1 file2
|移动或重命名文件|
|find
|find . -name "*.txt"
|查找文件|
|grep
|grep "text" file.txt
|在文件中查找文本|
|cat
|cat file.txt
|显示文件内容|
|more
|more file.txt
|逐页显示文件内容|
|less
|less file.txt
|逐页显示文件内容,可向上翻页|
|head
|head -n 10 file.txt
|显示文件前 10 行|
|tail
|tail -n 10 file.txt
|显示文件后 10 行|
|chmod
|chmod 755 file
|更改文件权限|
|chown
|chown user:group file
|更改文件所有者|
|tar
|tar -cvf archive.tar file1 file2
|创建 tar 归档文件|
|gzip
|gzip file
|压缩文件|
|gunzip
|gunzip file.gz
|解压 gzip 压缩文件|
|zip
|zip archive.zip file1 file2
|创建 zip 压缩文件|
|unzip
|unzip archive.zip
|解压 zip 压缩文件|
|mv
|mv file1 file2
|移动或重命名文件| -
系统管理类
|格式|示例|说明|
|:—:|:—:|:—:|
|ps
|ps -ef
|显示当前进程|
|top
|top
|实时显示系统资源使用情况|
|kill
|kill -9 12345
|终止进程|
|free
|free -h
|显示内存使用情况|
|df
|df -h
|显示磁盘使用情况|
|du
|du -sh /path/to/directory
|显示目录大小|
|scp
|scp file user@hostname:/path/to/destination
|远程复制文件|
|wget
|wget http://example.com/file
|下载文件|
|curl
|curl -O http://example.com/file
|下载文件|
|apt
|apt-get install package
|安装软件包| -
用户管理类
|格式|示例|说明|
|:—:|:—:|:—:|
|who
|who
|显示当前登录用户|
|w
|w
|显示当前登录用户及其活动|
|id
|id user
|显示用户信息|
|useradd
|useradd newuser
|创建新用户|
|userdel
|userdel newuser
|删除用户|
|passwd
|passwd user
|更改用户密码|
|su
|su - user
|切换用户| -
网络管理类
|格式|示例|说明|
|:—:|:—:|:—:|
|ifconfig
|ifconfig
|显示网络接口信息|
|ping
|ping www.google.com
|测试网络连接|
|traceroute
|traceroute www.google.com
|追踪网络路径|
|netstat
|netstat -an
|显示网络连接|
|ssh
|ssh user@hostname
|远程登录|