리눅스 / LVM / 만드는 방법, 수정하는 방법, 삭제하는 방법

1TB 디스크와 2TB 디스크를 추가했다고 하자. 디스크 크기에 맞게 그대로 사용할 수도 있지만, 3TB 하나인 것처럼 사용하거나 1.5TB 두 개인 것처럼 사용하고 싶을 수도 있다. 즉, 물리적인 디스크 크기와 무관하게 자유롭게 볼륨을 만들고 싶은 것이다.

이럴 때 사용하는 것이 LVM(Logical Volume Manager)이다. 여러 개의 볼륨을 하나로 묶은 후 다시 배분하여 사용한다.(이렇게 만든 볼륨을 논리적 볼륨이라고 한다.)

LVM을 이용하여 논리적 볼륨을 만들고, 수정하고, 삭제하는 방법을 알아본다.

LVM 만들기

LVM으로 볼륨을 만드는 순서는 다음과 같다.

  1. 물리적 볼륨을 만든다.
  2. 물리적 볼륨을 묶어서 볼륨 그룹을 만든다.
  3. 볼륨 그룹에 논리적 볼륨을 만든다.

간단한 예로 어떻게 구성하는지 알아보자. 목표는 100GB 디스크과 200GB 디스크로 50GB, 80GB, 170GB 볼륨을 만드는 것이다.

파티션 만들기

  • 현재 상태는 다음과 같다. 디스크 두 개를 추가해서 /dev/sdb와 /dev/sdc가 생겼고, /dev/sdb의 크기는 100GB, /dev/sdc의 크기는 200GB이다.
# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sdb  /dev/sdc
  • fdisk로 파티션을 만든다. 주의할 점은 타입을 8e로 해야 한다는 것이다.
# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xa066b799.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-209715199, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-209715199, default 209715199):

Created a new partition 1 of type 'Linux' and of size 100 GiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  • 파티션을 만든 후의 상태는 다음과 같다.
# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sdb  /dev/sdb1  /dev/sdc  /dev/sdc1

물리적 볼륨 만들기

  • /dev/sdb1과 /dev/sdc1로 물리적 볼륨(Physical Volume)을 만든다.
# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
root@ubuntu-2004-s-02:~# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.

볼륨 그룹 만들기

  • /dev/sdb1과 /dev/sdc1를 볼륨 그룹으로 만든다.
  • VG-01은 볼륨 그룹의 이름으로, 다른 것으로 만들어도 된다.
# vgcreate VG-01 /dev/sdb1 /dev/sdc1
  Volume group "VG-01" successfully created

논리적 볼륨 만들기

  • VG-01 볼륨 그룹에 50GB 크기의 논리적 볼륨(Logical Volume)을 만든다.
  • LG-01은 논리적 볼륨의 이름으로, 다른 것으로 만들어도 된다.
# lvcreate --size 50G --name LG-01 VG-01
  Logical volume "LG-01" created.
  • LG-02라는 이름의 80GB 크기의 논리적 볼륨을 만든다.
# lvcreate --size 80G --name LG-02 VG-01
  Logical volume "LG-02" created.
  • 나머지 공간을 다 사용하는 LG-03이라는 이름의 논리적 볼륨을 만든다.
# lvcreate --extents 100%FREE --name LG-03 VG-01
  Logical volume "LG-03" created.

포맷하고 마운트하기

  • 논리적 볼륨을 포맷한다. 아래는 LG-01을 EXT4 형식으로 포맷한 것이다.
# mkfs.ext4 /dev/VG-01/LG-01
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 13107200 4k blocks and 3276800 inodes
Filesystem UUID: ee2a0e20-db9f-4e38-b3d1-d46f00ccc215
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done
  • 적당한 이름의 폴더를 만들고 마운트한다.
# mkdir /LG-01
# mount /dev/VG-01/LG-01 /LG-01
  • 다음은 세 개의 논리적 볼륨을 포맷하고 마운트한 결과이다. 제일 아래 세 줄에 논리적 볼륨이 추가된 것을 확인할 수 있다.
# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              394M  1.4M  393M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  196G  8.8G  178G   5% /
tmpfs                              2.0G     0  2.0G   0% /dev/shm
tmpfs                              5.0M  4.0K  5.0M   1% /run/lock
tmpfs                              2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/loop1                          62M   62M     0 100% /snap/core20/1169
/dev/loop2                          71M   71M     0 100% /snap/lxd/21029
/dev/loop3                          68M   68M     0 100% /snap/lxd/21545
/dev/sda2                          976M  112M  798M  13% /boot
/dev/loop4                          56M   56M     0 100% /snap/core18/2128
/dev/loop5                          33M   33M     0 100% /snap/snapd/13170
/dev/loop0                          62M   62M     0 100% /snap/core20/1081
/dev/loop6                          33M   33M     0 100% /snap/snapd/12704
tmpfs                              394M   36K  394M   1% /run/user/128
tmpfs                              394M     0  394M   0% /run/user/0
/dev/mapper/VG--01-LG--01           49G   53M   47G   1% /LG-01
/dev/mapper/VG--01-LG--02           79G   57M   75G   1% /LG-02
/dev/mapper/VG--01-LG--03          167G   61M  158G   1% /LG-03

LVM 수정하기

볼륨 추가

볼륨 그룹에 볼륨을 추가하여 전체 공간을 확장할 수 있다. 위 예제에 이어 200GB 하드 디스크를 추가로 장착했다고 하면...

  • 디스크를 추가하면 아래와 같은 상태가 된다. /dev/sdd가 추가한 디스크이다.
# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sdb  /dev/sdb1  /dev/sdc  /dev/sdc1  /dev/sdd
  • Linux LVM 파티션을 만든다.
# fdisk /dev/sdd

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x8aa237e3.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-419430399, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-419430399, default 419430399):

Created a new partition 1 of type 'Linux' and of size 200 GiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  • 물리적 볼륨을 만든다.
# pvcreate /dev/sdd1
  Physical volume "/dev/sdd1" successfully created.
  • VG-01 볼륨 그룹에 추가한다.
# vgextend VG-01 /dev/sdd1
  Volume group "VG-01" successfully extended
  • 200GB의 여유 공간이 생긴다.
# vgdisplay VG-01
  --- Volume group ---
  VG Name               VG-01
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  9
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               <499.99 GiB
  PE Size               4.00 MiB
  Total PE              127997
  Alloc PE / Size       76798 / 299.99 GiB
  Free  PE / Size       51199 / <200.00 GiB
  VG UUID               YLV2F1-x00c-4CZt-LsCh-3q9O-iE3L-Ynx2vG

확장된 공간에 새로운 논리적 볼륨을 만들거나, 기존 논리적 볼륨의 크기를 늘릴 수 있다.

논리적 볼륨 확장하기

  • lvextend 명령어로 논리적 볼륨의 크기를 확장한다. 아래는 /dev/VG-01/LG-01의 크기를 1GB 늘리는 것.
# lvextend -L+1G /dev/VG-01/LG-01
  Size of logical volume VG-01/LG-01 changed from 50.00 GiB (12800 extents) to 51.00 GiB (13056 extents).
  Logical volume VG-01/LG-01 successfully resized.
  • resize2fs 명령어로 파일 시스템의 크기를 확장해야 반영된다.
# resize2fs /dev/VG-01/LG-01
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/VG-01/LG-01 is mounted on /LG-01; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 7
The filesystem on /dev/VG-01/LG-01 is now 13369344 (4k) blocks long.
  • 아래는 /dev/VG-01/LG-01의 크기를 60GB로 늘리는 것. 마찬가지로 resize2fs 명령으로 파일 시스템 크기를 확장한다.
# lvextend -L60G /dev/VG-01/LG-01
  Size of logical volume VG-01/LG-01 changed from 51.00 GiB (13056 extents) to 60.00 GiB (15360 extents).
  Logical volume VG-01/LG-01 successfully resized.
# resize2fs /dev/VG-01/LG-01
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/VG-01/LG-01 is mounted on /LG-01; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 8
The filesystem on /dev/VG-01/LG-01 is now 15728640 (4k) blocks long.

LVM 삭제하기

LVM 삭제는 LVM 생성의 역순으로 진행한다.

논리적 볼륨 삭제하기

lvremove 명령어로 논리적 볼륨을 삭제한다. 아래는 /dev/VG-01/LG-03를 삭제하는 것.

# lvremove /dev/VG-01/LG-03
Do you really want to remove and DISCARD active logical volume VG-01/LG-03? [y/n]: y
  Logical volume "LG-03" successfully removed

볼륨 그룹 삭제하기

vgremove 명령어로 볼륨 그룹을 삭제한다. 아래는 VG-01을 삭제하는 것으로, 볼륨 그룹 안에 논리적 볼륨이 남아 있으면 삭제할 것인지 묻는다.

# vgremove VG-01
Do you really want to remove volume group "VG-01" containing 2 logical volumes? [y/n]: y
Do you really want to remove and DISCARD active logical volume VG-01/LG-01? [y/n]: y
  Logical volume "LG-01" successfully removed
Do you really want to remove and DISCARD active logical volume VG-01/LG-02? [y/n]: y
  Logical volume "LG-02" successfully removed
  Volume group "VG-01" successfully removed

물리적 볼륨 삭제하기

pvremove 명령어로 물리적 볼륨을 삭제한다. 아래는 /dev/sdd1을 삭제하는 것.

# pvremove /dev/sdd1
  Labels on physical volume "/dev/sdd1" successfully wiped.

같은 카테고리의 다른 글

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

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

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

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

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

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

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

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

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

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

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

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

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

리눅스 / 명령어 / du / 디렉토리와 파일 용량 확인하는 명령어

리눅스 / 명령어 / du / 디렉토리와 파일 용량 확인하는 명령어

du는 disk usage의 약자로 디렉토리(폴더)와 파일의 용량을 출력해주는 명령어입니다. du 디렉토리명 디렉토리와 모든 하위 디렉토리의 용량을 표시해줍니다. 다음과 같이 명령하면 etc 디렉토리와 그 하위 디렉토리의 사용량이 출력됩니다. 단위는 kbyte입니다. du /etc du -s 디렉토리명, du -sh 디렉토리명 선택한 디렉토리만의 용량을 알고 싶으면 s 옵션을 붙입니다. du -s /etc 용량이 읽기 편한 단위로 나오게 하려면 h 옵션을 붙입니다. du -sh /etc du -sh ...

리눅스 / 사용자 / 사용자 조회, 사용자 추가, 사용자 삭제, 사용자 수정

리눅스 / 사용자 / 사용자 조회, 사용자 추가, 사용자 삭제, 사용자 수정

사용자 조회 모든 사용자를 출력합니다. # cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin ... root과 useradd 또는 adduser를 통해 생성한 사용자 계정을 출력합니다. # grep /bin/bash /etc/passwd root:x:0:0:root:/root:/bin/bash jb:x:1000:1000:JB:/home/jb:/bin/bash 사용자 추가 useradd jb 사용자를 만듭니다. useradd jb 사용자 홈 디렉토리도 같이 만들고 싶다면 -d 옵션을 사용합니다. useradd jb -d /home/jbdir jb 사용자의 비밀번호를 만듭니다. passwd jb adduser adduser 명령어로 사용자를 추가할 수 있습니다. useradd와는 달리 사용자 홈 디렉토리를 자동으로 만들고, 비밀번호 ...

리눅스 / 명령어 / alias / 명령어 별칭 만들기

리눅스 / 명령어 / alias / 명령어 별칭 만들기

긴 명령어 또는 복잡한 명령어를 자주 사용한다면 alias를 사용하자. 시간을 많이 절약할 수 있다. alias 목록 보기 alias를 실행하면 현재 등록된 alias를 출력한다. alias 예를 들어 ll을 실행한다는 것은 ls -alF를 실행하는 것과 같다. alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l='ls -CF' alias la='ls -A' alias ll='ls -alF' alias ls='ls --color=auto' alias 만들기 alias는 다음과 같이 만든다. abc를 실행하는 ...

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

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

그룹 조회 그룹 목록은 /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 명령으로 그룹을 삭제합니다. # ...

리눅스 / 명령어 / 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라는 디렉토리가 없다면, ...