리눅스 / 명령어 / 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
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

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation <https://www.gnu.org/software/coreutils/rmdir>
or available locally via: info '(coreutils) rmdir invocation'
같은 카테고리의 다른 글

Ubuntu 14.04 / LESS 설치하는 방법

우분투 14.04에 LESS를 설치하는 방법을 메모합니다. Node.js 설치 apt-get install nodejs NPM 설치 apt-get install npm LESS 설치 npm install -g less less-plugin-clean-css /usr/local/bin/lessc 파일 첫 줄에 다음과 같은 코드가 있습니다. #!/usr/bin/env node 다음처럼 바꿉니다. #!/usr/bin/env nodejs

CentOS 7 / SELinux 끄는 방법

CentOS 7 / SELinux 끄는 방법

방법 1 다음과 같이 명령하면 SELinux가 꺼진다. 재부팅하면 다시 SELinux가 켜진다. setenforce 0 만약 다시 SELinux를 사용하고 싶다면 다음과 같이 명령한다. setenforce 1 방법 2 /etc/selinux/config에 다음과 같은 코드가 있다. SELINUX=enforcing 다음과 같이 바꾼다. SELINUX=disabled 시스템을 재부팅하면 적용된다. 방법 1과는 달리 재부팅해도 설정이 유지된다.

Rocky Linux 8 / SELinux 끄는 방법

Rocky Linux 8 / SELinux 끄는 방법

상태 확인 켜진 상태라면 Enforcing, 꺼진 상태라면 Permissive를 출력한다. getenforce 방법 1 다음과 같이 명령하면 SELinux가 꺼진다. 재부팅하면 다시 SELinux가 켜진다. setenforce 0 만약 다시 SELinux를 사용하고 싶다면 다음과 같이 명령한다. setenforce 1 방법 2 /etc/selinux/config에 다음과 같은 코드가 있다. SELINUX=enforcing 다음과 같이 바꾼다. SELINUX=disabled 시스템을 재부팅하면 적용된다. 방법 1과는 달리 재부팅해도 설정이 유지된다.

CentOS 7 / yum으로 phpMyAdmin 설치하는 방법

CentOS 7 / yum으로 phpMyAdmin 설치하는 방법

phpMyAdmin은 MySQL 또는 MariaDB를 관리하는 유용한 툴입니다. 그런데 CentOS 7 기본 패키지에는 포함되어 있지 않습니다. 하지만, EPEL Repo를 추가하면 yum으로 설치하고 업그레이드를 할 수 있습니다. EPEL Repo 추가 yum install epel-release phpMyAdmin 설치 yum install phpmyadmin 설정 파일 /etc/httpd/conf.d/phpMyAdmin.conf 기본 설정은 외부 접속 불가입니다. 접속하는 PC의 IP를 추가하면 외부 접속이 가능합니다. 접속 주소 http://server-ip/phpMyAdmin

Rocky Linux 10 / 방화벽 관리

Rocky Linux 10 / 방화벽 관리

Rocky Linux는 firewalld를 기본 방화벽으로 사용하며, firewall-cmd 명령어로 실시간 설정이 가능합니다. 포트나 서비스를 열고 닫거나, Zone을 통해 네트워크 접근을 세분화하여 관리할 수 있습니다. 설정은 일시적 또는 영구적으로 적용 가능합니다.

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

명령어의 위치를 찾을 때 사용할 수 있는 명령어에는 which, whereis, locate가 있다. 명령어의 위치만 찾을 때는 which를 사용하고, 관련된 파일들의 위치까지 찾을 때는 whereis나 locate를 사용한다. which 명령어로 find 명령어를 찾는다. # which find /usr/bin/find whereis 명령어로 find 명령어를 찾는다. # whereis find find: /usr/bin/find /usr/share/man/man1/find.1.gz locate 명령어로 find 명령어를 찾는다. # 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 옵션으로 출력 ...

리눅스 / 그룹 / 그룹 조회, 그룹 추가, 그룹 삭제, 그룹 수정

그룹 조회 그룹 목록은 /et/group 파일에 있습니다. cat 명령어로 전체를 조회하거나... cat /etc/group tail 명령어로 마지막 부분을 조회할 수 있습니다. # tail -n 5 /etc/group avahi:x:70: slocate:x:21: rngd:x:974: tcpdump:x:72: vboxsf:x:973: X:Y:Z 형식으로 나오는데, X는 그룹 이름, Y는 그룹 비밀번호, Z는 그룹 ID입니다. 그룹 추가 groupadd 명령으로 그룹을 추가합니다. # groupadd group-1 # tail -n 5 /etc/group slocate:x:21: rngd:x:974: tcpdump:x:72: vboxsf:x:973: group-1:x:1000: 그룹 삭제 groupdel 명령으로 그룹을 삭제합니다. # ...

리눅스 / chown, chmod / 파일 또는 디렉토리 소유자, 소유그룹, 권한 설정

chown과 chmod는 파일 및 디렉토리의 권한과 소유자를 관리하는 데 사용되는 Linux 명령어입니다. 정보 확인 ls 명령어에 -l 옵션을 붙여서 파일 또는 디렉토리의 권한과 소유자(그룹)을 확인할 수 있습니다. 제일 앞에 있는 문자는 디렉토리인지 파일인지는 나타냅니다. d는 디렉토리라는 뜻이고, -는 파일이라는 뜻입니다. 그 다음 3개의 문자열은 소유자의 권한을, 그 다음 3개의 문자열은 소유그룹의 권한을, 그 다음 ...

CentOS 7 / rsyslog / 로그 서버 구축하는 방법

CentOS 7 / rsyslog / 로그 서버 구축하는 방법

CentOS을 설치하면 로그 기록을 위한 rsyslog 패키지가 설치되고 실행됩니다. 로그는 로컬 컴퓨터에 저장되는데, 관리하는 컴퓨터가 여러 대인 경우 각각의 로그를 따로 모니터링하는 것이 불편할 수 있습니다. 그런 경우 하나의 컴퓨터를 로그를 수집하는 서버로 만들어서 그 서버에 로그가 쌓이게 하면, 좀 더 수월하게 로그를 관리할 수 있습니다. rsyslog는 간단한 설정 변경으로 로그 ...

CentOS 7 / 다운로드 하는 방법

CentOS 7 / 다운로드 하는 방법

CentOS는 세계 곳곳의 서버에서 다운로드할 수 있습니다. 다운로드하려는 곳에서 가까운 곳에 있고 회선이 좋은 서버에서 다운로드 받아야 빠르게 다운로드 할 수 있습니다. 다행이 CentOS는 가까운 서버를 알려줘서 다운로드에 소요되는 시간을 줄일 수 있습니다. CentOS 공식 다운로드 페이지로 갑니다. 다운로드 하고 싶은 ISO를 클릭합니다. 카이스트, 카카오, 네이버 등 국내 다운로드 주소를 먼저 보여줍니다. 마음에 드는 ...