همه ابزارها
رایگان

مرجعی قابل‌جستجو و چاپ از Bash / shell — پیمایش، فایل‌ها، pipeها، متغیرها، حلقه‌ها، شرط‌ها و one-linerهای کاربردی. رایگان.

Navigation

8
pwd
Print the working directory
ls -la
List all files with details
cd /path
Change directory
cd -
Go to the previous directory
cd ~
Go to the home directory
tree -L 2
Show directory tree (2 levels)
pushd / popd
Push and pop the directory stack
ls -lhS
List by size, human-readable

Files & directories

10
touch file.txt
Create an empty file
mkdir -p a/b/c
Create nested directories
cp -r src dest
Copy recursively
mv old new
Move or rename
rm -rf dir
Remove recursively (careful!)
ln -s target link
Create a symbolic link
cat file.txt
Print file contents
head -n 20 / tail -n 20
First / last 20 lines
tail -f log.txt
Follow a file as it grows
less file.txt
Page through a file

Search & find

8
grep 'pattern' file
Search for a pattern in a file
grep -rin 'text' .
Recursive, case-insensitive, numbered
find . -name '*.php'
Find files by name
find . -type f -mtime -1
Files modified in the last day
find . -size +10M
Files larger than 10 MB
which node
Locate an executable
locate file.txt
Find by indexed database
grep -v 'skip' file
Invert match (exclude lines)

Text processing

9
wc -l file
Count lines
sort file | uniq -c
Sort then count duplicates
cut -d',' -f1 file
Extract a CSV column
awk '{print $1}' file
Print the first field
sed 's/old/new/g' file
Substitute text
tr 'a-z' 'A-Z'
Translate characters
diff a.txt b.txt
Compare two files
tee out.txt
Write to a file and stdout
xargs -I{} cmd {}
Build commands from input

Pipes & redirection

9
a | b
Pipe output of a into b
cmd > file
Redirect stdout (overwrite)
cmd >> file
Redirect stdout (append)
cmd 2> err.log
Redirect stderr
cmd > out 2>&1
Redirect both streams
cmd < input.txt
Read stdin from a file
cmd1 && cmd2
Run cmd2 only if cmd1 succeeds
cmd1 || cmd2
Run cmd2 only if cmd1 fails
cmd &
Run in the background

Permissions & ownership

8
chmod 755 file
Set rwx for owner, rx for others
chmod +x script.sh
Make a file executable
chmod -R 644 dir
Recursive permission change
chown user:group file
Change owner and group
umask 022
Default permission mask
sudo cmd
Run a command as root
stat file
Show file metadata
ls -l file
View permission bits

Processes & system

9
ps aux
List running processes
top / htop
Live process monitor
kill -9 PID
Force-kill a process
pkill -f name
Kill processes by name
jobs / fg / bg
Manage background jobs
df -h
Disk space usage
du -sh dir
Size of a directory
free -h
Memory usage
uname -a
System and kernel info

Variables & expansion

9
NAME='value'
Set a variable (no spaces)
echo \"$NAME\"
Use a variable
export PATH=\"$PATH:/x\"
Export to child processes
$(command)
Command substitution
${VAR:-default}
Default if unset
$1 $2 $@
Script positional arguments
$?
Exit status of the last command
read -p 'Name: ' x
Read user input
echo {1..5}
Brace expansion

Scripting

9
#!/usr/bin/env bash
Shebang line
set -euo pipefail
Safer strict mode
if [ -f file ]; then ...; fi
Conditional on a file test
[ \"$a\" = \"$b\" ]
String comparison
for f in *.txt; do ...; done
Loop over files
while read line; do ...; done < file
Read a file line by line
case \"$x\" in a) ...;; esac
Multi-way branch
function greet() { echo hi; }
Define a function
trap cleanup EXIT
Run a handler on exit

هیچ موردی با «:q» مطابقت ندارد.


درباره برگهٔ تقلب Shell

این جزوه‌ی مرجع Bash و شل، خط فرمان را از قدم اول تا اسکریپت‌نویسی پوشش می‌دهد: پیمایش، فایل‌ها و دایرکتوری‌ها، جست‌وجو و پیدا کردن، پردازش متن، پایپ و ریدایرکت، مجوزها و مالکیت، پردازش‌ها و اطلاعات سیستم، متغیرها و بسط آن‌ها، و ساختارهای اسکریپت‌نویسی شل.

این جزوه دستورهای روزمره — ls، cp، grep، find، chmod، ps — را همراه با پرچم‌هایی که آن‌ها را کاربردی می‌کنند ارائه می‌دهد، به‌علاوه‌ی نحو پایپ، ریدایرکت و بسط که دستورهای تکی را به یک‌خطی‌های کارآمد تبدیل می‌کند. بخش اسکریپت‌نویسی هم نحو حلقه، شرط و تابع را وقتی سالی یک‌بار اسکریپت می‌نویسید یادآوری می‌کند.

همه‌چیز در یک صفحه‌ی رایگان و سمت کاربر جمع شده است: جست‌وجو ردیف‌ها را به‌صورت زنده فیلتر می‌کند، فهرست مطالب چسبان بین بخش‌ها می‌پرد، یک کلیک هر دستور را کپی می‌کند و دکمه‌ی چاپ یک مرجع ترمینال برای روی میزتان می‌سازد.

نحوه استفاده از برگهٔ تقلب Shell

  1. بخش‌ها را مرور کنید، از پیمایش و فایل‌ها و دایرکتوری‌ها تا پایپ و ریدایرکت و اسکریپت‌نویسی.
  2. نام دستوری مثل grep یا chmod را در کادر جست‌وجو تایپ کنید تا جزوه فوراً فیلتر شود.
  3. با نوار کناری چسبان به بخشی مانند پردازش متن بروید.
  4. روی یک دستور یا آیکن کپی آن کلیک کنید تا کپی شود، سپس آن را در ترمینال خود جای‌گذاری کنید.
  5. صفحه را چاپ کنید تا یک مرجع آفلاین دستورهای Bash داشته باشید.

سوالات متداول

این جزوه برای Bash و شل‌های سبک POSIX نوشته شده، بنابراین تقریباً همه‌چیز بدون تغییر در bash، zsh و شل‌های مشابه روی لینوکس و macOS کار می‌کند.

هر دو. در کنار دستورهای فایل، جست‌وجو، پردازش متن و پردازش‌ها، بخش‌های ویژه‌ای متغیرها و بسط و همچنین ساختارهای اسکریپت‌نویسی — حلقه‌ها، شرط‌ها و نحوی که بین اسکریپت‌ها فراموش می‌کنید — را پوشش می‌دهند.

بله. روی دستور یا آیکن کپی در ردیف آن کلیک کنید تا در کلیپ‌بورد شما قرار گیرد و آماده‌ی جای‌گذاری در ترمینال شود.

همیشه پیش از اجرای هر دستور آن را بخوانید، به‌خصوص هر چیزی که rm، مجوزها یا ریدایرکت در آن دخیل است. هر ردیف یک توضیح یک‌خطی از کاری که دستور دقیقاً انجام می‌دهد دارد.

بله، کاملاً رایگان — یک صفحه‌ی مرجع سمت کاربر بدون نیاز به حساب کاربری و بدون محدودیت.

اشتراک‌گذاری

جستجوهای پرطرفدار
linux commands cheat sheet bash cheat sheet shell commands list grep and find examples bash scripting reference chmod permissions cheat sheet pipes and redirection bash terminal commands list
به کمک نیاز دارید؟
با این ابزار مشکلی پیدا کردید؟ به تیم ما اطلاع دهید.
گزارش مشکل

این ابزار رایگان را به وب‌سایت خود اضافه کنید — کد زیر را کپی و جای‌گذاری کنید.