# Setup Tips ## Linux Server Setup ### os - storage configuration - not LVM - /boot/efi: press "select as boot device" - /boot: 1G, ext4 - SWAP: 8G (depend on your RAM size) - LVM - the remaing boot disk + all the other disks - remaing boot disk: add GPT partition -> use remaining disk space -> leave unformatted, unmounted - create LVM VG - create LV for newly created VG - /: all space, ext4 - reference link: - [create partitions and LVMs](https://askubuntu.com/questions/1234457/ubuntu-live-server-20-04-how-to-create-custom-partition-boot-lvm-on-a-sin) ### network - remove cloud-init - `sudo apt remove cloud-init` - ethernets setup: no dhcp, static ip, dns ip, option: true, gateway (router ip or other gateway devices) - wifi setup: SSID and password - netplan try, netplan apply - reference link: - [netplan ethernet setup](https://blog.tigernaxo.com/posts/linux/ubuntu204-static-ip/) - [netplan wifi setup](https://zonego.tw/2022/12/25/ubuntu22-netsetting/) ### firewall (ufw) - https://help.ubuntu.com/community/UFW ### user ``` // user sudo adduser <username> sudo deluser <username> // or sudo useradd <username> sudo passwd <username> // group sudo usermod -aG <groupname> <username> // give user group groups <username> // check user group gpasswd --delete <username> <groupname> // remove user from a group mkhomedir_helper <username> // create home directory cat /etc/group // list all groups ``` ### git - git: email, name setup ``` git config --global user.name "ACaccel" git config --global user.email "c8763318@gmail.com" ``` - github: ssh key setup - paste pub key in github "ssh keys" ``` ssh-keygen -t ed25519 -C "c8763318@gmail.com" eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 cat ~/.ssh/id_ed25519.pub ``` ### Vscode ssh-remote auto-password - https://stackoverflow.com/questions/66113731/how-to-save-ssh-password-to-vscode - remote identification has changed - delete corresponding ip in `.ssh/known_hosts` in the client pc ### recommended packages installation ``` sudo apt install libtool // docker sudo apt install -y docker.io sudo usermod -aG <groupname> docker newgrp docker ``` ### problems solutions - A start job is running for wait for network to be configured (on boot): - add `optional: true` for NICs in your netplan configuration file - cannot call open vswitch: ovsdb-server.service is not running: - [install ovsdb](https://stackoverflow.com/questions/77352932/ovsdb-server-service-from-no-where) ### Other references - [how to setup linux server](https://hackmd.io/@QMYMj19MQTakfoKkZZO3jg/S1OuDNqQs#3-%E8%A8%AD%E5%AE%9AIP) - [ftp server setup](https://hackmd.io/@F6INImbsTzOe4izuqqLoWQ/rJt7n8lvh?utm_source=preview-mode&utm_medium=rec) ## Python Installation - https://phoenixnap.com/kb/how-to-install-python-3-ubuntu ``` sudo apt install python3 sudo apt install python3-pip -y ``` - If you want to upgrade python version, use conda ## Nodejs Installation ``` sudo apt install npm sudo npm cache clean -f sudo npm install -g n sudo n <version number> // 18.17.0 sudo n // change version sudo apt remove cmdtest // if yarn command failed sudo apt remove yarn sudo npm install -g yarn ``` ## Golang Installation - download [golang package](https://go.dev/doc/install) ``` sudo rm -rf /usr/local/go sudo tar -C /usr/local -xzf go1.23.4.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin // add to bashrc go version ``` ## Conda Installation - https://blog.csdn.net/Alex_81D/article/details/135692506 - if you want to disable auto-activate on startup - conda config --set auto_activate_base false - command - conda create -n <env_name> - conda activate <env_name> - conda env list - conda list - conda install <package_name> ## Tmux Command ``` tmux new-session -t <session name> tmux kill-session -t <session name> tmux attach -t <session name> Pane Commands: Ctrl+b then type % – Split the window vertically. Ctrl+b then type " – Split the window horizontally. Ctrl+b then type o – Cycle through panes. Ctrl+b then use the arrow keys – Switch to the pane in the specified direction. Ctrl+b then press the spacebar – Change the layout. Ctrl+b then type ! – Break the current pane out into a new window. Ctrl+b then type x – Close the current pane. Window Commands: Ctrl+b then type c – Create a new window. Ctrl+b then type w – Switch between windows using a visual menu (very useful). Ctrl+b then type n – Switch to the next window. Ctrl+b then type p – Switch to the previous window. Ctrl+b then type a number – Switch to the specified window. Ctrl+b then type & – Close the current window. Ctrl+b then type , – Rename the window. Session Commands: Ctrl+b then type $ – Rename the current session. Ctrl+b then type d – Detach the current session (exit tmux environment). Ctrl+b then type s – Switch between sessions using a visual menu (very useful). Ctrl+b then type L – Switch to the last used session. Ctrl+b then type ( – Switch to the previous session. Ctrl+b then type ) – Switch to the next session. Search Command: Ctrl+b then type f – Search for a keyword in all windows (very useful). ``` ## tar command - https://note.drx.tw/2008/04/command.html ``` tar zcvf <FileName.tar.gz> <DirName> // zip tar zxvf <FileName.tar.gz> // unzip ``` ## Windows commands - test server - `Start-Process powershell -ArgumentList {python -m http.server 3000}` ## Scrcpy setup - download **Scrcpy** and **Scrcpy GUI** on PC - add the Scrcpy directory into the $PATH - download **Wireless ADB** on your Android phone and open USB Debug - connect your phone to PC: - on PC run `adb tcpip <port>` - on PC run `adb connect <ip>` - open **Scrcpy GUI** to connect to your phone - Unplug your phone from PC and then open **Scrcpy.exe**