티스토리 뷰

CentOS 강좌 PART 1. 2 리눅스 기본 명령어 1편

[시스템 리부팅과 종료]

리눅스 종료 명령은 아래와 같다.
이 가운데 주로 shutdown, init 0, init 6 등의 명령을 자주 사용한다.

poweroff
shutdown
halt
init

poweroff

[whchoi@CentOS153 ~]$ sudo poweroff -p
# 시스템을 즉시 종료시킴.

[whchoi@CentOS153 ~]$ poweroff --help
poweroff [OPTIONS...]

Power off the system.

     --help      Show this help
     --halt      Halt the machine
  -p --poweroff  Switch off the machine
     --reboot    Reboot the machine
  -f --force     Force immediate halt/power-off/reboot
  -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record
  -d --no-wtmp   Don't write wtmp record
     --no-wall   Don't send wall message before halt/power-off/reboot

shutdown

[whchoi@CentOS153 ~]$ sudo shutdown -h now
# 시스템을 즉시 종료시킴.
[whchoi@CentOS153 ~]$ sudo shutdown -h +10
# 시스템을 10분 후에 종료 예약
[whchoi@CentOS153 ~]$ sudo shutdown -r now
# 시스템을 지금 즉시 리부팅
[whchoi@CentOS153 ~]$ sudo shutdown -r 12:00
# 시스템을 12시에 리부팅 예약
[whchoi@CentOS153 ~]$ sudo shutdown -c
# shutdown 예약 취소

[whchoi@CentOS153 ~]$ shutdown --help
shutdown [OPTIONS...] [TIME] [WALL...]

Shut down the system.

     --help      Show this help
  -H --halt      Halt the machine
  -P --poweroff  Power-off the machine
  -r --reboot    Reboot the machine
  -h             Equivalent to --poweroff, overridden by --halt
  -k             Don't halt/power-off/reboot, just send warnings
     --no-wall   Don't send wall message before halt/power-off/reboot
  -c             Cancel a pending shutdown

init

[whchoi@CentOS153 ~]sudo init 0
# 시스템을 즉시 종료시킴.
[whchoi@CentOS153 ~]$ sudo init 6
# 시스템을 지금 즉시 리부팅

[whchoi@CentOS153 ~]$ init --help
init [OPTIONS...] {COMMAND}

Send control commands to the init daemon.

     --help      Show this help
     --no-wall   Don't send wall message before halt/power-off/reboot

Commands:
  0              Power-off the machine
  6              Reboot the machine
  2, 3, 4, 5     Start runlevelX.target unit
  1, s, S        Enter rescue mode
  q, Q           Reload init daemon configuration
  u, U           Reexecute init daemon

halt

[whchoi@CentOS153 ~]sudo halt
# 시스템을 즉시 종료시킴.
[whchoi@CentOS153 ~]$ halt --help
halt [OPTIONS...]

Halt the system.

     --help      Show this help
     --halt      Halt the machine
  -p --poweroff  Switch off the machine
     --reboot    Reboot the machine
  -f --force     Force immediate halt/power-off/reboot
  -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record
  -d --no-wtmp   Don't write wtmp record
     --no-wall   Don't send wall message before halt/power-off/reboot

reboot

[whchoi@CentOS153 ~]sudo reboot
# 시스템을 즉시 재구동.
[whchoi@CentOS153 ~]$ reboot --help
reboot [OPTIONS...] [ARG]

Reboot the system.

     --help      Show this help
     --halt      Halt the machine
  -p --poweroff  Switch off the machine
     --reboot    Reboot the machine
  -f --force     Force immediate halt/power-off/reboot
  -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record
  -d --no-wtmp   Don't write wtmp record
     --no-wall   Don't send wall message before halt/power-off/reboot


[디렉토리 관리]

mkdir (make directoires) : 디렉토리의 생성

[whchoi@CentOS153 ~]$ ls -al
total 16
drwx------. 2 whchoi whchoi   83 Mar  6 00:37 .
drwxr-xr-x. 3 root   root     20 Mar  5 04:02 ..
-rw-------. 1 whchoi whchoi 1775 Mar  6 00:26 .bash_history
-rw-r--r--. 1 whchoi whchoi   18 Oct 31 02:07 .bash_logout
-rw-r--r--. 1 whchoi whchoi  193 Oct 31 02:07 .bash_profile
-rw-r--r--. 1 whchoi whchoi  231 Oct 31 02:07 .bashrc

[whchoi@CentOS153 ~]$ mkdir test1
# test1 이라는 디렉토리 생성

[whchoi@CentOS153 ~]$ mkdir test2 test3
# test2 test3 디렉토리 2개 생성

[whchoi@CentOS153 ~]$ mkdir -p test4/test14
# test4/test14 기본 디텍토리와 하위 디렉토리까지 생성

[whchoi@CentOS153 ~]$ ls -al
total 16
drwxrwxr-x. 2 whchoi whchoi    6 Mar  6 00:38 test1
drwxrwxr-x. 2 whchoi whchoi    6 Mar  6 00:38 test2
drwxrwxr-x. 2 whchoi whchoi    6 Mar  6 00:38 test3
drwxrwxr-x. 3 whchoi whchoi   20 Mar  6 00:38 test4

[whchoi@CentOS153 ~]$ tree /home/whchoi/
/home/whchoi/
|-- test1
|-- test2
|-- test3
`-- test4
    `-- test14
# tree를 통해 하위디렉토리 확인
# minimal ISO 설치시 기본 설치되지 않으므로, yum 을 통해 패키지 설치.

[whchoi@CentOS153 ~]$ mkdir --help
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.

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
  -Z                   set SELinux security context of each created directory
                         to the default type
      --context[=CTX]  like -Z, or if CTX is specified then set the SELinux
                         or SMACK security context to CTX
      --help     display this help and exit
      --version  output version information and exit

rmdir(remove empty directories) : 디렉토리 삭제

디렉토리 하위에 디렉토리가 다시 존재할 경우 삭제 되지 않는다. 
이러한 경우에는 -p 옵션을 통해 상위디렉토리와 함께 삭제 가능하다.
mkdir과 옵션 사용법은 거의 유사하다.

[whchoi@CentOS153 ~]$ ls
test1  test2  test3  test4

[whchoi@CentOS153 ~]$ rmdir test1
#test1 디렉토리 삭제

[whchoi@CentOS153 ~]$ ls
test2  test3  test4
[whchoi@CentOS153 ~]$ rmdir test2 test3
#test2,test3 디렉토리 2개 동시 삭제

[whchoi@CentOS153 ~]$ ls
test4
[whchoi@CentOS153 ~]$ rmdir -p test4/test14
[whchoi@CentOS153 ~]$ ls
[whchoi@CentOS153 ~]$

[whchoi@CentOS153 ~]$ rmdir --help
Usage: rmdir [OPTION]... DIRECTORY...
Remove the DIRECTORY(ies), if they are empty.

      --ignore-fail-on-non-empty
                  ignore each failure that is solely because a directory
                    is non-empty
  -p, --parents   remove DIRECTORY and its ancestors; e.g., 'rmdir -p a/b/c' is
                    similar to 'rmdir a/b/c a/b a'
  -v, --verbose   output a diagnostic for every directory processed
      --help     display this help and exit
      --version  output version information and exit






공지사항