---
# System prepended metadata

title: Server

---

# Server

### 系上server
r26111010 As@0918088611
### 防火牆:
sudo ufw allow 8787
sudo ufw allow 8000
### R:
開:sudo systemctl start rstudio-server
關:sudo systemctl stop rstudio-server
自動開:sudo systemctl enable rstudio-server
### Python:
sudo su root
開:jupyterhub
一開始安裝問題,要用root裝,sudo su root,並且mimiconda 要裝在大家有權可以連接的地方

一開始開不起來是因為,可以的時候是用conda開的,但是下面那個指令電腦不是用conda執行,所以一開始沒吃到路徑,所以先離開conda,conda deactivate,然後執行下面才可吃到路徑
export PATH=$PATH:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/miniconda3/bin

sudo nano /etc/systemd/system/jupyterhub.service
sudo systemctl start jupyterhub
sudo systemctl enable jupyterhub
sudo systemctl stop jupyterhub

# 
# jupyterhub使用注意事項(啓榮)
https://bold-bead-b92.notion.site/conda-jupyter-215c33b035cf4683bf12604262c5393f
# 註冊帳號以及使用教學
jupyterhub建立環境以及使用 https://pastebin.com/KR3Yhp3f

創帳號
sudo adduser xxx 
下載miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

#### 執行安裝檔案，全 yes、[Enter]，裝完後重新登入, 幫別人安裝miniconda init要yes
bash Miniconda3-latest-Linux-x86_64.sh
 
建立新環境
conda create --name [env_name] python=3.9
 
進入/離開環境
conda activate [env_name]
conda deactivate

 
將虛擬環境的 kernel 新增至 jupyterhub 當中
一定要先 activate 進入虛擬環境
conda activate [env_name]
 

安裝 ipykernel 套件,這樣虛擬環境才會直接顯示在介面上供選擇
pip install ipykernel
新增 kernel
python -m ipykernel install --user --name [kernel_name]



# 常用指令
關機
```cmake
sudo shutdown now
```
從新開機
```cmake
sudo shutdown -r now
```
刪除process
```cmake
sudo kill -9 xxx
```
刪除使用者
```cmake
sudo userdel -r xxx   #這會刪檔案
``` 
```cmake
sudo userdel username
```
刪除檔案
```cmake
sudo rm -r xx
```

給檔案權限給所有人
```cmake
chmod -R a+w [Folder]
```
# Acvlab
掛接硬碟:
sudo mount /dev/sda1 /hdd2
sudo mount /dev/sdb1 /hdd1
sudo mount /dev/sdc1 /hdd3
sudo mount /dev/sdd1 /hdd4
sudo mount /dev/sde /ssd5
sudo mount /dev/sdf /ssd6
sudo mount /dev/sdg /ssd7
sudo mount /dev/sdh /ssd8
沒自動接
sudo mount /dev/nvme1n1p1 /old_home

-----
/dev/sda1 /mnt/sda1 auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/sdc1 /ssd3 auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/sdd1 /ssd4 auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/sde1 /ssd5 auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/sdf1 /ssd6 auto nosuid,nodev,nofail,x-gvfs-show 0 0

查看記憶體占用
sudo du -sh /home/*

停用及解除停用帳號:
sudo usermod -s /sbin/nologin [**username**]
sudo usermod -s /bin/bash [**username**]

檔案權限:
sudo chown -R [**username**]:[**username**] [**Folder**]
所有人
sudo chmod -R 777 [Folder]

改密碼:
passwd [**username**]

看改密碼時間:
chage -l [**username**]

sudo 幫別人改:
```cmake
sudo su  #切換到root
passwd xxx
```

sudo 權限:
sudo visudo

username    ALL=(ALL) ALL
![image](https://hackmd.io/_uploads/B1kPCK9D6.png)

查顯卡型號
lspci | grep -i vga
出來是英文可到
https://admin.pci-ids.ucw.cz//read/PC/10de/2208

# 無密碼登錄(公私金鑰)
https://xenby.com/b/220-%e6%95%99%e5%ad%b8-%e7%94%a2%e7%94%9fssh-key%e4%b8%a6%e4%b8%94%e9%80%8f%e9%81%8ekey%e9%80%b2%e8%a1%8c%e5%85%8d%e5%af%86%e7%a2%bc%e7%99%bb%e5%85%a5

# Github 金鑰
https://officeguide.cc/git-https-server-certificate-verification-failed-solution/

# 218 nvidia-smi 找不到
https://blog.csdn.net/wjinjie/article/details/108997692

# Github 登入
```cmake=
git pull
git add .
git commit -m "註記"
git push
```
Jet..123@2024!


