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

cp는 copy의 약자로 복사하는 명령어, mv는 move의 약자로 이동하는 명령어이다.

복사하기

  • abc.txt 파일을 def.txt로 이름을 바꾸어 복사한다.
cp abc.txt def.txt
  • xyz라는 디렉토리가 없다면 abc.txt 파일을 xyz 파일로 복사한다.
  • xyz라는 디렉토리가 있다면 xyz 디렉토리 안에 abc.txt 파일을 복사한다.
cp abc.txt xyz
  • abc.txt 파일을 xyz 디렉토리 안에 def.txt라는 이름으로 복사한다.
cp abc.txt xyz/def.txt
  • abc가 디렉토리이고 xyz라는 디렉토리가 없다면, abc 디렉토리를 xyz로 이름을 바꾸어 복사한다.
  • abc가 디렉토리이고 xyz라는 디렉토리가 있다면, abc 디렉토리를 xyz 디렉토리 안에 복사한다. 즉 xyz/abc가 된다.
cp -r abc xyz
  • abc가 디렉토리이고 xyz/zzz라는 디렉토리가 없다면, abc 디렉토리를 xyz 디렉토리 안에 zzz로 이름을 바꾸어서 복사한다.
  • abc가 디렉토리이고 xyz/zzz라는 디렉토리가 있다면, abc 디렉토리를 xyz/zzz 디렉토리 안에 복사한다. 즉 xyz/zzz/abc가 된다.
cp -r abc xyz/zzz

이동하기

  • abc.txt 파일을 def.txt로 이름을 바꾸어 이동한다. 파일 이름을 바꾸는 것과 결과가 같다.
mv abc.txt def.txt
  • xyz라는 디렉토리가 없다면 abc.txt 파일을 xyz로 이름을 바꾸어 이동한다.
  • xyz라는 디렉토리가 있다면 xyz 디렉토리 안으로 abc.txt 파일을 이동한다.
mv abc.txt xyz
  • abc.txt 파일을 xyz 디렉토리 안으로 def.txt로 이름을 바꾸어 이동한다.
mv abc.txt xyz/def.txt
  • abc가 디렉토리이고 xyz라는 디렉토리가 없다면, abc 디렉토리를 xyz로 이름을 바꾸어 이동한다.
  • abc가 디렉토리이고 xyz라는 디렉토리가 있다면, abc 디렉토리를 xyz 디렉토리 안으로 이동한다. 즉 xyz/abc가 된다.
mv abc xyz
  • abc가 디렉토리이고 xyz/zzz라는 디렉토리가 없다면, abc 디렉토리를 xyz 디렉토리 안으로 zzz로 이름을 바꾸어 이동한다.
  • abc가 디렉토리이고 xyz/zzz라는 디렉토리가 있다면, abc 디렉토리를 xyz/zzz 디렉토리 안으로 이동한다. 즉 xyz/zzz/abc가 된다.
mv abc xyz/zzz

Midnight Commander

  • 파일 복사, 이동 작업은 Midnight Commander를 이용하면 쉽게 할 수 있다.

  • CentOS라면 다음 명령으로,
yum install mc
  • Ubuntu라면 다음 명령으로 설치할 수 있다.
apt install mc
같은 카테고리의 다른 글
국세청 홈택스 / 지급명세서 조회하는 방법

국세청 홈택스 / 지급명세서 조회하는 방법

종합소득세 신고를 해야하는 5월이 되었습니다. 종합소득세 신고를 위해 제일 먼저 해야할 것은 총 수입을 계산하는 것이죠. 원천징수를 한 소득이라면 국세청 홈택스에서 쉽게 확인할 수 있습니다. 근로소득만 있다면 에서 받은 금액과 원천징수한 금액을 확인할 수 있습니다. 근로소득 외에 다른 소득도 있다면 로 가세요. 을 클릭하면... 원천징수를 당한 모든 소득에 ...

리눅스 / 명령어 / 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 명령으로 그룹을 삭제합니다. # ...

CPU / 코어(Core)

CPU(Central Processing Unit)에서 "Core(코어)"란 프로세서의 중앙 처리 장치를 구성하는 기본적인 처리 유닛을 의미합니다. 현대의 CPU는 다중 코어로 구성되어 있으며, 각 코어는 독립적으로 작업을 처리할 수 있습니다. 코어의 정의 코어는 CPU 내에서 실제로 명령을 처리하는 개별적인 처리 유닛입니다. 각 코어는 자체적인 연산 장치(ALU), 레지스터, 그리고 명령어 집합을 가지고 있으며, 독립적으로 작업을 수행할 수 ...

EDR / 개념과 주요 기능

EDR / 개념과 주요 기능

EDR(Endpoint Detection and Response)의 뜻과 주요 기능을 알아봅니다. 기존 백신과의 차이, 프로세스·파일·네트워크 이벤트 탐지, 공격 경로 분석, 시스템 격리 등 EDR이 기업 보안에서 어떤 역할을 하는지 쉽게 설명합니다.

Ubuntu 16.04 / SASS 설치하는 방법

우분투 16.04에 SASS를 설치하는 방법은 두 가지가 있습니다. 방법 1 apt install ruby-sass 방법 2 apt install ruby gem install sass 설치되었는지 확인하는 방법 sass -v SASS 버전이 출력되면 제대로 설치된 것입니다. Sass 3.4.23 (Selective Steve) 참고 최신 버전의 SASS를 사용하고 싶다면 방법 2로 설치합니다.

Ubuntu 24.04 Server / 고정 IP 설정하는 방법

네트워크 설정 파일은 /etc/netplan 디렉토리 안에 있는 yaml 파일입니다. 파일 이름은 시스템마다 다를 수 있습니다. # ll /etc/netplan total 12 drwxr-xr-x 2 root root 4096 Apr 27 23:00 ./ drwxr-xr-x 108 root root 4096 Apr 27 23:06 ../ -rw------- 1 root root 389 Apr 27 23:00 50-cloud-init.yaml DHCP라면 설정 파일이 다음과 ...

워드프레스 / Yoast SEO / 사이트맵(sitemap) 활성화하는 방법과 주소

워드프레스 / Yoast SEO / 사이트맵(sitemap) 활성화하는 방법과 주소

사이트맵 활성화하기 로 이동한다. 에서... XML sitemaps를 활성화(Enable feature)한다. 사이트맵 주소 Yoast SEO의 사이트맵 주소는 /sitemap_index.xml 이다. 문제가 없다면 웹브라우저로 접속했을 때 아래와 같은 페이지가 나온다. 사이트맵에서 404 에러 나는 경우 사이트맵 페이지에서 404 에러가 나면 고유주소를 확인해본다. 인 경우 404 에러가 나므로, 다른 것으로 변경한다.

안드로이드 / 앱 / 마이 케이티 / 장기혜택쿠폰 사용 또는 선물하는 방법

안드로이드 / 앱 / 마이 케이티 / 장기혜택쿠폰 사용 또는 선물하는 방법

KT 핸드폰을 2년 이상 사용하면 매년 장기혜택쿠폰이 들어온다. 데이터, 무료통화, 알 등을 제공하는 것으로, 제한이 있는 저렴한 요금제라면 유용하게 사용할 수 있다. 만약 가족 결합이 되어 있다면 구성원에게 선물할 수도 있다. 장기혜택쿠폰 사용은 홈페이지에서도 가능한데, 아래는 안드로이드에 있는 마이 케이티 앱에서 사용하는 방법이다. 마이 케이티 앱을 열고 왼쪽 위의 아이콘을 눌러서 메뉴로 ...

엣지 / 스크롤 캡처

엣지 / 스크롤 캡처

활성화된 창을 캡처하는 것은 쉽다. 많은 캡처 프로그램이 창 캡처를 지원한다. 그런데, 화면에 보이지 않는 곳까지 캡처할 수 있는 프로그램은 많지 않고, OS 버전이나 캡처 대상이 되는 프로그램에 따라 잘 작동하지 않는 경우가 많다. 만약 웹페이지 전체를 캡처하고 싶다면 웹브라우저에 그런 기능이 있나 살펴보자. 쉽고 빠르게 캡처할 수 있다. 마이크로소프트 엣지는 웹 ...