
메뉴얼 페이지(줄여서 맨 페이지)는 UNIX 계열 운영체제 대부분에서 사용할 수 있는 내장된 문서들이다.
운영체제마다 구체적인 내용은 다르지만, 이 명령어를 실행해서 다른 명령어에 대해 더 많은 정보를 알아보거나, 리눅스, 혹은 전반적인 시스템에 관한 정보를 찾아볼 수 있다.
man ncal
아래와 같이 ncal에 대한 다양한 정보를 표시한다.
CAL(1) General Commands Manual CAL(1)
NAME
cal, ncal – displays a calendar and the date of Easter
SYNOPSIS
cal [-3hjy] [-A number] [-B number] [[month] year]
cal [-3hj] [-A number] [-B number] -m month [year]
ncal [-3hjJpwy] [-A number] [-B number] [-s country_code] [[month] year]
ncal [-3hJeo] [-A number] [-B number] [year]
ncal [-CN] [-H yyyy-mm-dd] [-d yyyy-mm]
DESCRIPTION
The cal utility displays a simple calendar in traditional format and ncal offers an alternative layout, more options and the date of Easter. The new format is a little cramped but it makes a
year fit on a 25x80 terminal. If arguments are not specified, the current month is displayed.
The options are as follows:
-h Turns off highlighting of today.
-J Display Julian Calendar, if combined with the -e option, display date of Easter according to the Julian Calendar.
-e Display date of Easter (for western churches).
-j Display Julian days (days one-based, numbered from January 1).
-m month
Display the specified month. If month is specified as a decimal number, it may be followed by the letter ‘f’ or ‘p’ to indicate the following or preceding month of that number,
respectively.
-o Display date of Orthodox Easter (Greek and Russian Orthodox Churches).
-p Print the country codes and switching days from Julian to Gregorian Calendar as they are assumed by ncal. The country code as determined from the local environment is marked with an
asterisk.
-s country_code
Assume the switch from Julian to Gregorian Calendar at the date associated with the country_code. If not specified, ncal tries to guess the switch date from the local environment or
falls back to September 2, 1752. This was when Great Britain and her colonies switched to the Gregorian Calendar.
-w Print the number of the week below each week column.
-y Display a calendar for the specified year.
-3 Display the previous, current and next month surrounding today.
-A number
Display the number of months after the current month.
-B number
Display the number of months before the current month.
-C Switch to cal mode.
-N Switch to ncal mode.
-d yyyy-mm
Use yyyy-mm as the current date (for debugging of date selection).
-H yyyy-mm-dd
Use yyyy-mm-dd as the current date (for debugging of highlighting).
A single parameter specifies the year (1–9999) to be displayed; note the year must be fully specified: “cal 89” will not display a calendar for 1989. Two parameters denote the month and year;
:
✅ 문서 읽기를 종료하려면 `q`를 입력하면 된다.
‘less’는 파일의 내용을 터미널에서 페이지 단위로 볼 수 있게 해주는 명령어이다. ‘less’ 명령어는 대형 파일을 한 번에 모두 로드하지 않고, 필요한 부분만 로드하여 메모리 사용을 최소화하는 방식으로 작동한다. 이로 인해, 파일의 특정 부분을 빠르게 탐색할 수 있다.
man 명령어는 이 ‘less’를 기본 페이저(pager)로 사용한다.
| 탐색 명령어 | 동작 |
|---|---|
| 스페이스바 / f(Foward) | 다음 페이지로 가기 |
| b(Back) | 이전 페이지로 가기 |
| h(Help) | 도움말 페이지(키보드 명령어와 탐색 방법에 대한 정보) |
| q | less를 종료 |
| G | 파일의 끝으로 이동 |
| g | 파일의 시작으로 이동 |
일반적으로, 각 man 페이지는 다음과 같은 형식을 따른다.
ncal [-3hJeo] [-A number] [-B number] [year]
ls [OPTION]... [FILE]...
cp [OPTION]… SOURCE DEST
‘SOURCE’와 ‘DEST’는 필수 인수로, 복사할 원본 파일과 대상 파일을 지정해야 한다.
메뉴얼 페이지는 여러 섹션으로 나뉘어 있으며, 각 섹션은 특정 유형의 정보나 명령어를 다룬다.
apropos 명령어와 동일한 역할을 하며, 메뉴얼 페이지의 제목과 설명에서 주어진 키워드를 검색한다. 특정 키워드와 관련된 모든 명령어, 함수, 파일, 라이브러리 등을 찾을 수 있다.
man -k network
ifconfig (8) - configure network interface parameters
netstat (1) - show network status
ping (8) - send ICMP ECHO_REQUEST to network hosts
추가 옵션
man -f [명령어] : 특정 명령어에 대한 요약 정보를 표시함(’whatis’와 동일)man [섹션 번호] [명령어] : 특정 섹션에서 명령어의 메뉴얼 페이지를 표시함( 예 - ‘man 3 printf’)type 명령어는 Unix 및 Unix-like 운영 체제에서 사용자가 입력한 명령어가 내부 명령어인지, 외부 명령어인지, 별칭인지, 함수인지 등 명령어의 유형과 위치를 확인하는 데 사용된다.
type [옵션] [명령어]
-a : PATH 변수에 설정된 모든 경로를 검색하여 명령어의 모든 위치를 출력-t : 명령어의 유형만 출력-p : 명령어의 위치만 출력-P : PATH 변수에 설정된 경로에서 실행 파일의 위치만 검색하여 출력(명령어의 유형이 실행 파일일 경우에만 위치를 출력).alias myls='ls -la'type -a 사용
type -a myls
myls is an alias for ls -la
myls is /usr/bin/ls
→ myls가 별칭(alias)이고, /usr/bin/ls 경로에 있는 실행 파일임을 모두 보여준다.
type -P 사용
type -P myls
/usr/bin/ls
→ myls의 실행 파일 경로만을 보여주고, 별칭은 무시된다.
실행 가능한 프로그램은 보통 /bin, /usr/bin, 또는 /usr/local/bin 디렉토리에 저장된다. 이러한 프로그램들은 컴파일된 이진 파일(컴파일된 바이너리 파일)로, 운영 체제에서 직접 실행될 수 있다.
ls, cp, mkdir 등$ type ls
ls is /bin/ls
쉘 내장 명령어는 쉘의 일부로 포함된 명령어이다. 즉, 이 명령어들은 외부 프로그램이 아니기 때문에 새로운 프로세스를 생성하지 않고도 즉시 실행될 수 있다. 따라서 보통 더 빠르게 실행되며, 쉘의 내부 상태를 조작할 수 있다.
cd, pwd, echo, alias, export 등$ type cd
cd is a shell builtin
쉘 함수는 쉘 스크립트 내에서 정의된 함수로, 특정 작업을 수행하는 명령어 집합이다. 사용자는 쉘 스크립트나 쉘 환경 내에서 필요한 기능을 함수로 정의할 수 있다.
$ my_function() { echo "This is a shell function"; }
$ type my_function
my_function is a function
my_function ()
{
echo "This is a shell function"
}
별칭은 긴 명령어나 복잡한 명령어의 단축형을 정의한 것이다. 별칭을 사용하면 자주 사용하는 명령어를 더 쉽게 입력할 수 있다.
alias ll='ls -l'.bashrc 또는 .bash_profile 파일에 정의하여 쉘 시작 시 자동으로 로드되도록 한다.$ alias ll='ls -l'
$ type ll
ll is aliased to `ls -l'
명령어의 경로를 찾아 출력한다. 실행 파일이 시스템의 어느 경로에 위치해 있는지를 확인하는 데 사용된다. which 명령어는 PATH 환경 변수에 설정된 디렉토리에서 실행 파일을 검색한다.
which [옵션] [명령어]
which ls
[출력] - ls 명령어의 실행 파일이 /bin/ls 경로에 있음을 나타냄.
/bin/ls
-a : PATH에 설정된 모든 경로를 검색하여, 해당 명령어에 대한 모든 위치를 출력한다. 기본적으로는 첫 번째로 발견된 경로만 출력한다.
which -a python
[출력]
/usr/bin/python
/usr/local/bin/python
PATH 환경 변수는 쉘이 실행 파일을 찾을 때 검색할 디렉토리들의 목록을 저장하고 있다. 이 변수에 설정된 디렉토리들은 콜론(:)으로 구분된다. 예를 들어, 다음과 같은 PATH 설정이 있다고 가정해 보자.
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
이 경우, PATH 변수에는 /usr/local/bin, /usr/bin, /bin, /usr/sbin, /sbin 디렉토리가 포함되어 있다.
which 명령어는 사용자가 입력한 명령어가 PATH 환경 변수에 나열된 디렉토리들 중 어디에 위치해 있는지 찾는다. 예를 들어, ls 명령어를 찾으려면 다음과 같이 실행할 수 있다.
which ls
which 명령어는 다음 순서로 동작한다.
PATH 변수에 나열된 첫 번째 디렉토리(/usr/local/bin)에서 ls라는 실행 파일이 있는지 확인한다.ls 파일이 없다면, 두 번째 디렉토리(/usr/bin)에서 ls 파일을 찾는다.PATH 변수에 나열된 모든 디렉토리에 대해 반복한다.PATH 환경 변수는 쉘이 명령어를 찾을 때 검색할 디렉토리 목록을 정의한다.which 명령어는 PATH 변수에 설정된 디렉토리들을 순서대로 검색하여, 사용자가 입력한 명령어의 실행 파일을 찾는다.쉘 내장 명령어의 도움말을 출력하는 명령어
help cd
cd: cd [-L|-P] [dir]
Change the current directory to DIR. The variable $HOME is the
default DIR. 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, i.e. `.'. 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, then try the word as a variable
name. If that variable has a value, then cd to the value of that
variable. The -P option says to use the physical directory structure
instead of following symbolic links; the -L option forces symbolic links
to be followed.
💡 less 프로그램이 아니기 때문에 스크롤 등에 사용했던 단축키도 사용할 수 없다. `man` 으로 도움말을 볼 수 없는 명령어는 `help` 로 도움말을 확인해 보면 된다.
help export
export: export [-nf] [name[=value] ...] or export -p
NAMEs are marked for automatic export to the environment of
subsequently executed commands. If the -f option is given,
the NAMEs refer to functions. If no NAMEs are given, or if `-p'
is given, a list of all names that are exported in this shell is
printed. An argument of `-n' says to remove the export property
from subsequent NAMEs. An argument of `--' disables further option
processing.