TAIL(1) User Commands TAIL(1)
NAME
tail - output the last part of files
SYNOPSIS
tail [OPTION]... [FILE]...
DESCRIPTION
Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-c, --bytes=[+]NUM
output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file
-f, --follow[={name|descriptor}]
output appended data as the file grows;
an absent option argument means 'descriptor'
-F same as --follow=name --retry
-n, --lines=[+]NUM
output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM
--max-unchanged-stats=N
with --follow=name, reopen a FILE which has not
changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files); with inotify, this op‐
tion is rarely useful
--pid=PID
with -f, terminate after process ID, PID dies
-q, --quiet, --silent
never output headers giving file names
--retry
keep trying to open a file if it is inaccessible
-s, --sleep-interval=N
with -f, sleep for approximately N seconds (default 1.0) between iterations; with inotify and --pid=P, check process P at least once every N seconds
-v, --verbose
always output headers giving file names
-z, --zero-terminated
line delimiter is NUL, not newline
--help display this help and exit
--version
output version information and exit
tail은 위의 매뉴얼에도 나와 있듯이 파일의 마지막 일부를 보여주는 명령어 입니다.
tail [옵션들] 파일명
위와 같이 사용할 수 있습니다.
많은 옵션이 있지만, 제가 주로 사용하는 옵션은 -n, -f 입니다. -s도 재미 있는 옵션이겠네요 ^^
제가 일부러 프로그램을 하나 설치해보고 설치하기 전과 설치후를 모니터링 하는 것을 보여 드리겠습니다. ^^
cd /var/log
tail -f dpkg.log
리눅스 로그 폴더로 이동해서 dpkg.log를 모니터링 합니다.
tail -f dpkg.log
2022-12-25 14:16:27 configure libcgi-fast-perl:all 1:2.15-1 <none>
2022-12-25 14:16:27 status unpacked libcgi-fast-perl:all 1:2.15-1
2022-12-25 14:16:27 status half-configured libcgi-fast-perl:all 1:2.15-1
2022-12-25 14:16:27 status installed libcgi-fast-perl:all 1:2.15-1
2022-12-25 14:16:27 trigproc man-db:amd64 2.10.2-1 <none>
2022-12-25 14:16:27 status half-configured man-db:amd64 2.10.2-1
2022-12-25 14:16:28 status installed man-db:amd64 2.10.2-1
2022-12-25 14:16:28 trigproc libc-bin:amd64 2.35-0ubuntu3.1 <none>
2022-12-25 14:16:28 status half-configured libc-bin:amd64 2.35-0ubuntu3.1
2022-12-25 14:16:28 status installed libc-bin:amd64 2.35-0ubuntu3.1
현재 결과는 위와 같습니다.
tail이 끝나면 프롬프트로 나오지만 tail은 해보시면 계속 대기 하고 있습니다.
저는 mc라고 mid-night command를 설치해보겠습니다.
sudo apt install mc
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
bzip2 libssh2-1 mailcap mc-data mime-support unzip
Suggested packages:
bzip2-doc arj catdvi | texlive-binaries dbview djvulibre-bin epub-utils genisoimage gv imagemagick libaspell-dev links | w3m | lynx odt2txt poppler-utils python python-boto
python-tz unar wimtools xpdf | pdf-viewer zip
The following NEW packages will be installed:
bzip2 libssh2-1 mailcap mc mc-data mime-support unzip
0 upgraded, 7 newly installed, 0 to remove and 20 not upgraded.
Need to get 2321 kB of archives.
After this operation, 8819 kB of additional disk space will be used.
Do you want to continue? [Y/n]
실제로 저는 위 명령어를 내렸습니다.
tail -f dpkg.log
2022-12-25 14:16:27 configure libcgi-fast-perl:all 1:2.15-1 <none>
2022-12-25 14:16:27 status unpacked libcgi-fast-perl:all 1:2.15-1
2022-12-25 14:16:27 status half-configured libcgi-fast-perl:all 1:2.15-1
2022-12-25 14:16:27 status installed libcgi-fast-perl:all 1:2.15-1
2022-12-25 14:16:27 trigproc man-db:amd64 2.10.2-1 <none>
2022-12-25 14:16:27 status half-configured man-db:amd64 2.10.2-1
2022-12-25 14:16:28 status installed man-db:amd64 2.10.2-1
2022-12-25 14:16:28 trigproc libc-bin:amd64 2.35-0ubuntu3.1 <none>
2022-12-25 14:16:28 status half-configured libc-bin:amd64 2.35-0ubuntu3.1
2022-12-25 14:16:28 status installed libc-bin:amd64 2.35-0ubuntu3.1
2022-12-26 14:18:15 startup archives unpack
2022-12-26 14:18:15 install bzip2:amd64 <none> 1.0.8-5build1
2022-12-26 14:18:15 status half-installed bzip2:amd64 1.0.8-5build1
2022-12-26 14:18:15 status triggers-pending man-db:amd64 2.10.2-1
2022-12-26 14:18:15 status unpacked bzip2:amd64 1.0.8-5build1
2022-12-26 14:18:15 install libssh2-1:amd64 <none> 1.10.0-3
2022-12-26 14:18:15 status triggers-pending libc-bin:amd64 2.35-0ubuntu3.1
2022-12-26 14:18:15 status half-installed libssh2-1:amd64 1.10.0-3
2022-12-26 14:18:15 status unpacked libssh2-1:amd64 1.10.0-3
2022-12-26 14:18:15 install mailcap:all <none> 3.70+nmu1ubuntu1
2022-12-26 14:18:15 status half-installed mailcap:all 3.70+nmu1ubuntu1
2022-12-26 14:18:16 status unpacked mailcap:all 3.70+nmu1ubuntu1
2022-12-26 14:18:16 install mc-data:all <none> 3:4.8.27-1
2022-12-26 14:18:16 status half-installed mc-data:all 3:4.8.27-1
2022-12-26 14:18:16 status unpacked mc-data:all 3:4.8.27-1
2022-12-26 14:18:16 install mc:amd64 <none> 3:4.8.27-1
2022-12-26 14:18:16 status half-installed mc:amd64 3:4.8.27-1
2022-12-26 14:18:16 status unpacked mc:amd64 3:4.8.27-1
2022-12-26 14:18:16 install mime-support:all <none> 3.66
2022-12-26 14:18:16 status half-installed mime-support:all 3.66
2022-12-26 14:18:16 status unpacked mime-support:all 3.66
2022-12-26 14:18:16 install unzip:amd64 <none> 6.0-26ubuntu3.1
2022-12-26 14:18:16 status half-installed unzip:amd64 6.0-26ubuntu3.1
2022-12-26 14:18:16 status unpacked unzip:amd64 6.0-26ubuntu3.1
2022-12-26 14:18:16 startup packages configure
2022-12-26 14:18:16 configure unzip:amd64 6.0-26ubuntu3.1 <none>
2022-12-26 14:18:16 status unpacked unzip:amd64 6.0-26ubuntu3.1
2022-12-26 14:18:16 status half-configured unzip:amd64 6.0-26ubuntu3.1
2022-12-26 14:18:16 status installed unzip:amd64 6.0-26ubuntu3.1
2022-12-26 14:18:16 configure bzip2:amd64 1.0.8-5build1 <none>
2022-12-26 14:18:16 status unpacked bzip2:amd64 1.0.8-5build1
2022-12-26 14:18:16 status half-configured bzip2:amd64 1.0.8-5build1
2022-12-26 14:18:16 status installed bzip2:amd64 1.0.8-5build1
2022-12-26 14:18:16 configure mc-data:all 3:4.8.27-1 <none>
2022-12-26 14:18:16 status unpacked mc-data:all 3:4.8.27-1
2022-12-26 14:18:16 status half-configured mc-data:all 3:4.8.27-1
2022-12-26 14:18:17 status installed mc-data:all 3:4.8.27-1
2022-12-26 14:18:17 configure libssh2-1:amd64 1.10.0-3 <none>
2022-12-26 14:18:17 status unpacked libssh2-1:amd64 1.10.0-3
2022-12-26 14:18:17 status half-configured libssh2-1:amd64 1.10.0-3
2022-12-26 14:18:17 status installed libssh2-1:amd64 1.10.0-3
2022-12-26 14:18:17 configure mailcap:all 3.70+nmu1ubuntu1 <none>
2022-12-26 14:18:17 status unpacked mailcap:all 3.70+nmu1ubuntu1
2022-12-26 14:18:17 status half-configured mailcap:all 3.70+nmu1ubuntu1
2022-12-26 14:18:17 status installed mailcap:all 3.70+nmu1ubuntu1
2022-12-26 14:18:17 configure mime-support:all 3.66 <none>
2022-12-26 14:18:17 status unpacked mime-support:all 3.66
2022-12-26 14:18:17 status half-configured mime-support:all 3.66
2022-12-26 14:18:17 status installed mime-support:all 3.66
2022-12-26 14:18:17 configure mc:amd64 3:4.8.27-1 <none>
2022-12-26 14:18:17 status unpacked mc:amd64 3:4.8.27-1
2022-12-26 14:18:17 status half-configured mc:amd64 3:4.8.27-1
2022-12-26 14:18:17 status installed mc:amd64 3:4.8.27-1
2022-12-26 14:18:17 trigproc man-db:amd64 2.10.2-1 <none>
2022-12-26 14:18:17 status half-configured man-db:amd64 2.10.2-1
2022-12-26 14:18:17 status installed man-db:amd64 2.10.2-1
2022-12-26 14:18:17 trigproc libc-bin:amd64 2.35-0ubuntu3.1 <none>
2022-12-26 14:18:17 status half-configured libc-bin:amd64 2.35-0ubuntu3.1
2022-12-26 14:18:17 status installed libc-bin:amd64 2.35-0ubuntu3.1
mc 하나 까는데 엄청나게 패키지가 설치되네요 ^^
Ctrl 키와 C를 누르시면 빠져 나옵니다.
오늘은 여기 까지 하고 다음에는 이 아이의 반대인데 head라는 명령어를 한번 공부해 보겠습니다.