본문 바로가기

IT 공부/UNIX + LINUX

[UNIX/Linux] 명령어 매뉴얼을 살펴보자! --help 와 man

안녕하세요~~ 덩덩윤입니다 :-)

 

블로그를 개설하고 첫 글을 작성하게 되었네요!

 

오늘은 UNIX 및 리눅스 명령어의 사용법을 자세히 확인해볼 수 있는 방법을 알아보려고 합니다.

 


 

요 계열의 운영체제들은 대부분 CLI 즉, 키보드로 명령어를 입력받아 사용자가 원하는 기능을 수행합니다.

 

때문에 이 명령어들의 사용법을 숙지하고 있어야만 시스템 운영이 편해질텐데요!

 

UNIX, 리눅스에는 정말정말정말정말정말정말정말정말 많은 명령어가 있습니다,,

 

거기다 명령어마다 옵션도 무지하게 많죠ㅜㅜㅜㅜ

 

물론 자주 사용하는 명령어나 옵션은 머릿속에 박혀있지만,

 

익숙하지 않은 명령어나 옵션에 대해서는 두 가지 방법으로 자세한 사용법을 확인할 수가 있습니다! 

 

바로 --help 옵션과 man 명령어인데요!

 

예를 들어 ls 명령어에 대해서 알고싶다면 ls --help 혹은 man ls 라고 입력하면 됩니다~!

 

그럼 man 명령어를 예시로해서 살펴보겠습니다 ~~!

 


 

1. --help

 

읭?

 

악!!!!!!! man 명령어는 git bash 환경에서는 수행되지 않아요 ㅜㅜㅜ

 

windows OS 에서 리눅스 커맨드를 실행할 수 있는게 git bash인데 ,,,

 

구글링을 살짝 해보니 man 명령어는 git bash에 기본으로 설치되어있지 않다고 하네요!

 

참고한 곳: (https://github.com/swcarpentry/shell-novice/issues/249)

 

그럼 저는 일단 SSH 로 CentOS 가상머신에 붙어서 실행해보겠습니다!

 

$ man --help
Usage: man [OPTION...] [SECTION] PAGE...

  -C, --config-file=FILE     use this user configuration file
  -d, --debug                emit debugging messages
  -D, --default              reset all options to their default values
      --warnings[=WARNINGS]  enable warnings from groff

 Main modes of operation:
  -f, --whatis               equivalent to whatis
  -k, --apropos              equivalent to apropos
  -K, --global-apropos       search for text in all pages
  -l, --local-file           interpret PAGE argument(s) as local filename(s)
  -w, --where, --path, --location
                             print physical location of man page(s)
  -W, --where-cat, --location-cat
                             print physical location of cat file(s)

  -c, --catman               used by catman to reformat out of date cat pages
  -R, --recode=ENCODING      output source page encoded in ENCODING

 Finding manual pages:
  -L, --locale=LOCALE        define the locale for this particular man search
  -m, --systems=SYSTEM       use manual pages from other systems
  -M, --manpath=PATH         set search path for manual pages to PATH

  -S, -s, --sections=LIST    use colon separated section list

  -e, --extension=EXTENSION  limit search to extension type EXTENSION

  -i, --ignore-case          look for pages case-insensitively (default)
  -I, --match-case           look for pages case-sensitively

      --regex                show all pages matching regex
      --wildcard             show all pages matching wildcard

      --names-only           make --regex and --wildcard match page names only,
                             not descriptions

  -a, --all                  find all matching manual pages
  -u, --update               force a cache consistency check

      --no-subpages          don't try subpages, e.g. 'man foo bar' => 'man
                             foo-bar'

 Controlling formatted output:
  -P, --pager=PAGER          use program PAGER to display output
  -r, --prompt=STRING        provide the `less' pager with a prompt

  -7, --ascii                display ASCII translation of certain latin1 chars
  -E, --encoding=ENCODING    use selected output encoding
      --no-hyphenation, --nh turn off hyphenation
      --no-justification,                              --nj   turn off justification
  -p, --preprocessor=STRING  STRING indicates which preprocessors to run:
                             e - [n]eqn, p - pic, t - tbl,
g - grap, r - refer, v - vgrind

  -t, --troff                use groff to format pages
  -T, --troff-device[=DEVICE]   use groff with selected device

  -H, --html[=BROWSER]       use elinks or BROWSER to display HTML output
  -X, --gxditview[=RESOLUTION]   use groff and display through gxditview
                             (X11):
                             -X = -TX75, -X100 = -TX100, -X100-12 = -TX100-12
  -Z, --ditroff              use groff and force it to produce ditroff

  -?, --help                 give this help list
      --usage                give a short usage message
  -V, --version              print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Report bugs to cjwatson@debian.org.

 

여러 옵션들의 용도와 사용법을 확인할 수 있습니다!

 

 


 

 

2. man

 

그럼 man man 을 입력하면 어떻게 될까요?

 

MAN(1)                                                                              Manual pager utils                                                                             MAN(1)

NAME
       man - an interface to the on-line reference manuals

SYNOPSIS
       man  [-C  file]  [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-m system[,...]] [-M path] [-S list] [-e extension] [-i|-I] [--regex|--wildcard] [--names-only] [-a]
       [-u] [--no-subpages] [-P pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justification] [-p string]  [-t]  [-T[device]]  [-H[browser]]  [-X[dpi]]  [-Z]  [[section]
       page ...] ...
       man -k [apropos options] regexp ...
       man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
       man -f [whatis options] page ...
       man  -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z]
       file ...
       man -w|-W [-C file] [-d] [-D] page ...
       man -c [-C file] [-d] [-D] page ...
       man [-?V]

DESCRIPTION
       man is the system's manual pager. Each page argument given to man is normally the name of a program, utility or function.  The manual page associated with each of these arguments
       is  then  found  and  displayed. A section, if provided, will direct man to look only in that section of the manual.  The default action is to search in all of the available sec‐
       tions, following a pre-defined order and to show only the first page found, even if page exists in several sections.

       The table below shows the section numbers of the manual followed by the types of pages they contain.

       1   Executable programs or shell commands
       2   System calls (functions provided by the kernel)
       3   Library calls (functions within program libraries)
       4   Special files (usually found in /dev)
       5   File formats and conventions eg /etc/passwd
       6   Games
       7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
       8   System administration commands (usually only for root)
       9   Kernel routines [Non standard]

       A manual page consists of several sections.

       Conventional section names include NAME, SYNOPSIS, CONFIGURATION, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUE, ERRORS, ENVIRONMENT,  FILES,  VERSIONS,  CONFORMING TO,  NOTES,
       BUGS, EXAMPLE, AUTHORS, and SEE ALSO.

......................................중략........................................

HISTORY
       1990, 1991 - Originally written by John W. Eaton (jwe@che.utexas.edu).

       Dec 23 1992: Rik Faith (faith@cs.unc.edu) applied bug fixes supplied by Willem Kasdorp (wkasdo@nikhefk.nikef.nl).

       30th April 1994 - 23rd February 2000: Wilf. (G.Wilford@ee.surrey.ac.uk) has been developing and maintaining this package with the help of a few dedicated people.

       30th October 1996 - 30th March 2001: Fabrizio Polacco <fpolacco@debian.org> maintained and enhanced this package for the Debian project, with the help of all the community.

       31st March 2001 - present day: Colin Watson <cjwatson@debian.org> is now developing and maintaining man-db.

2.6.3                                                                                   2012-09-17                                                                                 MAN(1)
 Manual page man(1) line 412/465 (END) (press h for help or q to quit)

 

--help 옵션을 달았을때는 내용을 화면에 삐비빅 출력해주고 끝이었지만,

 

man 을 실행하면 별도의 프로세스로 실행이 됩니다! (vi editor 실행하듯이)

 

그리고, --help 옵션을 달았을때보다 훨씬 더 많은 내용을 확인할 수가 있습니다.

 

너무 길어서 중간은 생략했는데요, 맨 아래를 보시면 매뉴얼만 해서 465 라인이네요 .................................. 왜우

 

많기도 하네 ,,,~~

 

또, 이 상태에서 h 키를 누르면 MOVING(화면/라인 이동)이라든지  SEARCHING(탐색) 등등

 

man 명령어 활용법을 확인할 수가 있습니다.

 

매뉴얼의 매뉴얼이라고 볼 수 있겠네요!

 


이렇게 UNIX 및 리눅스 명령어 사용설명서를 볼 수 있는 두 가지 방법을 알아보았습니다!

 

앞으로 공부하면서 요 녀석들을 잘 활용해보도록 해야겠습니다 ,,,~!(물론 구글링도)

 

그럼 오늘 글은 여기서 마치겠습니다 ~~~