環境變量
一、查看環境變量
env
二、查看PATH
export
或者單獨查看PATH環境變量
echo $PATH
三、修改PATH
1、直接用export命令:
export PATH=$PATH:你的路徑
查看是否已經設好,命令如上
2、修改profile文件:
vim /etc/profile
在里面加入:
export PATH="$PATH:你的路徑"
3. 修改.bashrc文件:
vim /root/.bashrc
在里面加入:
export PATH="$PATH:你的路徑"
后兩種方法一般需要重新注銷系統才能生效,然后查看PATH環境變量:
echo $PATH
一個“一勞永逸”的辦法是把這個路徑加入環境變量。命令 “PATH=$PATH:路徑”可以把這個路徑加入環境變量,但是退出這個命令行就失效了。要想永久生效,需要把這行添加到環境變量文件里。有兩個文件可選:“/etc/profile”和用戶主目錄下的“.bash_profile”,“/etc/profile”對系統里所有用戶都有效,用戶主目錄下的“.bash_profile”只對這個用戶有效。
sudo vim /etc/profile
在文件最后加上
PATH=$PATH:你的路徑
我的是
PATH=$PATH:/home/pi/.local/bin(寫給我自己看的)
查看路徑
查看軟件路徑方法(以python為例):
方法1:whereis python
查看所有python的路徑,不止一個
方法2:which python
查看當前使用的python路徑
樹莓派支持的源
樹莓派官方鏈接:
Raspbian Mirrors
清華大學開源軟件鏡像站
Raspbian 鏡像使用幫助
第一步:先備份源文件。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak
第二步:編輯系統源文件。
sudo nano /etc/apt/sources.list
將初始的源使用#注釋掉,添加如下兩行中科大的鏡像源。
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
清華:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
另外除了中科大的軟件源,也可以使用其他的源。替換時只需要更改網址部分即可。
http://mirrors.ustc.edu.cn/raspbian/raspbian/
阿里雲
http://mirrors.aliyun.com/raspbian/raspbian/
清華大學
http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/
第三步:繼續編輯系統源文件
sudo nano /etc/apt/sources.list.d/raspi.list
將初始的源使用#注釋掉,添加清華的鏡像源。
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
按Ctrl+S保存,Ctrl+X退出。
