리눅스 / 명령어 / rmdir / 빈 디렉토리 삭제하는 명령어

rmdir

rmdir은 빈 디렉토리를 삭제하는 명령어입니다.

Remove the DIRECTORY(ies), if they are empty.

사용법

rmdir directory

  • a 디렉토리를 삭제합니다.
rmdir a

 비어있다면 삭제를 하고, 그렇지 않다면 다음을 출력합니다.

rmdir: failed to remove ‘a’: Directory not empty

rmdir --ignore-fail-on-non-empty directory

  • 디렉토리가 비어있지 않아도 메시지를 출력하지 않습니다.

rmdir -v directory

  • 현재 디렉토리 안에 있는 모든 비어있는 디렉토리를 삭제합니다. v 옵션을 넣으면 작업 결과를 출력합니다.
rmdir -v *
  • 예를 들어 헌재 디렉토리에 a, b, c 디렉토리가 있고, a와 c는 빈 디렉토리, b는 비어있지 않은 디렉토리라면, 다음을 출력합니다.
rmdir: removing directory, ‘a’
rmdir: removing directory, ‘b’
rmdir: failed to remove ‘b’: Directory not empty
rmdir: removing directory, ‘c’

rmdir -p directory

  • a/b/c를 삭제하고, a/b를 삭제하고, a를 삭제합니다.
rmdir -p a/b/c
  • 아래와 같습니다.
rmdir a/b/c a/b a

rmdir --help

  • 도움말을 출력합니다.
rmdir --help

같은 카테고리의 다른 글

리눅스 / 명령어 / systemctl

리눅스 / 명령어 / systemctl

서비스 관리 service_name은 서비스 이름으로 바꾸어 사용합니다. 예를 들어 Apache라면 httpd, MariaDB라면 matiadb. 서비스 상태 확인 systemctl status service_name.service 서비스 시작 systemctl start service_name.service 서비스 재시작 systemctl restart service_name.service 서비스 중지 systemctl stop service_name.service 부팅 시 서비스 자동 시작 systemctl enable service_name.service 부팅 시 서비스 자동 시작 해제 systemctl disable service_name.service 서비스 목록 보기 systemctl list-units --type=service

리눅스 / RAID / Linear RAID, RAID0, RAID1, RAID5, RAID6

리눅스 / RAID / Linear RAID, RAID0, RAID1, RAID5, RAID6

RAID 뜻과 종류 RAID Redundant Array of Inexpensive Disk or Redundant Array of Independent Disk 여러 개의 하드디스크를 하나처럼 사용하게 하는 기술. 예를 들어 1TB 하드디스크 두 개를 묶어서 2TB 하드디스크처럼 사용할 수 있다. 크게 하드웨어 RAID와 소프트웨어 RAID로 구분할 수 있다. 하드웨어 RAID는 성능이 좋으나 비싸다. 소프트웨어 RAID는 운영체제에서 지원하는 것으로 OS RAID라고도 한다. Linear RAID 두 ...

리눅스 / 명령어 / rmdir / 빈 디렉토리 삭제하는 명령어

리눅스 / 명령어 / rmdir / 빈 디렉토리 삭제하는 명령어

rmdir rmdir은 빈 디렉토리를 삭제하는 명령어입니다. Remove the DIRECTORY(ies), if they are empty. 사용법 rmdir directory a 디렉토리를 삭제합니다. rmdir a  비어있다면 삭제를 하고, 그렇지 않다면 다음을 출력합니다. rmdir: failed to remove ‘a’: Directory not empty rmdir --ignore-fail-on-non-empty directory 디렉토리가 비어있지 않아도 메시지를 출력하지 않습니다. rmdir -v directory 현재 디렉토리 안에 있는 모든 비어있는 디렉토리를 삭제합니다. v 옵션을 넣으면 작업 결과를 출력합니다. rmdir -v ...

리눅스 / 명령어 / which, whereis, locate / 명령어 위치 찾기

리눅스 / 명령어 / which, whereis, locate / 명령어 위치 찾기

명령어의 위치를 찾을 때 사용할 수 있는 명령어에는 which, whereis, locate가 있습니다. 명령어의 위치만 찾을 때는 which를 사용하고, 관련된 파일들의 위치까지 찾을 때는 whereis나 locate를 사용합니다. 각 명령어로 find 명령어를 찾아보겠습니다. # which find /usr/bin/find # whereis find find: /usr/bin/find /usr/share/man/man1/find.1.gz # locate find /usr/bin/find /usr/bin/find2perl /usr/bin/findmnt /usr/bin/nl-link-ifindex2name /usr/bin/nl-link-name2ifindex /usr/bin/oldfind /usr/lib64/python2.7/modulefinder.py /usr/lib64/python2.7/modulefinder.pyc /usr/lib64/python2.7/modulefinder.pyo /usr/sbin/btrfs-find-root /usr/sbin/findfs /usr/share/bash-completion/completions/findmnt /usr/share/doc/findutils-4.5.11 /usr/share/doc/findutils-4.5.11/AUTHORS /usr/share/doc/findutils-4.5.11/COPYING /usr/share/doc/findutils-4.5.11/ChangeLog /usr/share/doc/findutils-4.5.11/NEWS /usr/share/doc/findutils-4.5.11/README /usr/share/doc/findutils-4.5.11/THANKS /usr/share/doc/findutils-4.5.11/TODO /usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_find.py /usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_stop_find.py /usr/share/info/find-maint.info.gz /usr/share/info/find.info.gz /usr/share/locale/be/LC_MESSAGES/findutils.mo /usr/share/locale/bg/LC_MESSAGES/findutils.mo /usr/share/locale/ca/LC_MESSAGES/findutils.mo /usr/share/locale/cs/LC_MESSAGES/findutils.mo /usr/share/locale/da/LC_MESSAGES/findutils.mo /usr/share/locale/de/LC_MESSAGES/findutils.mo /usr/share/locale/el/LC_MESSAGES/findutils.mo /usr/share/locale/eo/LC_MESSAGES/findutils.mo /usr/share/locale/es/LC_MESSAGES/findutils.mo /usr/share/locale/et/LC_MESSAGES/findutils.mo /usr/share/locale/fi/LC_MESSAGES/findutils.mo /usr/share/locale/fr/LC_MESSAGES/findutils.mo /usr/share/locale/ga/LC_MESSAGES/findutils.mo /usr/share/locale/gl/LC_MESSAGES/findutils.mo /usr/share/locale/hr/LC_MESSAGES/findutils.mo /usr/share/locale/hu/LC_MESSAGES/findutils.mo /usr/share/locale/id/LC_MESSAGES/findutils.mo /usr/share/locale/it/LC_MESSAGES/findutils.mo /usr/share/locale/ja/LC_MESSAGES/findutils.mo /usr/share/locale/ko/LC_MESSAGES/findutils.mo /usr/share/locale/lg/LC_MESSAGES/findutils.mo /usr/share/locale/lt/LC_MESSAGES/findutils.mo /usr/share/locale/ms/LC_MESSAGES/findutils.mo /usr/share/locale/nl/LC_MESSAGES/findutils.mo /usr/share/locale/pl/LC_MESSAGES/findutils.mo /usr/share/locale/pt/LC_MESSAGES/findutils.mo /usr/share/locale/pt_BR/LC_MESSAGES/findutils.mo /usr/share/locale/ro/LC_MESSAGES/findutils.mo /usr/share/locale/ru/LC_MESSAGES/findutils.mo /usr/share/locale/rw/LC_MESSAGES/findutils.mo /usr/share/locale/sk/LC_MESSAGES/findutils.mo /usr/share/locale/sl/LC_MESSAGES/findutils.mo /usr/share/locale/sr/LC_MESSAGES/findutils.mo /usr/share/locale/sv/LC_MESSAGES/findutils.mo /usr/share/locale/tr/LC_MESSAGES/findutils.mo /usr/share/locale/uk/LC_MESSAGES/findutils.mo /usr/share/locale/vi/LC_MESSAGES/findutils.mo /usr/share/locale/zh_CN/LC_MESSAGES/findutils.mo /usr/share/locale/zh_TW/LC_MESSAGES/findutils.mo /usr/share/man/man1/find.1.gz /usr/share/man/man1/find2perl.1.gz /usr/share/man/man1/oldfind.1.gz /usr/share/man/man8/btrfs-find-root.8.gz /usr/share/man/man8/findfs.8.gz /usr/share/man/man8/findmnt.8.gz locate 명령어는 -n 옵션으로 출력 개수를 정할 수 있습니다. # locate ...

리눅스 / 명령어 / cd / 다른 디렉토리로 이동하는 명령어

리눅스 / 명령어 / cd / 다른 디렉토리로 이동하는 명령어

cd cd는 change directory의 약자로, 다른 디렉토리로 이동하는 명령어입니다. cd 현재 로그인한 사용자의 홈 디렉토리로 이동합니다. 일반적으로 root 계정이라면 /root로, 사용자 jb 계정이라면 /home/jb로 이동합니다. cd ~user user의 홈 디렉토리로 이동합니다. 다음과 같이 명령하면 jb 사용자의 홈 디렉토리로 이동합니다. cd ~jb cd 디렉토리명 지정한 디렉토리로 이동합니다. 절대경로, 상대경로 다 사용할 수 있습니다. 다음과 같이 명령하면 /etc 디렉토리로 이동합니다. cd /etc 현재 디렉토리에 속한 디렉토리 ...

리눅스 / 명령어 / cp - 복사하는 명령어, mv - 이동하는 명령어

리눅스 / 명령어 / cp - 복사하는 명령어, mv - 이동하는 명령어

cp는 copy의 약자로 복사하는 명령어, mv는 move의 약자로 이동하는 명령어입니다. 복사하기 cp abc.txt def.txt abc.txt 파일을 def.txt로 이름을 바꾸어 복사합니다. cp abc.txt xyz xyz라는 디렉토리가 없다면 abc.txt 파일을 xyz 파일로 복사합니다. xyz라는 디렉토리가 있다면 xyz 디렉토리 안에 abc.txt 파일을 복사합니다. cp abc.txt xyz/def.txt abc.txt 파일을 xyz 디렉토리 안에 def.txt라는 이름으로 복사합니다. cp -r abc xyz abc가 디렉토리이고 xyz라는 디렉토리가 없다면, ...

리눅스 / 명령어 / history / 이전에 실행했던 명령어 목록 출력하는 명령어

리눅스 / 명령어 / history / 이전에 실행했던 명령어 목록 출력하는 명령어

history history는 이전에 실행했던 명령어 목록 출력하는 명령어입니다. history 이전에 실행했던 명령어 목록을 일련번호와 함께 출력합니다. history n 최근 n개의 명령어 목록을 출력합니다. history 10 최근 실행한 10개의 명령어를 출력합니다. !! !!를 입력하고 엔터를 누르면 직전에 실행했던 명령어를 다시 실행합니다. !n 일련번호가 n인 명령어를 실행합니다. !202 번호가 202인 명령어를 실행합니다.

리눅스 / 명령어 / find / 파일 또는 디렉토리를 찾는 명령어

리눅스 / 명령어 / find / 파일 또는 디렉토리를 찾는 명령어

find는 파일 또는 디렉토리를 찾는 명령어입니다. 자주 사용하는 옵션 등을 정리해봅니다. find 현재 디렉토리 안에 있는 모든 파일과 디렉토리를 출력합니다. 숨긴 파일 또는 숨긴 디렉토리도 출력합니다. find /etc /etc 디렉토리 안에 있는 모든 파일과 디렉토리를 출력합니다. 숨긴 파일 또는 숨긴 디렉토리도 출력합니다. find -name abc 현재 디렉토리 안에서 이름이 abc인 파일 또는 abc인 디렉토리를 검색합니다. find -name ...

리눅스 / 스왑 메모리(Swap Memory) 만드는 방법

리눅스 / 스왑 메모리(Swap Memory) 만드는 방법

리눅스 시스템이 메모리를 다 사용하면 프로그램이 멈추는 등 문제가 발생한다. 이때 스왑 메모리(Swap Memory) 늘려서 메모리 부족 문제를 해결할 수 있다. 스왑 파일 만들기 적당한 디렉토리에 적당한 이름의 파일을 적당한 크기로 만든다. 예를 들어 다음과 같이 하면, 루트 디렉토리에 jb-swap이라는 파일을 2G의 크기로 만든다. fallocate -l 2G /jb-swap root만 읽고 쓸 수 있게 권한 설정을 ...

리눅스 / 로그아웃 명령어, 재부팅 명령어, 종료 명령어

리눅스 / 로그아웃 명령어, 재부팅 명령어, 종료 명령어

로그아웃 명령어 logout exit 재부팅 명령어 즉시 재부팅 reboot shutdown -r now init 6 일정 시간 또는 일정 시간 후 재부팅 10분 후 재부팅 shutdown -r 10 12시에 재부팅 shutdown -r 12:00 취소 shutdown -c 종료 명령어 즉시 종료 poweroff shutdown -h now shutdown -P now halt -p init 0 일정 시간 또는 일정 시간 후에 종료 10분 후에 종료 shutdown -P 10 13시에 종료 shutdown -P 13:00 취소 shutdown -c 기타 10분 후에 종료할 거라는 메시지를 사용자에게 보내지만, 종료하지는 ...