리눅스 폴더 삭제 - linugseu poldeo sagje

rm은 remove의 약자로, 파일 또는 디렉토리를 삭제하는 명령어입니다.

차례

  • 1 파일 삭제하기
  • 2 디렉토리 삭제하기

파일 삭제하기

  • abc.txt 파일을 삭제합니다. 삭제할 건지 다시 묻습니다. y 또는 yes를 입력하면 삭제합니다.
rm abc.txt

리눅스 폴더 삭제 - linugseu poldeo sagje

  • 확장자가 txt인 모든 파일을 삭제합니다. 각 파일에 대해서 삭제할 건지 묻습니다.
rm *.txt
  • 현재 디렉토리에 있는 모든 파일을 삭제합니다. 각 파일에 대해서 삭제할 건지 묻고, 디렉토리가 있다면 삭제할 수 없다는 메시지가 나옵니다.
rm *
  • -f 옵션을 붙이면 삭제할 건지 다시 묻지 않고 바로 삭제합니다.
rm -f abc.txt
  • 현재 디렉토리에 있는 모든 파일을 바로 삭제합니다. 디렉토리는 삭제하지 않습니다.
rm -f *

디렉토리 삭제하기

  • dir1 디렉토리를 삭제합니다. 디렉토리를 삭제할 때는 -r 옵션을 붙입니다.
rm -r dir1
  • f 옵션을 추가하면 삭제할 건지 묻지 않고 바로 삭제합니다.
rm -rf dir1
  • 현재 디렉토리에 속한 모든 파일과 디렉토리를 삭제합니다. -rf 옵션은 주의해서 사용해야 합니다.
rm -rf *

같은 카테고리의 다른 글

리눅스 폴더 삭제 - linugseu poldeo sagje

리눅스 / 명령어 / rdate / 타임서버의 시간과 동기화해주는 명령어

rdate는 서버의 시간과 타임서버의 시간을 동기화해주는 명령어입니다. rdate는 설치되어있지 않는 경우가 많으므로, 필요하다면 설치를 해야 합니다. CentOS라면 yum install rdate Ubuntu라면 apt install rdate 와 같이 명령하여 설치할 수 있습니다. 타임서버의 시간을 확인할 때는 -p 옵션을 사용합니다. 현재 서버의 시간을 변경하지 않습니다. rdate -p time.bora.net 현재 서버의 시간을 타임서버의 시간으로 맞출 때에는 -s 옵션을 붙입니다. rdate -s time.bora.net CentOS ...

리눅스 폴더 삭제 - linugseu poldeo sagje

리눅스 폴더 삭제 - linugseu poldeo sagje

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

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

리눅스 폴더 삭제 - linugseu poldeo sagje

리눅스 / 명령어 / man / 명령어의 설명서 출력하는 명령어

man은 manual의 약어로, 명령어의 설명서를 출력하는 명령어입니다. man 뒤에 명령어 이름을 넣고 엔터를 누릅니다. 예를 들어 man rm 은 rm 명령어의 설명서를 출력합니다. ↑키를 누르면 한 줄 위로 올라가고, ↓키를 누르면 한 줄 아래로 내려갑니다. Page Up 키를 누르면 한 페이지 위로 올라가고, Page Down 키를 누르면 한 페이지 아래로 내려갑니다. /를 누르고 단어를 입력하면 ...

리눅스 폴더 삭제 - linugseu poldeo sagje

리눅스 / 하드디스크 파디션 만들기, 포맷하기, 마운트하기

리눅스에서 하드디스크 파티션 만들고, 포맷 하고, 마운트 하는 방법을 요약한다. 장착된 하드디스크 확인하기 ls 명령어로 컴퓨터에 장착된 하드디스크 정보를 출력할 수 있다. /dev/sda, /dev/sdb 등이 하드디스크, /dev/sda1 등이 파티션이다. # ls -l /dev/sd* brw-rw----. 1 root disk 8, 0 Oct 16 13:12 /dev/sda brw-rw----. 1 root disk 8, 1 Oct 16 13:12 /dev/sda1 brw-rw----. 1 ...

리눅스 폴더 삭제 - linugseu poldeo sagje

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

리눅스 폴더 삭제 - linugseu poldeo sagje

리눅스 / 파일 또는 디렉토리 이름 바꾸는 방법

파일 이름 바꾸기 mv는 파일을 이동시키는 명령어이다. 이 명령어를 이용해서 파일 이름을 바꿀 수 있다. 예를 들어 다음은 abc.txt를 xyz.txt로 바꾼다. mv abc.txt xyz.txt   디렉토리 이름 바꾸기 디렉토리 이름을 바꾸는 것도 파일 이름 변경과 같다. 다음은 abc 디렉토리의 이름을 xyz로 바꾼다. mv abc xyz  

리눅스 폴더 삭제 - linugseu poldeo sagje

리눅스 / 명령어 / cat / 파일 내용 출력하는 명령어

다음과 같은 두 개의 파일이 있다고 할 때 file1 1-1 1-2 1-3 file2 2-1 2-2 2-3 cat filename cat 뒤에 파일 이름을 넣으면 파일 안의 내용을 보여줍니다. # cat file1 1-1 1-2 1-3 파일 이름을 연달아 넣으면 연속하여 파일의 내용을 보여줍니다. # cat file1 file2 1-1 1-2 1-3 2-1 2-2 2-3 cat filename -n -n 옵션을 붙이면 줄번호를 보여줍니다. # cat -n file1 1 1-1 2 1-2 3 1-3 # cat -n file1 file2 1 1-1 2 1-2 3 1-3 4 2-1 5 2-2 6 ...

리눅스 폴더 삭제 - linugseu poldeo sagje

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

ls -l ls 명령어에 -l 옵션을 붙여서 파일 또는 디렉토리의 권한과 소유자(그룹)을 확인할 수 있습니다. 제일 앞에 있는 문자는 디렉토리인지 파일인지는 나타냅니다. d는 디렉토리라는 뜻이고, -는 파일이라는 뜻입니다. 그 다음 3개의 문자열은 소유자의 권한을, 그 다음 3개의 문자열은 소유그룹의 권한을, 그 다음 3개의 문자열은 소유자(그룹) 이외의 권한을 나타냅니다. 처음 나오는 jb는 소유자, 그 다음 ...

리눅스 폴더 삭제 - linugseu poldeo sagje

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

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