实验常用linux指令
# 创建虚拟环境基本步骤
conda create -n xxx python=3.x -y
conda activate xxx
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
清除代理环境变量
# 查看当前代理设置(确认问题)
echo $http_proxy $https_proxy $HTTP_PROXY $HTTPS_PROXY
# 全部清除
unset http_proxy https_proxy all_proxy no_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY NO_PROXY
# 验证已清除
env | grep -i proxy
zip解压
unzip命令的基本语法非常简单,只需要指定要解压的ZIP文件名即可。例如,要解压一个名为file.zip的文件到当前目录,可以使用以下命令:
unzip file.zip
如果想将ZIP文件解压到指定的目录,可以使用-d选项来指定目标目录的路径。例如,要将file.zip解压到/path/to/directory目录,可以使用以下命令:
unzip file.zip -d /path/to/directory
虚拟环境创建
| 操作 | 命令 | 说明 |
|---|---|---|
| 创建环境 | conda create -n myenv python=3.9 |
创建名为myenv的环境 |
| 激活环境 | conda activate myenv |
激活指定环境 |
| 退出环境 | conda deactivate |
退出当前环境 |
| 查看环境列表 | conda env list |
显示所有环境 |
| 安装包 | conda install numpy pandas |
使用conda安装包 |
| 使用pip安装 | pip install package |
也可在conda环境中用pip |
| 导出环境 | conda env export > environment.yml |
导出完整环境配置 |
| 从文件创建 | conda env create -f environment.yml |
从配置文件创建 |
| 删除环境 | conda env remove -n myenv |
删除指定环境 |
| 克隆环境 | conda create --clone myenv --name myenv_copy |
克隆现有环境 |
查看所有配置pip config list -v
版本控制 (Git)
| 命令 | 用法示例 | 说明 |
|---|---|---|
git init |
git init |
初始化本地仓库 |
git clone |
git clone https://github.com/... |
克隆远程仓库 |
git add |
git add . |
添加文件到暂存区 |
git commit |
git commit -m "init project" |
提交更改 |
git push |
git push origin main |
推送到远程仓库 |
git pull |
git pull |
拉取远程更新 |
git status |
git status |
查看仓库状态 |
git log |
git log --oneline |
查看提交历史 |
git branch |
git branch -a |
查看分支 |
git checkout |
git checkout -b dev |
创建并切换分支 |
网络与文件传输
| 命令 | 用法示例 | 说明 |
|---|---|---|
wget |
wget https://example.com/file.tar.gz |
下载文件 |
curl |
curl -O https://example.com/file |
下载文件(-O 保存原文件名) |
scp |
scp file.txt user@host:/path/ |
安全复制文件到远程服务器 |
rsync |
rsync -avz src/ user@host:dest/ |
同步文件(-a 归档,-v 详细,-z 压缩) |
ssh |
ssh user@10.68.214.2 |
远程登录服务器 |
系统监控与进程管理
| 命令 | 用法示例 | 说明 |
|---|---|---|
ps |
ps aux |
grep python |
top |
top |
实时监控系统资源 |
htop |
htop |
增强版进程监控(需安装) |
kill |
kill 1234 |
终止进程(默认SIGTERM) |
kill -9 |
kill -9 1234 |
强制终止进程(SIGKILL) |
pkill |
pkill -f "python script" |
按名称杀死进程 |
nohup |
nohup python app.py & |
后台运行程序 |
free |
free -h |
查看内存使用情况 |
df |
df -h |
查看磁盘空间使用 |
du |
du -sh project/ |
查看目录大小 |
本文来自博客园,作者:BlnoOo,转载请注明原文链接:https://www.cnblogs.com/Bolan/p/19760030

浙公网安备 33010602011771号