리눅스 / 명령어 / 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
같은 카테고리의 다른 글
CentOS 8 / Squid로 Proxy Server 만드는 방법

CentOS 8 / Squid로 Proxy Server 만드는 방법

리눅스로 프록시 서버(Proxy Server)를 만들 때 스퀴드(Squid)를 주로 사용합니다. 오픈 소스이고, 대부분의 리눅스 배포판에 패키지로 포함되어 있습니다. 스퀴드(squid)는 대중적인 오픈 소스(GPL)소프트웨어 프록시 서버이자 웹 캐시이다. 반복된 요청을 캐싱함으로 웹서버의 속도를 향상시키는 것부터, 네트워크 자원을 공유하려는 사람들에게 웹, DNS와 다른 네트워크 검색의 캐싱을 제공하고, 트래픽을 걸러줌으로써 안정성에 도움을 주는 등에 이르기까지 광범위 ...

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

로그아웃 명령어 # 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분 후에 종료 # ...

Ubuntu 20.04 Server / hostname 확인하는 방법, 변경하는 방법

Ubuntu 20.04 Server / hostname 확인하는 방법, 변경하는 방법

hostname 확인하는 방법 방법 1 - 명령어로 확인하기 다음과 같이 명령하면 hostname을 출력한다. hostname 방법 2 - 설정 파일 열어서 확인하기 /etc/hostname 파일에 hostname이 있다. cat /etc/hostname hostname 변경하는 방법 방법 1 - 명령어로 변경하기 다음과 같이 명령하면 hostname이 abc로 바뀐다. hostnamectl set-hostname abc 방법 2 - 설정 파일 열어서 변경하기 텍스트 에디터로 /etc/hostname 파일을 열어서 내용을 abc로 바꾸면 hostname이 abc로 바뀐다. 재부팅 재부팅을 하면 변경사항이 ...

Ubuntu 16.04 / 메모

PHP intl 설치 apt install php-intl service apache2 reoad APCu 설치 apt install php-apcu service apache2 reload

CentOS 7 / Apache, PHP, MariaDB 설치하는 방법

CentOS 7 / Apache, PHP, MariaDB 설치하는 방법

CentOS에 Apache, PHP, MariaDB를 설치하는 방법을 간략히 정리합니다. APM 설치 Apache, PHP, MariaDB을 설치합니다. yum install httpd php mariadb-server php-mysql 서비스 설정 Apache가 부팅 시 자동으로 시작되도록 합니다. systemctl enable httpd.service MariaDB가 부팅 시 자동으로 시작되도록 합니다. systemctl enable mariadb.service Apache를 시작합니다. systemctl start httpd.service MariaDB를 시작합니다. systemctl start mariadb.service 방화벽 설정 http로 접속할 수 있도록 포트를 열어줍니다. firewall-cmd --permanent --add-service=http https로 접속할 수 있도록 포트를 ...

리눅스 / 배포판 / 우분투(Ubuntu) - 역사, 특징, 장점

우분투의 역사 우분투(Ubuntu)는 2004년 10월 20일에 첫 번째 버전이 출시된 이후로 리눅스 배포판 중에서 가장 인기 있는 배포판 중 하나로 자리매김했습니다. 우분투는 데비안(Debian) 리눅스를 기반으로 하며, 캐노니컬(Canonical Ltd.)의 설립자인 마크 셔틀워스(Mark Shuttleworth)가 주도하여 시작되었습니다. 셔틀워스는 우분투를 통해 누구나 쉽게 접근할 수 있는 무료 운영체제를 제공하고자 했습니다. 데비안 기반 우분투는 데비안의 강력한 패키지 관리 ...

리눅스 / 명령어 / 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 옵션으로 출력 ...

Ubuntu 22.04 Server / NGINX / 설치와 설정

Ubuntu 22.04 Server / NGINX / 설치와 설정

Nginx는 높은 성능과 안정성을 제공하는 웹 서버 소프트웨어로, 웹 서버 외에도 리버스 프록시, 로드 밸런서, 메일 프록시 등의 기능을 수행할 수 있다. Igor Sysoev가 2004년에 처음 개발했으며, 현재는 오픈 소스 소프트웨어로 널리 사용되고 있다. 가정 Ubuntu 22.04 Server의 IP는 192.168.3.242이고, 내 컴퓨터에서 IP로 접근 가능하다. 내 컴퓨터의 OS는 Windows이다. 설치 nginx 패키지 설치 다음과 같이 명령하여 ...

Ubuntu 22.04 Server / 백신 프로그램 ClamAV 설치 및 사용법

ClamAV ClamAV는 리눅스에서 사용할 수 있는 백신 프로그램이다. 우분투 패키지에 포함되어 있으므로 apt 명령으로 쉽게 설치하고 사용할 수 있다. 설치 # apt install clamav 사용법 데이터베이스 업데이트 clamav-freshclam 서비스를 중지한다. # systemctl stop clamav-freshclam freshclam 명령으로 업데이트한다. # freshclam clamav-freshclam 서비스를 시작한다. # systemctl start clamav-freshclam 검사 home 디렉토리와 그 하위 디렉토리를 검사한다. # clamscan -r /home 검사 결과는 다음처럼 나온다. ----------- SCAN SUMMARY ----------- Known viruses: ...

리눅스 / SELinux(Security-Enhanced Linux)

SELinux(Security-Enhanced Linux)는 리눅스 커널에 통합된 보안 모듈로, 미국 국가안보국(NSA)이 개발한 강력한 접근 제어 메커니즘을 제공하는 보안 프레임워크입니다. SELinux는 시스템의 보안을 강화하기 위해 다양한 보안 정책을 적용하여 프로세스와 사용자 간의 상호작용을 제어합니다. SELinux의 주요 특징과 기능은 다음과 같습니다: 정책 기반 접근 제어 SELinux는 시스템의 모든 파일, 디렉터리, 포트, 그리고 프로세스에 대한 접근을 제어하기 ...