웹사이트 검색

초보자를 위한 Linux vdir 명령 자습서(예제 8개)


이 페이지에서

  1. Q1. vdir을 사용하는 방법?\n
  2. Q2. 점(.)으로 시작하는 vdir 표시 항목을 만드는 방법은 무엇입니까?\n
  3. Q3. 고정 크기로 vdir 스케일 크기를 만드는 방법은 무엇입니까?
  4. Q4. vdir이 ls와 같은 출력을 생성하는 방법은 무엇입니까?\n
  5. Q5. vdir에서 컬러 출력을 생성하는 방법은 무엇입니까?\n
  6. Q6. vdir이 정렬되지 않은 출력을 생성하는 방법은 무엇입니까?\n
  7. Q7. 출력에서 vdir 그룹 디렉토리를 먼저 만드는 방법은 무엇입니까?
  8. Q8. vdir이 각 파일에 대한 색인 번호를 생성하도록 하는 방법은 무엇입니까?\n

디렉토리의 내용을 나열하는 것은 사용자(프로와 멍청이 모두)가 관여하는 가장 기본적인 작업 중 하나입니다. ls 명령은 이 목적에 사용되는 가장 인기 있는 도구입니다. 그러나 유일한 것은 아닙니다.

몇 가지 대안이 있습니다. 예를 들어 vdir이라는 유틸리티가 있습니다. 기본 사항은 여기에서 자세히 설명합니다. 그러나 그 전에 이 튜토리얼의 모든 예제는 Ubuntu 18.04 LTS 및 Debian 10 시스템에서 테스트되었음을 언급할 가치가 있습니다.

ls와 마찬가지로 Linux의 vdir 명령도 디렉토리 내용을 나열하는 데 사용됩니다. 구문은 다음과 같습니다.

vdir [OPTION]... [FILE]...

도구 매뉴얼 페이지에서 설명하는 방법은 다음과 같습니다.

List information about the FILEs (the current directory by default).  
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

다음은 vdir 명령의 작동 방식에 대한 좋은 아이디어를 제공하는 몇 가지 Q&A 스타일의 예입니다.

Q1. vdir을 사용하는 방법?

기본 사용법은 매우 간단합니다. 옵션 없이 vdir 명령을 실행하기만 하면 됩니다.

vdir

예를 들어 필자의 경우 vdir을 실행하면 다음과 같은 결과가 출력됩니다.

total 12
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Desktop
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Documents
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Downloads
-rw-r--r-- 1 guest-A8CLd9 guest-A8CLd9 2513 Apr 16 14:33 examples.desktop
drwxrwxr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Files-From-Desktop
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Music
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Pictures
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Public
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Templates
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9   40 Apr 16 14:33 Videos

따라서 출력이 ls -l 명령과 유사하다는 것을 알 수 있습니다.

Q2. 점(.)으로 시작하는 vdir 표시 항목을 만드는 방법은 무엇입니까?

기본적으로 vdir 명령 출력에는 점(.)으로 시작하는 이름이 표시되지 않습니다. 그러나 -a 명령줄 옵션을 사용하여 이 동작을 변경할 수 있습니다.

vdir -a

제 경우에는 다음과 같은 출력이 생성되었습니다.

total 52
drwx------ 20 guest-A8CLd9 guest-A8CLd9   540 Sep 26 09:30 .
drwxrwxrwt  7 root         root         16384 Sep 26 10:17 ..
-rw-r--r--  1 guest-A8CLd9 guest-A8CLd9   220 Sep 26 09:29 .bash_logout
-rw-r--r--  1 guest-A8CLd9 guest-A8CLd9  3637 Sep 26 09:29 .bashrc
drwxr-xr-x 12 guest-A8CLd9 guest-A8CLd9   260 Sep 26 09:37 .cache
drwxr-xr-x 16 guest-A8CLd9 guest-A8CLd9   360 Sep 26 09:29 .config
drwxr-xr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Desktop
drwxr-xr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Documents
drwxr-xr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Downloads
-rw-r--r--  1 guest-A8CLd9 guest-A8CLd9  8980 Sep 26 09:29 examples.desktop
drwxrwxr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Files-From-Desktop
drwx------  3 guest-A8CLd9 guest-A8CLd9    60 Sep 26 09:30 .gconf
drwx------  3 guest-A8CLd9 guest-A8CLd9    60 Sep 26 09:30 .gnome2
drwx------  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:30 .gnome2_private
-rw-------  1 guest-A8CLd9 guest-A8CLd9   358 Sep 26 09:29 .ICEauthority
drwxr-xr-x  3 guest-A8CLd9 guest-A8CLd9    60 Sep 26 09:29 .kde
drwx------  3 guest-A8CLd9 guest-A8CLd9    60 Sep 26 09:29 .local
drwx------  4 guest-A8CLd9 guest-A8CLd9    80 Sep 26 09:30 .mozilla
drwxr-xr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Music
drwxr-xr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Pictures
-rw-r--r--  1 guest-A8CLd9 guest-A8CLd9   697 Sep 26 09:29 .profile
drwxrwxr-x  2 guest-A8CLd9 guest-A8CLd9    60 Sep 26 09:29 .psensor
drwxr-xr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Public
drwxr-xr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Templates
drwxr-xr-x  2 guest-A8CLd9 guest-A8CLd9    40 Sep 26 09:29 Videos
-rw-------  1 guest-A8CLd9 guest-A8CLd9    61 Sep 26 09:29 .Xauthority
-rw-------  1 guest-A8CLd9 guest-A8CLd9   108 Sep 26 09:29 .xsession-errors

따라서 점으로 시작하는 파일 이름도 출력에 생성되는 것을 볼 수 있습니다.

Q3. 고정 크기로 vdir 스케일 크기를 만드는 방법은 무엇입니까?

vdir이 크기(출력의 5번째 열)를 메가바이트 단위로 인쇄하기를 원한다고 가정하면 M을 입력으로 제공하여 --block-size 옵션을 사용하여 이를 수행할 수 있습니다.

vdir --block-size=M

다음은 이 명령이 내 시스템에서 생성한 출력입니다.

total 1M
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Desktop
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Documents
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Downloads
-rw-r--r-- 1 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 examples.desktop
drwxrwxr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Files-From-Desktop
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Music
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Pictures
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Public
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Templates
drwxr-xr-x 2 guest-A8CLd9 guest-A8CLd9 1M Sep 26 09:29 Videos

따라서 크기 항목이 메가바이트(M) 단위로 생성되는 것을 볼 수 있습니다.

다음은 이 옵션에 필요한 입력과 관련된 몇 가지 유용한 정보입니다.

       The  SIZE  argument  is  an  integer and optional unit (example: 10K is
       10*1024).  Units are K,M,G,T,P,E,Z,Y  (powers  of  1024)  or  KB,MB,...
       (powers of 1000).

Q4. vdir이 ls와 같은 출력을 생성하는 방법은 무엇입니까?

기본적으로 ls 명령은 출력에 세부 정보를 생성하지 않습니다. 현재 디렉토리의 파일/디렉토리 이름만 표시합니다.

그러나 vdir은 기본적으로 많은 정보를 생성합니다. 그러나 원하는 경우 vdir을 출력과 같은 ls로 제한할 수 있습니다. 이것은 -C 명령줄 옵션을 사용하여 수행할 수 있습니다.

vdir -C

제 경우에는 다음과 같은 출력이 생성되었습니다.

Desktop  Documents  Downloads  examples.desktop  Files-From-Desktop  Music  Pictures  Public  Templates  Videos

Q5. vdir에서 컬러 출력을 생성하는 방법은 무엇입니까?

이전 섹션에서 vdir에 의해 생성된 출력을 ls 명령에 의해 생성된 출력과 비교하면 한 가지 차이점을 관찰할 수 있습니다.

그러나 vdir이 컬러 출력을 생성하도록 할 수도 있습니다. --color 명령줄 옵션을 사용하여 이 작업을 수행할 수 있습니다.

vdir --color

Q6. vdir이 정렬되지 않은 출력을 생성하는 방법은 무엇입니까?

이것은 -f 명령줄 옵션을 사용하여 수행할 수 있습니다.

vdir -f

다음은 제 경우에 이 명령이 생성한 출력입니다.

.         .gnome2   Files-From-Desktop  .local     Music        Templates  .xsession-errors  .cache           .bash_logout
..         .mozilla  .ICEauthority       Videos     Documents  Downloads  .Xauthority     .config       .profile
.gnome2_private  .psensor  .gconf           Pictures  Public     Desktop    .kde         examples.desktop  .bashrc

매뉴얼 페이지에서 이 -f 옵션을 설명하는 방법은 다음과 같습니다.

-f     do not sort, enable -aU, disable -ls --color

Q7. 출력에서 vdir 그룹 디렉토리를 먼저 만드는 방법은 무엇입니까?

vdir 명령이 출력에서 먼저 디렉토리를 그룹화하도록 하려면 --group-directories-first 옵션을 사용하십시오.

vdir --group-directories-first

다음은 제 경우에 이 명령이 생성한 출력입니다.

total 12
drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Desktop
drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Documents
drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Downloads
drwxrwxr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Files-From-Desktop
drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Music
drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Pictures
drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Public
drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Templates
drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Videos
-rw-r--r-- 1 guest-eugepN guest-eugepN 8980 Aug 22  2011 examples.desktop

따라서 모든 디렉토리가 먼저 나열되는 것을 볼 수 있습니다.

Q8. vdir이 각 파일에 대한 색인 번호를 생성하도록 하는 방법은 무엇입니까?

이는 -i 명령줄 옵션을 사용하여 수행할 수 있습니다.

vdir -i

다음은 샘플 출력입니다.

total 12
 22 drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Desktop
 26 drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Documents
 23 drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Downloads
  6 -rw-r--r-- 1 guest-eugepN guest-eugepN 8980 Aug 22  2011 examples.desktop
155 drwxrwxr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Files-From-Desktop
 27 drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Music
 28 drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Pictures
 25 drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Public
 24 drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Templates
 29 drwxr-xr-x 2 guest-eugepN guest-eugepN   40 Aug 22  2011 Videos

첫 번째 열에는 해당 색인 번호가 포함되어 있습니다.

요구 사항에 따라 vdir 명령이 유용한 도구가 될 수 있습니다. 이 자습서에서는 이 유틸리티가 제공하는 몇 가지 주요 옵션에 대해 설명했습니다. 이 도구에 대해 자세히 알아보려면 해당 매뉴얼 페이지로 이동하십시오.