Skip to content

파일 관리 명령어

디스크 사용량

  • df

    • 파일 시스템별 디스크 사용량

      Terminal window
      $ df --help
      Usage: df [OPTION]... [FILE]...
      Show information about the file system on which each FILE resides,
      or all file systems by default.
      Mandatory arguments to long options are mandatory for short options too.
      -a, --all include pseudo, duplicate, inaccessible file systems
      -h, --human-readable print sizes in powers of 1024 (e.g., 1023M)
      -t, --type=TYPE limit listing to file systems of type TYPE
      -T, --print-type print file system type
      $ df -h
      Filesystem Size Used Avail Use% Mounted on
      /dev/root 20G 13G 6.6G 66% /
      tmpfs 1.9G 0 1.9G 0% /dev/shm
      tmpfs 743M 1.3M 742M 1% /run
      tmpfs 5.0M 0 5.0M 0% /run/lock
      /dev/nvme0n1p15 105M 5.3M 100M 5% /boot/efi
      tmpfs 372M 4.0K 372M 1% /run/user/1000
  • df

    • 디렉터리, 사용자 별 디스크 사용량

    • 옵션 없이 사용 시 현재 디렉터리의 디스크 사용량을 출력

      $ du --help
      Usage: du [OPTION]... [FILE]...
      or: du [OPTION]... --files0-from=F
      Summarize disk usage of the set of FILEs, recursively for directories.
      -d, --max-depth=N print the total for a directory (or file, with --all)
      only if it is N or fewer levels below the command
      line argument; --max-depth=0 is the same as
      --summarize
      -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
      --inodes list inode usage information instead of block usage
      -s, --summarize display only a total for each argument
      $ du -h
      8.0K ./.ssh
      4.0K ./.cache
      8.0K ./.docker
      4.0K ./snap/certbot/common
      4.0K ./snap/certbot/3024
      4.0K ./snap/certbot/2913

quota

  • quotacheck

    • 쿼터 파일 생성/확인/수정을 위해 파일 시스템을 검사하는 명령어
    • [-a]: 전체 파일 시스템 검사
    • [-u]: 사용자 쿼터 확인
    • [-g]: 그룹 쿼터 확인
    • [-m] : 파일 시스템을 다시 마운트하지 않는다.
    • [-v] : 자세하게 출력

    $ quotacheck —help Utility for checking and repairing quota files. quotacheck [-gucbfinvdmMR] [-F ] filesystem|-a -a, —all check all filesystems -u, —user check user files -g, —group check group files

    -m, --no-remount do not remount filesystem read-only
    -M, --try-remount try remounting filesystem read-only,
    continue even if it fails
    - ex. `quotacheck -avugm`
  • quotaon

    • 파일 시스템의 쿼터 기능을 활성화하는 명령어

    $ quotaon —help quotaon: Usage: quotaon [-guPvp] [-F quotaformat] [-x state] -a quotaon [-guPvp] [-F quotaformat] [-x state] filesys …

    -a, --all turn quotas on for all filesystems
    -u, --user operate on user quotas
    -g, --group operate on group quotas
    -v, --verbose print more messages
    - ex. `quotaon -augv`
  • edquota

    • 쿼터를 설정하는 명령어 (vi 형식)

    $ edquota —help edquota: Usage: edquota [-u|g|-P] [-F formatname] [-f filesystem] -t edquota [-u|g|-P] [-F formatname] [-f filesystem] -T username|groupname|projectname …

    -u, --user edit user data
    -g, --group edit group data
    -P, --project edit project data
  • setquota

    • 쿼터를 설정하는 명령어 (커맨드 라인에서 옵션으로 설정하는 형식)
    • 형식 : setquota [옵션] [이름] [block soft limit] [block hard limit] [inode soft limit] [inode hard limit] [장치명]
    • ex. setquota -u fedora 1000 1100 0 0 /
  • quota

    • 쿼터 정보를 출력하는 명령어
    • [-u], [-g] 옵션 포함
    • ex. quota -u fedora → fedora 유저의 쿼터 설정 내용 출력
  • repquota

    • 쿼터 정보를 요약하여 출력하는 명령어
    • [-a], [-u], [-g] 옵션 포함
    • [-v]: 사용량이 없는 쿼터의 정보 출력

파일 시스템 ACL

  • 접근 권한을 확인하는 명령어
  • getfacl
    • 접근 권한을 확인하는 명령어
  • setfacl
    • 접근 권한을 설정하는 명령어

LVM

  1. 파티션의 종류 변경
    • fdiskt → 기존 83(linux) 를 8e(linux LVM)로 변경
  2. PV 생성
    • pvcreate
    • pvscan 명령어: PV 상태를 확인
  3. VG 생성: vgcreate 명령어
  4. VG 활성화
    • vgchange -a y: 활성화
    • vgchange -a n: 비활성화
    • vgdisplay -v: VG 상태 확인
  5. LV 생성
    • lvcreate
    • lvscan 명령어: LV 상태 확인
  6. LV에 파일 시스템 생성: mkfs/mke2fs 명령어 사용
  7. LV 마운트: mount 명령어 사용

파일 시스템 점검/복구

  • fsck
    • 파일 시스템을 검사/복구하는 명령어
    • $ fsck --help
      Usage:
      fsck [options] -- [fs-options] [<filesystem> ...]
      Check and repair a Linux filesystem.
      -A check all filesystems
      -V explain what is being done
    • fsck.ext2 / fsck.ext3 / fsck.ext4 명령어도 제공
  • e2fsck
    • 파일 시스템을 점검하기 전에 해당 파일 시스템을 umount 후 진행
    • [-j ext3/ext4]: ext3나 ext4 파일 시스템을 검사할 때 지정
  • badblocks
    • 지정한 장치의 배드 블록을 검사하는 명령어
    • -v: 검사 결과 자세히 출력
    • -o: 검사 결과를 지정한 출력 파일에 저장
  • tune2fs
    • ext2 파일 시스템을 설정(튜닝)하는 명령어
    • -i: ext2 파일 시스템을 ext3 파일 시스템으로 바꿈
    • -l: 파일 시스템 슈퍼 블록 내용을 출력