리눅스에서 설정파일이나 스크립트 파일을 수정한 뒤에 재부팅을 하지않고, 수정내용을 바로 적용하려면 source 명령을 수행하면 된다.

source 명령은 bash 내부 명령으로 포함되어있다.


  • $ source <script file>


Posted by leechwin
,

리눅스에서는 로그파일을 실시간으로 확인하는 방법중에 하나로 tail 명령에 대해 알아보자.


  • Tail
    • $ tail -f <대상파일>
    • 위와 같이 실행하면 대상 파일의 마지막 10라인을 출력하며, 해당 파일에 추가되는 행을 계속 출력하여 준다.


  • 옵션
    • f: 파일의 마지막 10라인을 실시간으로 계속 해서 출력한다.
    • n: 기본 10라인이 아닌 n 만큼의 라인을 출력한다.
      • $ tail -n 20 <대상파일>


  • Help 문서

  •  Usage: tail [OPTION]... [FILE]...

     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 option 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



Posted by leechwin
,

리눅스에서는 파일이나 디렉토리를 연결하는 링크의 개념이 있는데, 이 링크를 'ln' 명령으로 만들 수 있다.

링크는 하드링크(hard link)와 심볼릭링크(symbolic link) 2개의 종류로 만들 수 있다.

  • 하드링크
    • 하드링크 생성
      • $ ln <source> <target>
    • 하드링크는 원본파일과 동일한 내용의 다른 파일이다.
    • 원본파일의 내용이 변경되면 하드링크된 파일의 내용도 자동으로 변경된다.
    • 디렉토리는 하드링크 할 수 없다.


  • 심볼릭링크
    • 심볼릭링크 생성
      • $ ln -s <source> <target>
    • 심볼릭링크는 기존 파일을 가리키도록 링크만 되어있는 특별한 유형의 파일로 '바로가기'와 비슷한 파일이다.
    • 디렉토리도 심볼릭링크 가능하다.
    • 심볼릭 링크가 가리키고있는 파일이 변경되거나 삭제되면, 제동작을 하지 못하고, 해당링크는 'dangling soft link' 라고 한다.

  • Help 문서

  •  Usage: ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)

      or:  ln [OPTION]... TARGET                  (2nd form)

      or:  ln [OPTION]... TARGET... DIRECTORY     (3rd form)

      or:  ln [OPTION]... -t DIRECTORY TARGET...  (4th form)

     In the 1st form, create a link to TARGET with the name LINK_NAME.

     In the 2nd form, create a link to TARGET in the current directory.

     In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.

     Create hard links by default, symbolic links with --symbolic.

     By default, each destination (name of new link) should not already exist.

     When creating hard links, each TARGET must exist.  Symbolic links

     can hold arbitrary text; if later resolved, a relative link is

     interpreted in relation to its parent directory.


     Mandatory arguments to long options are mandatory for short options too.

          --backup[=CONTROL]      make a backup of each existing destination file

      -b                          like --backup but does not accept an argument

      -d, -F, --directory         allow the superuser to attempt to hard link

                                    directories (note: will probably fail due to

                                    system restrictions, even for the superuser)

      -f, --force                 remove existing destination files

      -i, --interactive           prompt whether to remove destinations

      -L, --logical               dereference TARGETs that are symbolic links

      -n, --no-dereference        treat LINK_NAME as a normal file if

                                    it is a symbolic link to a directory

      -P, --physical              make hard links directly to symbolic links

      -r, --relative              create symbolic links relative to link location

      -s, --symbolic              make symbolic links instead of hard links

      -S, --suffix=SUFFIX         override the usual backup suffix

      -t, --target-directory=DIRECTORY  specify the DIRECTORY in which to create

                                    the links

      -T, --no-target-directory   treat LINK_NAME as a normal file always

      -v, --verbose               print name of each linked file

          --help     display this help and exit

          --version  output version information and exit

     



Posted by leechwin
,