免費轉換器

Linux / Bash 指令速查表

完整的Linux和Bash指令速查表。搜尋80+個常用指令,附說明、範例和一鍵複製功能。

ls
List directory contents
範例:ls -la /home/user
ls -la
List all files including hidden, with details
範例:ls -la ~/Documents
cd
Change directory
範例:cd /var/log
pwd
Print working directory path
範例:pwd
mkdir
Create a new directory
範例:mkdir -p /tmp/mydir/subdir
rm
Remove files or directories
範例:rm -rf /tmp/oldfiles
cp
Copy files or directories
範例:cp -r /src/dir /dst/dir
mv
Move or rename files/directories
範例:mv oldname.txt newname.txt
touch
Create an empty file or update timestamp
範例:touch newfile.txt
find
Search for files in a directory hierarchy
範例:find /home -name '*.log' -mtime -7
locate
Find files by name using a prebuilt database
範例:locate nginx.conf
ln
Create hard or symbolic links
範例:ln -s /path/to/target /path/to/link
df
Report disk space usage of file systems
範例:df -h
du
Estimate file space usage
範例:du -sh /var/log/*
stat
Display file or file system status
範例:stat /etc/passwd
file
Determine file type
範例:file /usr/bin/bash
cat
Concatenate and display file contents
範例:cat /etc/hosts
less
View file content one screen at a time
範例:less /var/log/syslog
more
View file content page by page
範例:more /etc/passwd
head
Output the first part of a file
範例:head -n 20 /var/log/auth.log
tail
Output the last part of a file
範例:tail -f /var/log/syslog
grep
Search text using patterns
範例:grep -rn 'error' /var/log/
sed
Stream editor for filtering and transforming text
範例:sed 's/old/new/g' file.txt
awk
Pattern scanning and text processing language
範例:awk '{print $1, $3}' access.log
sort
Sort lines of text files
範例:sort -k2 -n data.txt
uniq
Report or omit repeated lines
範例:sort file.txt | uniq -c
wc
Print newline, word, and byte counts
範例:wc -l /etc/passwd
cut
Remove sections from each line of files
範例:cut -d: -f1 /etc/passwd
tr
Translate or delete characters
範例:echo 'hello' | tr 'a-z' 'A-Z'
echo
Display a line of text
範例:echo "Hello, World!"
printf
Format and print data
範例:printf "%s\t%d\n" name 42
diff
Compare files line by line
範例:diff file1.txt file2.txt
tee
Read from stdin and write to stdout and files
範例:ls | tee output.txt
ps
Report a snapshot of current processes
範例:ps aux | grep nginx
top
Display Linux processes in real time
範例:top -u www-data
htop
Interactive process viewer (ncurses-based)
範例:htop
kill
Send a signal to a process
範例:kill -9 1234
killall
Kill processes by name
範例:killall firefox
bg
Resume a suspended job in the background
範例:bg %1
fg
Bring a job to the foreground
範例:fg %1
jobs
List active jobs in the current shell
範例:jobs -l
nohup
Run a command immune to hangups
範例:nohup ./script.sh &
nice
Run a command with modified scheduling priority
範例:nice -n 10 ./heavy_task.sh
systemctl
Control the systemd system and service manager
範例:systemctl restart nginx
service
Run a System V init script
範例:service apache2 status
ping
Send ICMP ECHO_REQUEST to network hosts
範例:ping -c 4 google.com
curl
Transfer data from or to a server
範例:curl -L -o file.zip https://example.com/file.zip
wget
Non-interactive network downloader
範例:wget -q https://example.com/file.tar.gz
ssh
OpenSSH remote login client
範例:ssh -i ~/.ssh/key.pem user@host
scp
Secure copy files between hosts
範例:scp user@host:/path/file.txt ./local/
rsync
Remote file copying tool with delta transfer
範例:rsync -avz /src/ user@host:/dst/
netstat
Print network connections and routing tables
範例:netstat -tulpn
ss
Utility to investigate sockets
範例:ss -tulwn
ifconfig
Configure a network interface
範例:ifconfig eth0
ip
Show and manipulate routing, devices, and tunnels
範例:ip addr show
nmap
Network exploration tool and port scanner
範例:nmap -sV 192.168.1.0/24
dig
DNS lookup utility
範例:dig +short A google.com
nslookup
Query Internet name servers interactively
範例:nslookup example.com
chmod
Change file mode bits (permissions)
範例:chmod 755 script.sh
chown
Change file owner and group
範例:chown -R www-data:www-data /var/www
chgrp
Change group ownership
範例:chgrp developers project/
sudo
Execute a command as another user (superuser)
範例:sudo systemctl restart nginx
su
Change user ID or become superuser
範例:su - postgres
passwd
Change user password
範例:passwd username
umask
Set or display the file mode creation mask
範例:umask 022
id
Print user and group information
範例:id username
whoami
Print the current effective user name
範例:whoami
groups
Print the groups a user is in
範例:groups username
tar
Archive files using tape archive format
範例:tar -czvf archive.tar.gz /path/to/dir
tar -x
Extract files from a tar archive
範例:tar -xzvf archive.tar.gz -C /target/
gzip
Compress files using GNU zip
範例:gzip -9 large_file.log
gunzip
Decompress gzip compressed files
範例:gunzip archive.tar.gz
zip
Package and compress files into a ZIP archive
範例:zip -r output.zip /path/to/dir
unzip
Extract files from a ZIP archive
範例:unzip archive.zip -d /target/
bzip2
Compress files using bzip2 algorithm
範例:bzip2 -z large_file.txt
xz
Compress files using the XZ algorithm
範例:xz -z -9 file.txt
uname
Print system information
範例:uname -a
uptime
Tell how long the system has been running
範例:uptime
free
Display amount of free and used memory
範例:free -h
lscpu
Display information about the CPU architecture
範例:lscpu
lsblk
List information about block devices
範例:lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
lspci
List all PCI devices
範例:lspci -v | grep VGA
dmesg
Print or control the kernel ring buffer
範例:dmesg | tail -50
journalctl
Query and display messages from the journal
範例:journalctl -u nginx --since '1 hour ago'
history
Display the command history list
範例:history | grep docker
env
Print environment variables
範例:env | grep PATH
if / then / fi
Conditional execution in shell scripts
範例:if [ -f file.txt ]; then echo exists; fi
for
Loop over a list of items
範例:for i in 1 2 3; do echo $i; done
while
Execute commands while a condition is true
範例:while read line; do echo $line; done < file
case
Multi-branch conditional matching pattern
範例:case "$var" in a) echo A;; b) echo B;; esac
function
Define a shell function
範例:greet() { echo "Hello, $1!"; }; greet World
export
Set environment variables for child processes
範例:export MY_VAR=value
source
Execute commands from a file in current shell
範例:source ~/.bashrc
alias
Create an alias for a command
範例:alias ll='ls -la'
cron / crontab
Schedule commands to run periodically
範例:crontab -e # 0 * * * * /path/to/script.sh
at
Execute commands at a specified time
範例:echo 'ls /tmp' | at 14:30

關於此工具

Linux bash 的綜合快速參考指南。瀏覽按類別組織的常用指令、語法和範例。可搜尋且適合行動裝置 - 將此頁面加入書籤,以便在需要快速提醒時即時存取。

使用方法

  1. 瀏覽分類的參考部分。
  2. 使用搜尋欄尋找特定指令或語法。
  3. 按一下任何條目即可查看使用範例和說明。
  4. 直接複製命令以在終端機或編輯器中使用。

常見問題

該參考文獻是最新的嗎?
該參考涵蓋了廣泛使用的命令和語法,這些命令和語法在各個版本中都是穩定的。有關最新添加或特定於版本的功能,請查看官方文件。
我可以離線使用嗎?
加載後,該頁面無需互聯網連接即可運行。將其新增為書籤以便快速存取 - 所有內容都在瀏覽器中呈現,無需進一步的網路請求。
這是全面的還是只是基礎知識?
它涵蓋了處理 90% 日常任務的最常用命令和模式。有關利基或高級功能,請參閱官方文件。
我可以建議補充嗎?
我們定期更新我們的參考資料。如果您發現缺少命令或有建議,請透過我們的聯絡頁面告知我們。