免费转换器
Linux / Bash 命令速查表
全面的Linux和Bash命令速查表。搜索80+个常用命令,附带示例、描述和一键复制功能。
ls
List directory contents
示例:
ls -la /home/userls -la
List all files including hidden, with details
示例:
ls -la ~/Documentscd
Change directory
示例:
cd /var/logpwd
Print working directory path
示例:
pwdmkdir
Create a new directory
示例:
mkdir -p /tmp/mydir/subdirrm
Remove files or directories
示例:
rm -rf /tmp/oldfilescp
Copy files or directories
示例:
cp -r /src/dir /dst/dirmv
Move or rename files/directories
示例:
mv oldname.txt newname.txttouch
Create an empty file or update timestamp
示例:
touch newfile.txtfind
Search for files in a directory hierarchy
示例:
find /home -name '*.log' -mtime -7locate
Find files by name using a prebuilt database
示例:
locate nginx.confln
Create hard or symbolic links
示例:
ln -s /path/to/target /path/to/linkdf
Report disk space usage of file systems
示例:
df -hdu
Estimate file space usage
示例:
du -sh /var/log/*stat
Display file or file system status
示例:
stat /etc/passwdfile
Determine file type
示例:
file /usr/bin/bashcat
Concatenate and display file contents
示例:
cat /etc/hostsless
View file content one screen at a time
示例:
less /var/log/syslogmore
View file content page by page
示例:
more /etc/passwdhead
Output the first part of a file
示例:
head -n 20 /var/log/auth.logtail
Output the last part of a file
示例:
tail -f /var/log/sysloggrep
Search text using patterns
示例:
grep -rn 'error' /var/log/sed
Stream editor for filtering and transforming text
示例:
sed 's/old/new/g' file.txtawk
Pattern scanning and text processing language
示例:
awk '{print $1, $3}' access.logsort
Sort lines of text files
示例:
sort -k2 -n data.txtuniq
Report or omit repeated lines
示例:
sort file.txt | uniq -cwc
Print newline, word, and byte counts
示例:
wc -l /etc/passwdcut
Remove sections from each line of files
示例:
cut -d: -f1 /etc/passwdtr
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 42diff
Compare files line by line
示例:
diff file1.txt file2.txttee
Read from stdin and write to stdout and files
示例:
ls | tee output.txtps
Report a snapshot of current processes
示例:
ps aux | grep nginxtop
Display Linux processes in real time
示例:
top -u www-datahtop
Interactive process viewer (ncurses-based)
示例:
htopkill
Send a signal to a process
示例:
kill -9 1234killall
Kill processes by name
示例:
killall firefoxbg
Resume a suspended job in the background
示例:
bg %1fg
Bring a job to the foreground
示例:
fg %1jobs
List active jobs in the current shell
示例:
jobs -lnohup
Run a command immune to hangups
示例:
nohup ./script.sh &nice
Run a command with modified scheduling priority
示例:
nice -n 10 ./heavy_task.shsystemctl
Control the systemd system and service manager
示例:
systemctl restart nginxservice
Run a System V init script
示例:
service apache2 statusping
Send ICMP ECHO_REQUEST to network hosts
示例:
ping -c 4 google.comcurl
Transfer data from or to a server
示例:
curl -L -o file.zip https://example.com/file.zipwget
Non-interactive network downloader
示例:
wget -q https://example.com/file.tar.gzssh
OpenSSH remote login client
示例:
ssh -i ~/.ssh/key.pem user@hostscp
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 -tulpnss
Utility to investigate sockets
示例:
ss -tulwnifconfig
Configure a network interface
示例:
ifconfig eth0ip
Show and manipulate routing, devices, and tunnels
示例:
ip addr shownmap
Network exploration tool and port scanner
示例:
nmap -sV 192.168.1.0/24dig
DNS lookup utility
示例:
dig +short A google.comnslookup
Query Internet name servers interactively
示例:
nslookup example.comchmod
Change file mode bits (permissions)
示例:
chmod 755 script.shchown
Change file owner and group
示例:
chown -R www-data:www-data /var/wwwchgrp
Change group ownership
示例:
chgrp developers project/sudo
Execute a command as another user (superuser)
示例:
sudo systemctl restart nginxsu
Change user ID or become superuser
示例:
su - postgrespasswd
Change user password
示例:
passwd usernameumask
Set or display the file mode creation mask
示例:
umask 022id
Print user and group information
示例:
id usernamewhoami
Print the current effective user name
示例:
whoamigroups
Print the groups a user is in
示例:
groups usernametar
Archive files using tape archive format
示例:
tar -czvf archive.tar.gz /path/to/dirtar -x
Extract files from a tar archive
示例:
tar -xzvf archive.tar.gz -C /target/gzip
Compress files using GNU zip
示例:
gzip -9 large_file.loggunzip
Decompress gzip compressed files
示例:
gunzip archive.tar.gzzip
Package and compress files into a ZIP archive
示例:
zip -r output.zip /path/to/dirunzip
Extract files from a ZIP archive
示例:
unzip archive.zip -d /target/bzip2
Compress files using bzip2 algorithm
示例:
bzip2 -z large_file.txtxz
Compress files using the XZ algorithm
示例:
xz -z -9 file.txtuname
Print system information
示例:
uname -auptime
Tell how long the system has been running
示例:
uptimefree
Display amount of free and used memory
示例:
free -hlscpu
Display information about the CPU architecture
示例:
lscpulsblk
List information about block devices
示例:
lsblk -o NAME,SIZE,TYPE,MOUNTPOINTlspci
List all PCI devices
示例:
lspci -v | grep VGAdmesg
Print or control the kernel ring buffer
示例:
dmesg | tail -50journalctl
Query and display messages from the journal
示例:
journalctl -u nginx --since '1 hour ago'history
Display the command history list
示例:
history | grep dockerenv
Print environment variables
示例:
env | grep PATHif / then / fi
Conditional execution in shell scripts
示例:
if [ -f file.txt ]; then echo exists; fifor
Loop over a list of items
示例:
for i in 1 2 3; do echo $i; donewhile
Execute commands while a condition is true
示例:
while read line; do echo $line; done < filecase
Multi-branch conditional matching pattern
示例:
case "$var" in a) echo A;; b) echo B;; esacfunction
Define a shell function
示例:
greet() { echo "Hello, $1!"; }; greet Worldexport
Set environment variables for child processes
示例:
export MY_VAR=valuesource
Execute commands from a file in current shell
示例:
source ~/.bashrcalias
Create an alias for a command
示例:
alias ll='ls -la'cron / crontab
Schedule commands to run periodically
示例:
crontab -e # 0 * * * * /path/to/script.shat
Execute commands at a specified time
示例:
echo 'ls /tmp' | at 14:30