From 5300bfa6bf14f2a7763dc5371fb27410fb519902 Mon Sep 17 00:00:00 2001 From: Mustafa Al-Saegh Date: Wed, 27 Jan 2016 22:49:56 +1100 Subject: [PATCH] everyday use 2/3 --- README-ar.md | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/README-ar.md b/README-ar.md index 4f2b9b1..d7260b4 100644 --- a/README-ar.md +++ b/README-ar.md @@ -134,28 +134,45 @@ Unices, MacOS, Cygwin الكثير من الملاحظات يمكن تطبيقه اذا كنت قد كتبت جزءا من ايعاز ما وققرت ان لاتنفذ الايعاز في حينها، يمكنك استخدام alt-# لأضافة # الى بداية الأيعاز مما سيحولة الى تعليق\ملاحظة (كذلك يمكنك استخدام #، ctrl+a ،enter). يمكنك فيما بعد العودة الى نفس الأيعاز عن طريق البحث في الأيعازات المدخلة سابقا (history).

+-

+استعن بـxargs (او parallel). تمكنك هذة الأدوات المفيدة من كتابة أوامر ذات عدة اسطر. لاحظ انه يمكنك تحديد عدد الأوامر التي تود تنفيذها في السطر الواحد (-L) كما يمكنك ايضا تنفيذ الأوامر بالتوازي (-P). اذا كنت غير واثقا من النتائج المرجوة من الأيعاز الذي تود\تودين تنفيذة، يمكنك الأستعانة بـ xargs echo اولا (أو -I{}). بعض الأمثلة: +find . -name '*.py' | xargs grep some_function +cat hosts | xargs -I{} ssh root@{} hostname + +

-- Use `xargs` (or `parallel`). It's very powerful. Note you can control how many items execute per line (`-L`) as well as parallelism (`-P`). If you're not sure if it'll do the right thing, use `xargs echo` first. Also, `-I{}` is handy. Examples: -```bash - find . -name '*.py' | xargs grep some_function - cat hosts | xargs -I{} ssh root@{} hostname -``` +-

+ايعاز pstree -p يعرض شجرة الاعمال(processes) الحالية. +

-- `pstree -p` is a helpful display of the process tree. +-

+يمكنك pgrep وpkill من تمييز وايقاف وحدة عمل ما (process) حسب الأسم. (-f مفيدة ايضا). +

-- Use `pgrep` and `pkill` to find or signal processes by name (`-f` is helpful). +-

+تعلم الاشارات المختلفة التي يمكنك ارسالها الى وحدات العمل(processes). على سبيل المثال، لأيقاف وحدة عمل ما: kill -STOP [pid]. لرؤية كافة الأشارات استعن بـman 7 signal. +

-- Know the various signals you can send processes. For example, to suspend a process, use `kill -STOP [pid]`. For the full list, see `man 7 signal` +-

+لأبقاء برنامج ما يعمل (حتى بعد خروجك من واجهة Bash) استخدم nohup او disown. +

-- Use `nohup` or `disown` if you want a background process to keep running forever. +-

+لمعرفة البرامج التي تستخدم منافذ اتصالTCP (مايعرف بـ ports)استخدم netstat -lntp او ss -plat. (اضف -u لمعرفة البرامج التي تستخدم منافذ UDP) +

-- Check what processes are listening via `netstat -lntp` or `ss -plat` (for TCP; add `-u` for UDP). +-

+يمكنك lsof من معرفة الأتصالات المفتوحه في النظام والملفات التي تستخدمها. +

-- See also `lsof` for open sockets and files. -- See `uptime` or `w` to know the how long the system has been running. +-

+لمعرفة الوفت المنصرم منذ تشغيل النظام، استخدم uptime او w. +

-- Use `alias` to create shortcuts for commonly used commands. For example, `alias ll='ls -latr'` creates a new alias `ll`. +-

+يمكنك alias من تأليف\كتابة مختصرات للمهام التي تنفذها\تنفذيها يوميا، مثلا: alias='ls -latr' سيخلق مختصر ll لتنفيذ ايعاز ls -latr. +

- In Bash scripts, use `set -x` (or the variant `set -v`, which logs raw input, including unexpanded variables and comments) for debugging output. Use strict modes unless you have a good reason not to: Use `set -e` to abort on errors (nonzero exit code). Use `set -u` to detect unset variable usages. Consider `set -o pipefail` too, to on errors within pipes, too (though read up on it more if you do, as this topic is a bit subtle). For more involved scripts, also use `trap` on EXIT or ERR. A useful habit is to start a script like this, which will make it detect and abort on common errors and print a message: ```bash