ssh
连接远程主机
- ssh -p 22 root@host
- 其中-p后面是端口号,root是远程主机上的用户名,host是远程主机的ip地址。以组里的服务器为例,则为:ssh -p 22 123@10.181.83.26
如果连接不上
- 检查是否启动:
sudo systemctl status sshd
如果显示activate,则表明ssh服务已经启动 - 启动命令:
sudo systemctl start sshd
- 设置开机自启动命令:
sudo systemctl enable sshd
- 也有可能时防火墙不允许指定端口通过,检查防火墙规则:
sudo ufw status
- 允许端口22通过:
sudo ufw allow 22/tcp
- 检查防护墙是否是开机自启动:
sudo systemctl is-enabled ufw
- 设置防火墙开机自启动:
sudo systemctl enable ufw
git
- git add .
- git commit -m “first commit”
- git status
- git remote -v 查看所有远端仓库
- git remote add name git@…… 添加远端仓库
- git remote remove name 移除远端仓库
linux
mv /root/path/ /root/path2
移动第一个路径下的某一个文件至第二个路径cd
:cd /path/dic cd .. 上一个目录ls
: ls 查看目录下的文件 ls -l 列出文件详细信息cat
: cat test.txt 终端打印文件内容cp
: cp test1.txt test2.txt 复制文件1的内容到文件2rm
: rm file.txt 删除文件touch
: touch file.txt 创建一个新的文件pwd
: 显示当前位置mkdir
: mkdir file 创建新的目录rmdir
: 删除空的目录tar
:- tar -cvf archive.tar /path/to/directory 创建一个名为 archive.tar 的归档文件
- tar -xvf archive.tar -C /path/to/extract 解压 archive.tar 到指定目录
ping
: ping google.com 测试网络联通性ipconfig
: 显示所有网络信息的接口wget
: wget 是一个命令行工具,用于从网络上下载文件。它支持 HTTP、HTTPS 和 FTP 协议,并且可以递归下载整个网站。wget https://example.com/file.zip
下载单个文件wget -O myfile.zip https://example.com/file.zip
下载文件并保存为指定名称
- 硬盘挂载:
sudo umount /path/file
:取消挂载在这个文件下的硬盘mount /dev/sdb /data
:将硬盘sdb挂载在/data文件夹下mount
:查看是否挂载成功vim /etc/fstab
:编辑这个文件可以设置系统开机自动挂载
- 重启:
reboot
:重新启动shutdown -r now
:现在重启sudo shutdown -r +10
:10分钟后重启sudo shutdown -r 22:00
:晚上10点重启
- 硬盘分区:
fdisk -l
:查看当前所有磁盘的分区情况lsblk(老师不离开)
:查看所有磁盘所有分区的挂载情况blkid
:查看UUID
- vim文本编辑:
- 一般要使用
sudo
,因为一些文件只有root用户能编辑 - 进入文件后,首先点
insert
开始插入模式开始编辑 - 编辑完成后点
esc
退出插入模式,按:wq
退出
- 一般要使用
uptime
:记录当前时间,从上次系统启动开始系统运行时间, 目前连接的用户数,过去1,5,15分钟系统的平均负载man
:在所有命令加上man,会在终端打开一个手册,展示这个命令的功能和可选参数lscpu
:查看CPU的数量和其他信息netstat -nat | grep 'ESTABLISHED' | grep ':22 ' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c
:显示当前ssh连接到服务器的用户数及其ip地址ls -l
:查看当前目录下所有文件的详细信息包括- 权限解释:
drwxr-xr-- 2 user group 4096 Jan 1 10:00 myfolder
:- 第一个字符表示文件类型,d表示目录,-表示普通文件,l表示符号链接等。
- 接下来的9个字符分为三组,每组三个字符,分别表示所有者、所属组和其他用户的权限。
- 每组中的三个字符分别表示读(r)、写(w)和执行(x)权限。如果某个权限没有被授予,则用-表示。
- drwxr-xr–:表示这是一个目录,所有者有读、写和执行权限,所属组有读和执行权限,其他用户只有读权限。
chmod -R u+rwx /path/folder
:- -R:递归地对文件夹及其内部的所有文件和子文件夹应用权限更改
- u:表示用户(所有者)
- +rwx:表示添加读、写和执行权限。
- /path/to/folder:替换为你要设置权限的文件夹的实际路径
chown test:test /data
:将data文件的所有者和所属组都设置为testexport http_proxy=http://ip:端口
:为linux系统设置代理,ip为win的ipv4地址,端口为代理软件的的监听端口一般为7890或者7897,设置好后可以使用curl google.com
来检测是否可以访问google,如果返回内容则设置成功。还需要设置export https_proxy=http://192.168.1.2:7890
Authentication failure
- 刚安装没有设置root密码,运行
sudo passwd
,设置密码,再运行su
即可
桌面环境挂掉了
systemctl status gdm
或者systemctl status lightdm
查看桌面环境运行状态sudo systemctl restart gdm
重启桌面环境即可
huggingface
下载模型或者数据
- pip install -U “huggingface_hub[cli]” 下载huggingface_hub
- huggingface-cli login 登录,使用token,在hf界面设置access token
- $env:HF_ENDPOINT = “https://hf-mirror.com“ 使用国内镜像
- huggingface-cli download –resume-download gpt2 –local-dir gpt2 下载模型
- 下载数据集 huggingface-cli download –repo-type dataset –resume-download wikitext –local-dir wikitext
- token存储地址:C:\Users\123.cache\huggingface\stored_tokens
excalidraw(linux)
- cd excalidraw
- yarn
- yarn start
- AI-MO/aimo-validation-amc
python自带虚拟环境(linux)
- python 创建虚拟环境:
python3 -m venv name - 进入虚拟环境:
source name/bin/activate - 进入项目文件:
cd /path/to/project - 打开vscode:
code .
sftp(类似于ssh但命令更简单)
上传文件到服务器
- 连接服务器:
sftp root@host
- cd远程服务器到指定路径:
cd path/to/dict
- 上传本地路径下的文件到远程服务器:
put local\path\doc.exe
kaggle
使用kaggle api在本地下载kaggle上的数据,模型等
- 在kaggle上的setting中,创建token,会自动下载一个kaggle.json
- 在
C/user/name/
下创建文件夹.kaggle
,将json文件放入其中 - 在终端中运行命令:
kaggle competitions download -c AI-Mathematical-Olympiad-Progress-Prize-2
注意要将赛事名称中间的空格用-
代替 - 使用命令:
tar -xf archive.zip -C target_folder
将下载好的zip文件解压到指定文件夹
open resume
- D盘打开project文件夹
- 右键打开git
- 运行
npm run dev
- 第一次安装:
cd open-resume
npm install
npm run dev
- 打开localhost:3000即可
git连接github失败
- 配置Git使用代理
git config --global http.proxy http://127.0.0.1:7897
git config --global https.proxy http://127.0.0.1:7897
- 其中端口号和IP地址可以打开设置->网络与Internet->代理来得到
- 配置完后可以查看是否配置成功
git config --global -l
- 这将列出当前的 Git 配置信息,确保其中的 http.proxy 和 https.proxy 设置为你刚刚配置的端口。
cmd命令
- msinfo32:可以查看主板信息
windows代理作用于WSL
- .sh文件已经保存在github,下载下来bash 运行即可,脚本如下:
-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24function proxy_on() {
export http_proxy="http://$(wslip):7890"
export https_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
echo -e "终端代理已开启,windows ip 为 $(wslip)。"
if curl --silent --head --max-time 3 https://www.google.com/ | grep "HTTP.*200" > /dev/null; then
echo "Google 连通性正常。"
else
echo "无法连接到 Google。"
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY
echo -e "终端代理已关闭。"
fi
}
function proxy_off(){
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY
echo -e "终端代理已关闭。"
}
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
配置Linux使用代理
sudo vim ~/.bashrc
- 在文件的末尾添加函数如下:
-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34function proxy_on() {
# 代理服务器配置
local proxy_server="192.168.1.2" # 代理服务器地址
local proxy_port="7890" # 代理服务器端口
local proxy="http://${proxy_server}:${proxy_port}"
# 设置代理环境变量
export http_proxy=$proxy
export https_proxy=$proxy
export HTTP_PROXY=$proxy
export HTTPS_PROXY=$proxy
# 设置无需代理的地址
export no_proxy="localhost,127.0.0.1/8,::1,192.168.0.0/23,*.local"
echo -e "终端代理已开启,代理服务器为 ${proxy_server}:${proxy_port}。"
# 检查 Google 连通性
if curl --silent --head --max-time 3 https://www.google.com/ | grep "HTTP.*200" > /dev/null; then
echo "Google 连通性正常。"
else
echo "无法连接到 Google。"
# 如果无法连接,关闭代理
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY
echo -e "终端代理已关闭。"
fi
}
function proxy_off() {
# 关闭代理
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY
unset no_proxy
echo -e "终端代理已关闭。"
}
Author: 武丢丢
Link: http://example.com/2025/03/24/%E5%91%BD%E4%BB%A4%E5%92%8C%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98/
Copyright: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.