Bash Commands

uname -a

نمایش سیستم و کرنل (Show system and kernel)

head -n1 /etc/issue

نمایش توزیع (Show distribution)

mount

نمایش فایل‌سیستم‌های مانت‌شده (Show mounted filesystems)

date

نمایش تاریخ سیستم (Show system date)

uptime

نمایش آپ‌تایم (Show uptime)

whoami

نمایش نام کاربری (Show your username)

man command

نمایش راهنمای دستور (Show manual for command)

Bash Shortcuts

CTRL-c

توقف دستور فعلی (Stop current command)

CTRL-z

تعلیق برنامه (Sleep program)

CTRL-a

برو به ابتدای خط (Go to start of line)

CTRL-e

برو به انتهای خط (Go to end of line)

CTRL-u

برش از ابتدای خط (Cut from start of line)

CTRL-k

برش تا انتهای خط (Cut to end of line)

CTRL-r

جستجو در تاریخچه (Search history)

!!

تکرار آخرین دستور (Repeat last command)

!abc

اجرای آخرین دستور با شروع abc (Run last command starting with abc)

!abc:p

چاپ آخرین دستور با شروع abc (Print last command starting with abc)

!$

آخرین آرگومان دستور قبلی (Last argument of previous command)

ALT-.

آخرین آرگومان دستور قبلی (Last argument of previous command)

!*

تمام آرگومان‌های دستور قبلی (All arguments of previous command)

^abc^123

اجرای دستور قبلی، جایگزینی abc با 123 (Run previous command, replacing abc with 123)

Bash Variables

env

نمایش متغیرهای محیطی (Show environment variables)

echo $NAME

چاپ مقدار متغیر $NAME (Output value of $NAME variable)

export NAME=value

تنظیم $NAME برابر value (Set $NAME to value)

$PATH

مسیر جستجوی اجرایی‌ها (Executable search path)

$HOME

دایرکتوری خانگی (Home directory)

$SHELL

شل فعلی (Current shell)

IO Redirection & Pipes

cmd < file

ورودی cmd از فایل (Input of cmd from file)

cmd1 <(cmd2)

خروجی cmd2 به عنوان ورودی فایل به cmd1 (Output of cmd2 as file input to cmd1)

cmd > file

خروجی استاندارد (stdout) به فایل (Standard output (stdout) of cmd to file)

cmd > /dev/null

نادیده گرفتن stdout (Discard stdout of cmd)

cmd >> file

افزودن stdout به انتهای فایل (Append stdout to file)

cmd 2> file

خروجی خطا (stderr) به فایل (Error output (stderr) of cmd to file)

cmd >&2

هدایت stdout به stderr (stdout to same place as stderr)

cmd 2>&1

هدایت stderr به stdout (stderr to same place as stdout)

cmd &> file

تمام خروجی‌ها به فایل (Every output of cmd to file)

cmd1 | cmd2

هدایت stdout از cmd1 به cmd2 (stdout of cmd1 to cmd2)

cmd1 |& cmd2

هدایت stderr از cmd1 به cmd2 (stderr of cmd1 to cmd2)

cmd1 ; cmd2

اجرای cmd1 سپس cmd2 (Run cmd1 then cmd2)

cmd1 && cmd2

اجرای cmd2 اگر cmd1 موفق بود (Run cmd2 if cmd1 is successful)

cmd1 || cmd2

اجرای cmd2 اگر cmd1 موفق نبود (Run cmd2 if cmd1 is not successful)

{ cmd }

اجرای cmd در ساب‌شل (Run cmd in a subshell)

Directory & File Operations

pwd

نمایش دایرکتوری فعلی (Show current directory)

mkdir dir

ساخت دایرکتوری dir (Make directory dir)

cd dir

تغییر به دایرکتوری dir (Change directory to dir)

cd ..

برو به دایرکتوری بالاتر (Go up a directory)

touch file1

ساخت فایل file1 (Create file1)

cat file1 file2

چسباندن و نمایش فایل‌ها (Concatenate files and output)

less file1

نمایش صفحه‌بندی شده file1 (View and paginate file1)

file file1

دریافت نوع فایل file1 (Get type of file1)

cp file1 file2

کپی file1 در file2 (Copy file1 to file2)

mv file1 file2

انتقال file1 به file2 (Move file1 to file2)

rm file1

حذف file1 (Delete file1)

head file1

نمایش ۱۰ خط اول file1 (Show first 10 lines of file1)

tail file1

نمایش ۱۰ خط آخر file1 (Show last 10 lines of file1)

tail -f file1

نمایش زنده خطوط آخر (Output last lines of file1 as it changes)

ls Options

ls -a

نمایش همه (شامل مخفی‌ها) (Show all (including hidden))

ls -R

لیست بازگشتی (Recursive list)

ls -r

ترتیب معکوس (Reverse order)

ls -t

مرتب‌سازی بر اساس زمان (Sort by last modified)

ls -S

مرتب‌سازی بر اساس اندازه (Sort by file size)

ls -l

فرمت لیست طولانی (Long listing format)

ls -1

یک فایل در هر خط (One file per line)

ls -m

خروجی با جداکننده کاما (Comma-separated output)

ls -Q

خروجی داخل کوتیشن (Quoted output)

Search Files

grep pattern files

جستجوی pattern در files (Search for pattern in files)

grep -i

جستجوی بدون حساسیت به حروف (Case insensitive search)

grep -r

جستجوی بازگشتی (Recursive search)

grep -v

جستجوی معکوس (Inverted search)

grep -o

فقط نمایش بخش مچ‌شده (Show matched part of file only)

find /dir/ -name name*

پیدا کردن فایل با اسم name* در dir (Find files starting with name in dir)

find /dir/ -user name

پیدا کردن فایل‌های کاربر name در dir (Find files owned by name in dir)

find /dir/ -mmin num

فایل‌های تغییرکرده در num دقیقه اخیر (Find files modifed less than num minutes ago)

whereis command

پیدا کردن binary/source/manual دستور (Find binary / source / manual for command)

locate file

پیدا کردن فایل (جستجوی سریع ایندکس) (Find file (quick search of system index))

Process Management

ps

نمایش اسنپ‌شات پراسس‌ها (Show snapshot of processes)

top

نمایش زنده پراسس‌ها (Show real time processes)

kill pid

کشتن پراسس با ID (Kill process with id pid)

pkill name

کشتن پراسس با نام (Kill process with name name)

killall name

کشتن تمام پراسس‌ها با نام (Kill all processes with names beginning name)

Nano & Screen Shortcuts

Nano

Ctrl-R

خواندن فایل (Read file)

Ctrl-O

ذخیره فایل (Save file)

Ctrl-X

بستن فایل (Close file)

ALT-A

شروع انتخاب متن (Start marking text)

CTRL-K

برش متن یا خط (Cut marked text or line)

CTRL-U

چسباندن متن (Paste text)

ALT-/

انتهای فایل (End of file)

CTRL-A

ابتدای خط (Beginning of line)

CTRL-E

انتهای خط (End of line)

CTRL-C

نمایش شماره خط (Show line number)

CTRL-_

برو به خط (Go to line number)

CTRL-W

جستجو (Find)

ALT-W

پیدا کردن بعدی (Find next)

CTRL-\

جستجو و جایگزینی (Search and replace)

Screen

screen

شروع session جدید (Start a screen session.)

screen -r

اتصال مجدد به session (Resume a screen session.)

screen -list

نمایش session های فعلی (Show your current screen sessions.)

CTRL-A c

ساخت ترمینال جدید (Create a new terminal.)

CTRL-A n

رفتن به ترمینال بعدی (Go to the next terminal.)

CTRL-A p

رفتن به ترمینال قبلی (Go to the previous terminal.)

CTRL-A "

نمایش لیست ترمینال‌ها (Show current terminals.)

CTRL-A A

تغییر نام ترمینال فعلی (Rename the current instance.)

File Permissions

4

خواندن (read (r))

2

نوشتن (write (w))

1

اجرا (execute (x))

chmod 644 file

تغییر دسترسی به rw-r--r-- (Change mode to rw-r--r--)

chmod -R 750 folder

تغییر دسترسی بازگشتی به rwxr-x--- (Recursively chmod to rwxr-x---)

chown usr:grp file

تغییر مالک (usr) و گروه (grp) (Change owner to usr, group to grp)