Linux_ 폴더 만들기/ 파일 명령어

김지영·2024년 2월 21일
0

Linux

목록 보기
5/9

리눅스의 폴더(디렉토리) / 파일 열기

1) 윈도우 : 프린터, 디스크 등은 일부 작은 프로그램등으로 되어 있음

2) 리눅스 : 프린터, 디스크 등은 파일로 관리됨

3) 폴더(디펙토리) 구조

(1) 경로(path) : /(슬래쉬) 사용해서 폴더 경로 표시함

예) /home/oracle => home 밑에 oracle 폴더
(vs 윈도우 명령프롬프트 : (역슬러쉬))

(2) 경로의 최상위 경로 : / => 루트(root) 경로

(3) 리눅스를 설치하면 시스템 폴더(관리 폴더)

/bin : 주요 명령어 들이 있는 폴더
/etc : 계정, 그룹, 패스워드 등의 환경설정 파일 있음
/home: 계정별로 할당되는 작업폴더
/sbin: 슈퍼 관리자가 사용하는 명령어들 있음
(컴퓨터 끄기, 켜기 등)
/tmp : 임시파일이 잠시 머무르는 폴더
/usr : 설치된 프로그램이 있는 폴더
/var : 로그(접속, 시스템감시 등)가 있는 폴더

4) 현재 폴더 또는 경로 확인

pwd

5) 절대경로 : /(슬래쉬) => 루트(root)경로(최상위경로)

예) /home/oracle, /home 등

상대경로 : 현재 자신을 위치를 기준으로 경로 설정

. : 현재 있는 경로
.. : 상위 경로
    예) ./ , ../usr : 상위 경로(폴더) 이동해서 usr 들어가기

● 실습: 폴더(디펙토리) 이동

예제 1) /usr 경로 이동

사용법 : cd 경로

cd == Change directory

oracle@cd10cec9dac9:~$ cd /usr
oracle@cd10cec9dac9:/usr$ pwd
/usr
oracle@cd10cec9dac9:/usr$

(2) 현재 폴더(디렉토리) 안의 파일/ 폴더 목록 출력

사용법 : ls

: 간략하게 목록 보기(파일, 폴더 등)

oracle@cd10cec9dac9:/usr$ ls
bin games include lib local sbin share src

사용법 : ls -lF
-l : 자세하게보기
-F : 폴더에 / 붙여서 출력하기
-a : 숨긴파일까지 모두 보기

oracle@cd10cec9dac9:/usr$ ls -lF
total 40
drwxr-xr-x 1 root root 4096 Feb 20 21:01 bin/
drwxr-xr-x 2 root root 4096 Apr 24 2018 games/
drwxr-xr-x 1 root root 4096 Feb 20 20:43 include/
drwxr-xr-x 1 root root 4096 Feb 20 21:01 lib/
drwxr-xr-x 1 root root 4096 May 30 2023 local/
drwxr-xr-x 1 root root 4096 Feb 20 21:01 sbin/
drwxr-xr-x 1 root root 4096 Feb 20 21:01 share/
drwxr-xr-x 2 root root 4096 Apr 24 2018 src/
oracle@cd10cec9dac9:/usr$

(3) 현재 경로에서 다른 경로의 목록 보기

사용법: ls 경로

oracle@cd10cec9dac9:~$ ls /usr
bin games include lib local sbin share src
oracle@cd10cec9dac9:~$

(4) 경로 자동완성 사용하기

tab 키

예제 2) /usr/local 경로를 자동완성 기능을 이용해서 이동하세요

oracle@cd10cec9dac9:~$ cd /usr/lo => (tad키 클릭) ---> cd /usr/local/ (자동완성됨)

연습1) /usr 밑에 lib로 이동해서 목록을 화면에 출력해 보세요.

oracle@2d5f598932bb:/usr/local$ cd /usr/lib
oracle@2d5f598932bb:/usr/lib$ ls
apt gcc mime python3.6 sudo tmpfiles.d
dpkg git-core openssh sasl2 systemd x86_64-linux-gnu
file locale os-release ssl tar
oracle@2d5f598932bb:/usr/lib$

(5) /home/계정명 : 작업폴더 도는 홈폴더(디렉토리)

1) 이동 : cd /home/oracle
2) ~ : cd ~

oracle@cd10cec9dac9:~$ pwd
/home/oracle
oracle@cd10cec9dac9:~$

(6) 이전 경로로 이동하기

예제 3) 이전 경로 /usr/lib 로 다시 이동하세요

사용법 : cd -

oracle@2d5f598932bb:~$ pwd
/home/oracle
oracle@2d5f598932bb:~$ cd -
/usr/lib
oracle@2d5f598932bb:/usr/lib$ pwd
/usr/lib

(7) cd ~ : 홈 폴더(디렉토리) 이동 : 틸트 확장

폴더만들기 : mkdir report
예제 4) 홈폴더(디렉토리) 밑에 report 로 이동하기
사용법 : cd ~/report

oracle@2d5f598932bb:~$ mkdir report
oracle@2d5f598932bb:~$ ls
report
oracle@2d5f598932bb:~$ pwd
/home/oracle
oracle@2d5f598932bb:~$ cd /usr
oracle@2d5f598932bb:/usr$ pwd
/usr
oracle@2d5f598932bb:/usr$ cd ~/report
oracle@2d5f598932bb:~/report$ pwd
/home/oracle/report
oracle@2d5f598932bb:~/report$

(8) 현재 경로에서 상위 경로로 이동하기

예제 5) /home/oracle -> /home 으로 이동하기(상위경로)
사용법 : cd ..
oracle@2d5f598932bb:~$ cd ..
oracle@2d5f598932bb:/home$ pwd
/home
oracle@2d5f598932bb:/home$

(9) 리눅스 명령어 체계

명령어 -옵션(생략) 매개변수(인자)
예) pwd (현재경로보기)
ls -al (ls : 목록(list) 보기)

(10) 특수기호 소개 : *(아스테리스크), ?(퀘스천)

예제 6) /usr/bin 폴더로 이동해서 b로시작되는 파일 또는 폴더를 화면에 출력하세요

사용법 : ls b*
oracle@2d5f598932bb:/home$ cd /usr/bin
oracle@2d5f598932bb:/usr/bin$ ls b*
b2sum  base32  base64  basename  bashbug
oracle@2d5f598932bb:/usr/bin$
예제 7) /usr/bin 에서 base 뒤에 임의의 2자를 포함하는 폴더 또는 파일을 모두 출력하세요
oracle@2d5f598932bb:/usr/bin$ ls base??
base32  base64
oracle@2d5f598932bb:/usr/bin$

11) 목록 상세보기 : ls -l

drwxr-xr-x 부분 :

d : 디렉토리(폴더), - : 파일

l : 심볼릭링크(윈도우의 바탕화면 바로가기 아이콘)

r : read(읽기권한)

w : write(쓰기권한)

x : excute(실행권한)


rwx (만든사람(user))

r-x (그룹(group))

r-x (다른사람(other))


(참고) 2: 심볼릭 링크수(바로가기 아이콘과 비슷)

oracle : 만든사람

dba : 만든사람의 그룹명

4096 : 폴더에 기본으로 제공하는 용량(4kb)

Feb 21 06:03 : 폴더 또는 파일 생성일자

oracle@2d5f598932bb:~$ ls -l
total 4
drwxr-xr-x 2 oracle dba 4096 Feb 21 06:03 report
oracle@2d5f598932bb:~$

profile
그냥 졍이라구하자

0개의 댓글