โดย ชิตพงษ์ กิตตินราดร | กันยายน 2563
หน้านี้จะรวมคำสั่งพื้นฐานในการใช้งาน Linux ด้วย shell เช่น Bash, Zsh, และ Fish เพื่อเป็นพื้นฐานในการเขียนโค้ดและ deploy บนเว็บต่อไป
List directory: ls
ls -a
ls -l
ls -h
Make directory: mkdir
Remove directory: rmdir
Copy: cp [filename] [target]
Move: mv [filename] [target]
Remove: rm [filename]
Copy or move many files at once: cp {[file1],[file2],[file3]} target
Recursive remove dir: rm -rfv target/
Show file content: cat [filename]
Show file content with backward/forward movement: less [filename]
Show tail of file with n-lines: tail -[# of lines] [filename]
Show tail of file and live update: tail -f [filename]
Show only lines with specific string: [command-to-std-output] | grep [string]
Show disk usage in partitions: df -h
Show memory usage: free -m
Show processes: top
or htop
*
Show Linux version information: uname -a
or neofetch
*
Compress: tar -czvf target.tar.gz [file(s)]
Uncompress: tar -xzvf target.tar.gz
Connect to remote: ssh -i pemfile.pem username@host
Copy file from remote: scp -i pemfile.pem username@host:/path/to/file /path/to/destination
Install fonts by copy font directory to .local/share/fonts
Refresh font cache: fc-cache -f -v
View PATH: echo $PATH
Bash shell:
export PATH=$PATH:/path/to/bin
~/.bashrc
or ~/.bash_profile
Fish shell:
printenv
or sudo printenv
set PATH /path/to/bin $PATH
~/.config/fish/config.fish
Fish shell:
Create a function in ~/.config/fish/functions/funcname.fish
In funcname.fish:
function funcname
ls -lh $argv
end
Debian-based
sudo apt update
sudo apt upgrade
sudo apt install [package]
sudo apt remove [package]
sudo apt remove --purge [package]
sudo apt clean
sudo apt autoremove
Arc-based
sudo pacman -Syu
or yay -Syu
* to also include AUR repo
sudo pacman -S [package]
yay -S [package]
sudo pacman -Rs [package]
sudo pacman -Scc
or yay -Scc
to also clean AUR cache
pacman -Qm
pacman -Qn
pacman -Qtdq | pacman -Rns -
Virtual environment
python3 -m venv ~/.venv/envname
source ~/.venv/envname/bin/activate
source ~/.venv/envname/bin/activate.fish
deactivate
Package management
pip list
pip install [packagename]
pip list --outdated
pip install --upgrade [packagename]
pip remove [packagename]
pip show [packagename]
หน้าแรก | Virtual Environment (venv)