Chuyển đổi miễn phí

Linux / Bash Bảng lệnh gian lận

Bảng cheat lệnh Linux và Bash toàn diện. Tìm kiếm hơn 80 lệnh cần thiết kèm theo ví dụ, mô tả và sao chép bằng một cú nhấp chuột.

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

Về công cụ này

Hướng dẫn tham khảo nhanh toàn diện về bash linux. Duyệt qua các lệnh, cú pháp và ví dụ thường dùng được sắp xếp theo danh mục. Có thể tìm kiếm và thân thiện với thiết bị di động — đánh dấu trang này để truy cập ngay khi bạn cần lời nhắc nhanh.

Cách sử dụng

  1. Duyệt qua các phần tham khảo được phân loại.
  2. Sử dụng thanh tìm kiếm để tìm các lệnh hoặc cú pháp cụ thể.
  3. Nhấp vào bất kỳ mục nào để xem ví dụ sử dụng và giải thích.
  4. Sao chép lệnh trực tiếp để sử dụng trong terminal hoặc trình soạn thảo của bạn.

Câu hỏi thường gặp

Tài liệu tham khảo này có được cập nhật không?
Tài liệu tham khảo bao gồm các lệnh và cú pháp được sử dụng rộng rãi, ổn định trên các phiên bản. Để biết các bổ sung mới nhất hoặc các tính năng dành riêng cho phiên bản, hãy kiểm tra tài liệu chính thức.
Tôi có thể sử dụng tính năng này ngoại tuyến không?
Sau khi tải, trang hoạt động mà không cần kết nối internet. Đánh dấu nó để truy cập nhanh - tất cả nội dung được hiển thị trong trình duyệt mà không cần yêu cầu mạng thêm.
Đây có phải là toàn diện hay chỉ là những điều cơ bản?
Nó bao gồm các lệnh và mẫu được sử dụng phổ biến nhất để xử lý 90% công việc hàng ngày. Đối với các tính năng thích hợp hoặc nâng cao, hãy tham khảo tài liệu chính thức.
Tôi có thể đề xuất bổ sung không?
Chúng tôi thường xuyên cập nhật tài liệu tham khảo của chúng tôi. Nếu bạn nhận thấy các lệnh bị thiếu hoặc có đề xuất, hãy cho chúng tôi biết thông qua trang liên hệ của chúng tôi.