تک دیک

واژه نامه و مجله آموزشی کامپیوتر و فناوری

خط فرمان لینوکس – مشاهده مستندات و راهنمای دستورات

دریافت مستندات یک دستور

با دانستن اینکه دستور چیست، حالا می‌توانیم مستندات در دسترس برای هر نوع دستور را جستجو کنیم.

help – دریافت کمک برای (دستورات) داخلی شل

bash مجهز به یک قابلیت کمک داخلی برای هر یک از (دستورات) داخلی شل است. برای استفاده از آن، “help” را تایپ کنید و پس از آن نام (دستور) داخلی شل را وارد کنید. اینجا یک مثال هست:

[me@linuxbox ~]$ help cd
cd: cd [-L|[-P [-e]] [-@]] [dir] 
    Change the shell working directory. 
    Change the current directory to DIR. The default DIR is the value of the HOME shell variable. 
    The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the same as the current directory. If DIR begins with a slash (/), then CDPATH is not used. 
    If the directory is not found, and the shell option `cdable_vars' is set, the word is assumed to be a variable name. If that variable has a value, its value is used for DIR. 
    Options: 
        -L force symbolic links to be followed: resolve symbolic links in DIR after processing instances of `..' 
        -P use the physical directory structure without following symbolic links: resolve symbolic links in DIR before processing instances of `..' 
        -e if the -P option is supplied, and the current working directory cannot be determined successfully, exit with a non-zero status
        -@ on systems that support it, present a file with extended attributes as a directory containing the file attributes
    The default is to follow symbolic links, as if `-L' were specified. `..' is processed by removing the immediately previous pathname component back to a slash or the beginning of DIR. 
    Exit Status: 
Returns 0 if the directory is changed, and if $PWD is set successfully when -P is used; non-zero otherwise.

یک نکته در مورد نشانه‌گذاری: هنگامی که براکت‌های مربعی در توضیحات سینتکس یک دستور ظاهر می‌شوند، موارد اختیاری را نشان می‌دهند. یک کاراکتر خط عمودی، موارد مانعة الجمع (Mutually exclusive) را نشان می‌دهد. در مورد دستور cd بالا:

cd [-L|[-P[-e]]] [dir]

این نشانه‌گذاری می‌گوید دستور cd ممکن است به شکل اختیاری با یک "-L" یا یک "-P" دنبال شود، به علاوه اگر آپشن "-P" مشخص شده باشد، ممکن است آپشن "-e" نیز گنجانده شود و به دنبال آن آرگومان اختیاری "dir" ظاهر شود.

در حالی که خروجی help برای دستور cd مختصر و دقیق است، اما به هیچ وجه آموزشی نیست و همانطور که می‌بینیم به نظر می‌رسد بسیاری از مواردی که ما هنوز در مورد آن‌ها صحبت نکرده‌ایم را ذکر کرده است! نگران نباشید. ما به آنجا می‌رسیم.

--help نمایش اطلاعات استفاده

بسیاری از برنامه‌های اجرایی از آپشن "--help" پشتیبانی می‌کنند که شرح سینتکس و آپشن‌های پشتیبانی شده دستور را نمایش می‌دهد. به عنوان مثال:

[me@linuxbox ~]$ mkdir --help
Usage: mkdir [OPTION] DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.
    -Z, --context=CONTEXT (SELinux) set security context to CONTEXT Mandatory arguments to long options are mandatory for short options too.
    -m, --mode=MODE set file mode (as in chmod), not a=rwx – umask
    -p, --parents no error if existing, make parent directories as needed
    -v, --verbose print a message for each created directory
    --help display this help and exit
    --version output version information and exit
Report bugs to <bug-coreutils@gnu.org>.

برخی برنامه ها از آپشن "--help" پشتیبانی نمی‌کنند، اما به هر حال آن را امتحان کنید. اغلب منجر به پیام خطایی می‌شود که همان اطلاعاتِ (نحوه) استفاده را نمایش می‌دهد.


متن بالا بخشی از ترجمه کتاب The Linux Command Line (به فارسی: خط فرمان لینوکس) نوشته William Shotts است که نسخه اصلی آن از طریق وبسایت رسمی کتاب (https://linuxcommand.org) قابل دسترسی است. (فهرست مطالب کتاب خط فرمان لینوکس).

امیرحسین شهسواری

عاشق دنیای رایانه و فناوری به خصوص برنامه نویسی هستم؛ یادگرفتن و البته یاد دادن چیزای جالبی که یاد گرفتم باعث خوشحالیم میشه و از اولویت‌های اصلی زندگیم به حساب میاد. از مدیریت و نوشتن در تک دیک هم واقعا لذت می‌برم :)

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *