Linux admin

โดย ชิตพงษ์ กิตตินราดร | กันยายน 2563

หน้านี้จะรวมคำสั่งพื้นฐานในการใช้งาน Linux ด้วย shell เช่น Bash, Zsh, และ Fish เพื่อเป็นพื้นฐานในการเขียนโค้ดและ deploy บนเว็บต่อไป

Files and Directory

List directory: ls

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/

Text display

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]

File system

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*

Compression

Compress: tar -czvf target.tar.gz [file(s)]

Uncompress: tar -xzvf target.tar.gz

SSH

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

Fonts

Install fonts by copy font directory to .local/share/fonts

Refresh font cache: fc-cache -f -v

PATH environment

View PATH: echo $PATH

Bash shell:

Fish shell:

Shell function

Fish shell:

Create a function in ~/.config/fish/functions/funcname.fish

In funcname.fish:

function funcname
    ls -lh $argv
end

Package management

Debian-based

Arc-based

Python

Virtual environment

Package management

หน้าแรก | Virtual Environment (venv)

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.