·터미널 명령어

ls

파일·디렉터리

쓰는 꼴

ls -la [path]

디렉터리에 무엇이 있는지 보여줍니다. 점으로 시작하는 이름은 -a를 붙일 때까지 숨어 있습니다.

자주 쓰는 옵션

옵션
-lOne line per entry with mode, owner, size and time
-aInclude names that begin with a dot
-hSizes as 4.0K instead of 4096, together with -l
-tSort by modification time, newest first
-rReverse whatever order is in effect
-SSort by size, largest first
-RWalk into subdirectories
-dShow the directory itself instead of its contents

예시

ls -lh

Long listing with readable sizes.

ls -lat

Newest first, hidden files included.

ls -d */

Only the directories in this folder.

옮기고 지우고 찾는 것들. 되돌릴 수 없는 명령이 섞여 있어 -i를 붙이는 습관이 손을 구합니다.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. ls은 무엇을 하나요?

디렉터리에 무엇이 있는지 보여줍니다. 점으로 시작하는 이름은 -a를 붙일 때까지 숨어 있습니다.

Q. 어떻게 치나요?

ls -la [path] — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 8개입니다. 전체 목록은 man ls에 있습니다. 이 명령은 파일·디렉터리 갈래입니다.

같이 보는 명령

man 페이지: man ls