در این قسمت سعی من بر این هست که میانبرهایی رو در یونیکیس برای شما قرار بدهم که معمولا به خاطر استفاده نکردن زیاد ممکن هست یادتون بره، اما کاربرد اونها خیلی زیاد هست و اگر بدونیدشون خیلی جاها می تونه خیلی سریع کمکتون کنه:

میانبر ها در CLI
  • ctrl+a — move cursor to beginning of line
  • ctrl+e — move cursor to end of line
  • ctrl+u — clear to beginning of line
  • ctrl+k — clear to end of line
فایل سیستم
  • cp -r dir1 dir - copy directory dir1 to dir2
  • ln -s file link — create a soft symbolic link to file - soft
  • ln file link — create a hard symbolic link to file - hard
  • less file — view file with page navigation
  • head file — output the first 10 lines of file
  • tail file — output the last 10 lines of file
  • tail -f file — output the contents of file as it grows
سیستم
  • shutdown — shut down machine
  • reboot — restart machine
  • df — show disk usage
  • du — show directory space usage
جستجو
  • grep pattern files — search for pattern in files
  • grep -r pattern dir — search recursively for pattern in dir
  • grep -rn pattern dir — search recursively for pattern in dir and show the line number found
  • grep -r pattern dir --include='*.ext — search recursively for pattern in dir and only search in files with .ext extension
  • grep -E pattern files — search for pattern using Extended regexp in files
  • command | grep pattern — search for pattern in the output of command
  • find file* — find all instances of file in real system
  • find . -iname 'string*' - find file case insensitive with a pattern
  • find -L . -iname '*.js' -exec chmod 744 {} \; - find js files and change mode to 644 within this directory
  • find /var/log/ -iname '*.tmp' -delete - find .tmp files within that directory and delete them
  • locate file — find all instances of file using indexed database built from the updatedb command. Much faster than find
  • sed -i 's/day/night/g' file — find all occurrences of day in a file and replace them with night - s means substitude and g means global - sed also supports regular expressions
  • sed -i -- 's/old/new/g' */**(.D) find and replace old string with new string withing this folder and all its subfolder
مدیریت پروسه ها
  • ps — display your currently active processes
  • top — display all running processes
  • kill pid — kill process id pid
  • kill -9 pid — force kill process id pid
شبکه
  • scp [email protected]:file dir — secure copy a file from remote server to the dir directory on your machine
  • scp file [email protected]:dir — secure copy a file from your machine to the dir directory on a remote server
  • scp -r [email protected]:dir dir — secure copy the directory dir from remote server to the directory dir on your machine
  • ssh -p port [email protected] — connect to host on port as user
  • ssh-copy-id [email protected] — add your key to host for user to enable a keyed or passwordless login
  • ping host — ping host and output results
  • whois domain — get information for domain
  • dig domain — get DNS information for domain
  • dig -x host — reverse lookup host
  • lsof -i tcp:1337 — list all processes running on port 1337
زیپ و آنزیپ
  • tar cvzf file.tar.gz files — create a tar with Gzip compression
  • tar cafxz file.tar.gz — extract a tar using Gzip
اجازه ها
  • chmod ugo file — change permissions of file to ugo - u is the user's permissions, g is the group's permissions, and o is everyone else's permissions. The values of u, g, and o can be any number between 0 and 7.
  • x = 1
  • w = 2
  • r = 4
  • u = user
  • g = group
  • o = other

مثال

  • u+rwx
  • g=r
  • 0-rwx
  • 777 = a+rwx