docker 설치유무 확인
명령프롬프트 - 관리자 권한 - docker 치면 실행됨 : 설치가 잘 되었는지 확인하는 것!! 실행에는 아무 의미없음
도커의 명령어 : command line
애플의 스티브잡스 : 윈도우 개발당시 프로젝트 같이 참여했었음
위의 돋보기 탭 : 소프트웨어 다운로드하는 곳
Containers : 실행중인 프로그램 - 재생 : 실행, 중단 : 정지
Images : 다운로드 된 것들 보임
docker 설치 : 맥북버전 삭제하고 윈도우버전 깔기
1. Containers 에서 휴지통 모양 - 삭제
2. Images 에서 삭제
3. 재설치 - ubuntu-win - pull 눌러서 설치
4. Images : 설치된 목록 보임
5. 밑에 글 복사
● mac m1/m2 용 ubuntu 실행
docker run -it --name ubuntu kangtaegyung/ubuntu-edu
● windows 용 ubuntu 실행
docker run -it --name ubuntu kangtaegyung/ubuntu-win
6. 명령 프롬프트가서 붙여넣기
쾌적한 환경을 위한 환경설정
1. 왼쪽 하단 검색 : Microsoft Store 검색 (기능은 똑같은데 이쁜 디자인위해 다운로드, 필수 아님)
2. PowerShell -> 명령 프롬프트 변경
3. 명령 프롬프트 - "이 프로필을 관리자 권한으로 실행"에 켬으로 변경
4. 허접한 명령 프롬프트 종료 : exit 입력 후 enter
리눅스 사용위해 docker 켜기
1. docker 띄워서 Images 에서 재생 누르면 Running 뜸
밑에 있는 compenent 는 필요업승니 삭제하면 됨
2. 벨로그에 있는 이 코드블럭 - 명령 프롬프트에 복붙 : docker attach 이미지명(별명, 이미지id)
docker attach ubuntu
> : 윈도우 명령 프롬프트
# : 리눅스 명령 프롬프트
01_Linux 설치
0. 파일 -> vscode로 열기
1. 리눅스에 대해
02_계정 만들기
0. 리눅스/윈도우 os : 1대의 컴퓨터에 여러명이 접속해서 사용하는 프로그램
1) 계정 : 사용자를 의미
2) 계정관리 : 각 사용자별 작업 공간이 필요하므로 관리가 필요함
1. 그룹 생성 : groupadd 그룹명
(그룹 : 계정을 목적별로 분류해놓은것. ex) 개발자 그룹, 운영자 그룹)
C:\Users\GGG>docker attach ubuntu // docker 컨테이너 시작
root@731130ee71d4:/# groupadd dba
root@731130ee71d4:/#
2. 계정 생성 : useradd 유저명 -s 셀지정 -m -d 홈폴더 -g 그룹명
-s : 셀환경 선택(바탕화면 테마와 비슷) : /bin/bash(배쉬셀)이 인기셀
-m, -d : 홈폴더(=directory), 개인 사용자별 작업공간 폴더를 의미
-g : 그룹 지정
root@731130ee71d4:/# : 프롬프트, 계정명@컴퓨터명:/#
root : 최고의 권한을 가진 관리자 계정, 항상 자동생성됨
root@731130ee71d4:/# useradd oracle -s /bin/bash -m -d /home/oracle -g dba
root@731130ee71d4:/#
3. 비밀번호 생성 : passwd 계정명 (암호 설정 시 입력 글자는 안보임)
root@488a2397e634:/# passwd oracle
Enter new UNIX password: // Ds1234567890 안보이지만 입력했음
Retype new UNIX password: // Ds1234567890 안보이지만 입력했음
passwd: password updated successfully
root@488a2397e634:/#
4. oracle 계정으로 접속(root 에서 oracle 로 전환) : su - 계정명 (switch user 이라는 의미)
(최고관리자 root는 비밀번호 없어서 비밀번호 안치고 바로 oracle로 계정 바꾸면 됨)
root@488a2397e634:/# su - oracle
oracle@488a2397e634:~$
4-1) 다시 root 계정으로 오고싶을때 : exit
oracle@488a2397e634:~$ exit
logout
root@488a2397e634:/#
5. 명령 프롬프트 너무 많으면 화면 지우기 : Ctrl + L
6. 현재 경로 확인 : pwd
(pwd : print working directory)
oracle@488a2397e634:~$ pwd
/home/oracle
oracle@488a2397e634:~$
7. 폴더나 파일 목록 보기 : ls -a -l / ls -al
(ls : list / al : alias : 별명, 현재 등록된 alias 리스트 확인)
-a : 숨긴파일도 봄(.파일명 : 숨긴 파일)
ls : 목록 간략하게 보기 ★
ls -l : 목록을 자세히 보기(권한, 사이즈 등) ★
ls -a : (숨긴파일까지) 목록 간략하게 보기 ★
ls -al : (숨긴파일까지) 자세히 보기(폴더 크기, 시간 등) ★
oracle@488a2397e634:~$ ls
report
oracle@488a2397e634:~$ ls -a
. .. .bash_history .bash_logout .bashrc .profile report // 목록 상세,간략
oracle@488a2397e634:~$ ls -al
total 28
drwxr-xr-x 3 oracle dba 4096 Feb 21 06:03 . // 목록 상세보기
drwxr-xr-x 1 root root 4096 Feb 21 01:32 ..
-rw------- 1 oracle dba 61 Feb 21 03:01 .bash_history
-rw-r--r-- 1 oracle dba 220 Apr 4 2018 .bash_logout
-rw-r--r-- 1 oracle dba 3771 Apr 4 2018 .bashrc
-rw-r--r-- 1 oracle dba 807 Apr 4 2018 .profile
drwxr-xr-x 2 oracle dba 4096 Feb 21 06:03 report
oracle@488a2397e634:~$
oracle@488a2397e634:~$ ls -al
total 20
drwxr-xr-x 2 oracle dba 4096 Feb 21 01:32 .
drwxr-xr-x 1 root root 4096 Feb 21 01:32 ..
-rw-r--r-- 1 oracle dba 220 Apr 4 2018 .bash_logout
-rw-r--r-- 1 oracle dba 3771 Apr 4 2018 .bashrc
-rw-r--r-- 1 oracle dba 807 Apr 4 2018 .profile
oracle@488a2397e634:~$
03_기본명령어
현재 날짜 보기 : date
oracle@488a2397e634:~$ date
Wed Feb 21 02:30:02 UTC 2024
oracle@488a2397e634:~$
화면에 문자열 출력하기 : echo 문자열
oracle@488a2397e634:~$ echo Hello
Hello
oracle@488a2397e634:~$ echo Hello World
Hello World
oracle@488a2397e634:~$
현재 사용하는 셀 보기 : echo $SHELL ($SHELL : 환경변수, 셀변수, 리눅스의 현재 셀환경이 저장됨)
oracle@488a2397e634:~$ echo $SHELL
/bin/bash
oracle@488a2397e634:~$
프롬프트 : $, # 이 앞에 붙어있는 표시
프롬프트 구조 : 계정명@컴퓨터명(ip주소):~$
- root : 최고관리자 계정, # 프롬프트 사용
- oracle : 일반계정, $ 프롬프트 사용
oraoracle@488a2397e634:~$, root@488a2397e634:/#
계정 전환
1) 일반 계정일 때 : exit
2) root 계정일 때 : su - 계정명
(su : substitute user : 현 사용자를 로그아웃 하지 않고, 다른 사용자의 권한을 획득)
oracle@488a2397e634:~$ exit
logout
root@488a2397e634:/# su - oracle
oracle@488a2397e634:~$
리눅스를 사용하며 만날 수 있는 문제
1. 키보드 입력이 갑자기 안됨 : Ctrl + q
2. 실행한 명령어가 종료되지 않아 계속 실행됨 : Ctrl + c
3. 종료(로그아웃) : exit
1) 키보드 입력이 갑자기 안됨
Ctrl + s : 화면 표시 잠김(눈에는 안보이지만 입력됨)
Ctrl + q : 잠김 해제
2) 실행한 명령어가 종료되지 않아 계속 실행됨
Ctrl + c : 강제 실행 중단
# oracle@2d5f598932bb:~$ ping www.google.com
# ...
# ctrl + c
3) 종료(로그아웃) : exit
리눅스의 자동완성 : 2번 tab 키 입력하면 여러 후보를 화면에 보여줌
oracle@488a2397e634:~$ e
e2freefrag e2label e4defrag editor else encguess eval exit export
e2fsck e2undo echo egrep enable env ex expand expr
e2image e4crypt edit elif enc2xs esac exec expiry
oracle@488a2397e634:~$ e
명령어 이력(history) 보기 기능 : 화살표 위(이전 명령어), 화살표 아래(최근 명령어)
oracle@2d5f598932bb:~$ pwd
/home/oracle
명령어 검색 기능 : Ctrl + r
(failed reverse-i-search)`eco': echo $SHELL
enter 키 : 실행
04_폴더_파일명령어
1. 리눅스의 파일 알기
1. 윈도우 : 프린터, 디스크 등은 일부 작은 프로그램 등으로 되어 있음
2. 리눅스 : 모든 하드웨어 장치(프린터, 디스크) 등은 모두 파일로 관리됨
3. 폴더(디렉토리) 구조
1) 경로(Path) : /(슬래쉬) 사용해서 폴더 경로 표시함
ex) /home/oracle => home 밑의 oracle 폴더
(vs 윈도우 명령프롬프트 : \(역슬래쉬))
2) 경로의 최상위 경로 : / => 루트(root)경로
3) 리눅스 설치하면 시스템 폴더(관리 폴더)
/bin : 주요 명령어들이 들어있는 폴더, 중요도가 높은 명령어들이 있음
/etc : 계정, 그룹, 패스워드 등의 환경설정 파일 있음
/home : 사용자별(계정별)로 할당되는 작업폴더
/sbin : 슈퍼관리자가 사용하는 명령어들이 있음(서버끄기/켜기 등)
/tmp : 임시 파일들이 잠시 머무르는 폴더(주기적으로 리눅스가 삭제함)
/usr : 설치된 프로그램이 있는 폴더
/var : 로그(접속로그, 시스템감시로그 등)가 있는 폴더
4. 현재 폴더 또는 경로 확인 : pwd
oracle@488a2397e634:~$ pwd
/home/oracle
oracle@488a2397e634:~$
5. 경로 : 절대경로, 상대경로
1) 절대경로 : / (루트 경로)
2) 상대경로 : . 또는 .. 사용
1) 절대경로 : /(슬래쉬) => 루트(root)경로, 최상위경로 로 시작해서 현재 자신의 경로까지 작성하는 것
ex) /home/oracle, /home 등
2) 상대경로 : 현재 자신의 위치를 기준으로 경로 설정
. : 현재 있는 경로
..: 상위 경로
ex) ./ : 현재 폴더 위치
../usr : 상위 경로(폴더)로 이동해서 usr 들어가기
2. 실습 : 폴더(디렉토리) 이동
1. 경로 이동 : cd 경로
(cd : change directory)
oracle@488a2397e634:~$ cd /usr
oracle@488a2397e634:/usr$ pwd
/usr
2. 현재 디렉토리 안의 파일/디렉토리 목록 출력
1) 간략하게 단순 목록(파일, 폴더) 보기 : ls
예제 2) /usr/local 경로를 자동완성 기능을 이용해서 이동하세요
oracle@488a2397e634:/usr$ ls
bin games include lib local sbin share src
oracle@488a2397e634:/usr$
2) 자세하게 보기 : ls -lF
-s : 자세하게 보기
-F : 폴더에 /붙여서 출력하기, 없는 것은 파일
-a : 숨긴 파일까지 모두 보기
oracle@488a2397e634:/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@488a2397e634:/usr$
3) 현재 경로에서 다른 경로의 목록 보기 : ls 경로
oracle@488a2397e634:~$ ls /usr
bin games include lib local sbin share src
oracle@488a2397e634:~$
4) 경로 자동완성 : tab키
oracle@488a2397e634:~$ cd /usr/lo
-> tab키
oracle@488a2397e634:~$ cd usr/local/
연습 1) /usr 밑에 lib로 이동해서 목록을 화면에 출력해보세요 : cd /usr/경로 -> ls
oracle@488a2397e634:/usr/local$ cd /usr/lib
oracle@488a2397e634:/usr/lib$ ls
apt file git-core mime os-release sasl2 sudo tar x86_64-linux-gnu
dpkg gcc locale openssh python3.6 ssl systemd tmpfiles.d
oracle@488a2397e634:/usr/lib$
5) 홈폴더(디렉토리)로 이동 방법
1) 직접 이동 : cd /home/oracle
2) ~ 사용 : cd~
home/oracle : home 폴더와 계정명까지 같이 보이는게 홈 디렉토리임
1) 이동 : cd /home/oracle
2) ~ : cd~
oracle@488a2397e634:/usr/lib$ cd ~
oracle@488a2397e634:~$ pwd
/home/oracle // home 폴더로 이동 + 계정명
oracle@488a2397e634:~$
6) 이전경로로 이동하기 : cd -
예제 3) 이전 경로 /usr/lib로 다시 이동하세요
oracle@488a2397e634:~$ pwd
/home/oracle
oracle@488a2397e634:~$
oracle@488a2397e634:~$ cd -
/usr/lib
oracle@488a2397e634:/usr/lib$ pwd
/usr/lib
7) 폴더 만들기, 틸트 확장
- mkdir 폴더명 : 폴더 만들기 (mkdir : make directory)
- cd ~/폴더명 : 홈 폴더로 가서 해당 폴더로 이동 = 틸트 확장
예제 4) 홈폴더 밑의 report로 이동하기
#사용법 : cd ~/report
oracle@488a2397e634:~$ ls // 현재 경로의 목록 보기
oracle@488a2397e634:~$ mkdir report
oracle@488a2397e634:~$ ls
report
oracle@488a2397e634:~$ pwd
/home/oracle
oracle@488a2397e634:~$ cd /usr
oracle@488a2397e634:/usr$ pwd
/usr
oracle@488a2397e634:/usr$ cd ~/report
oracle@488a2397e634:~/report$ pwd
/home/oracle/report
oracle@488a2397e634:~/report$
8) 현재 경로에서 상위 경로로 이동 : cd ..
예제 5) /home/oracle -> /home 으로 이동하기(상위경로)
oracle@488a2397e634:~/report$ cd ~ // 홈 폴더로 이동
oracle@488a2397e634:~$ pwd // 현재 경로 확인
/home/oracle // home/oracle
oracle@488a2397e634:~$ cd ..
oracle@488a2397e634:/home$ pwd // 현재 경로 확인
/home // home
oracle@488a2397e634:/home$
9) 리눅스 명령어 체계 : 명령어 -옵션(생략) 매개변수(인자)
ex) pwd (현재경로보기)
ls -al (ls : 목록(list) 보기)
10) 특수기호 소개 : *(아스테리스크), ?(question)
1) ls b* : 임의의 문자열
예제 6) /usr/bin 폴더로 이동해서 b로 시작되는 파일 또는 폴더를 화면에 출력하세요
#사용법 : ls b*
oracle@488a2397e634:/home$ cd /usr/bin
oracle@488a2397e634:/usr/bin$ ls
oracle@488a2397e634:/usr/bin$ ls b*
b2sum base32 base64 basename bashbug
oracle@488a2397e634:/usr/bin$
2) ls base?? : 임의의 한문자
예제 7) /usr/bin 에서 base 뒤에 임의의 2자를 포함하는 폴더 또는 파일을 모두 출력하세요
# 사용법 : ls base??
oracle@488a2397e634:/usr/bin$ ls base??
base32 base64
oracle@488a2397e634:/usr/bin$
11) drwxr-xr-x : 권한 관리 정보
d : 폴더
l : 심볼릭 링크(윈도우의 바탕화면 바로가기 아이콘)
r : 읽기 권한
w : 쓰기 권한
x : 실행 권한
oracle@488a2397e634:~$ ls -l // 목록 상세보기
total 4
drwxr-xr-x 2 oracle dba 4096 Feb 21 06:03 report
oracle@488a2397e634:~$
d : directory(폴더), - : 파일
l : 심볼릭링크(윈도우의 바탕화면 바로가기 아이콘)
r : read(읽기 권한)
w : write(쓰기 권한)
x : excute(실행 권한) // - : 권한이 없다는 뜻
rwx r-x r-x
(파일 또는 폴더를 만든 사람(user)의 권한) (그룹(group)의 권한) (다른사람(other)의 권한)
* 참고 *
2 : 심볼릭 링크수(바로가기 아이콘과 비슷)
oracle : 이 폴더를 만든 사람
dba : 이 폴더를 만든사람의 그룹
4096 : 폴더에 기본으로 제공하는 용량
Feb 21 06:03 : 폴더 또는 파일 생성일자
05_파일_컨트롤
1. 폴더(디렉토리) 만들기 : mkdir [옵션] 폴더명
예제 1) work 폴더 만들기
oracle@488a2397e634:~$ mkdir work
oracle@488a2397e634:~$ ls
report work
oracle@488a2397e634:~$
2. 자식 폴더까지 한번에 만들기 : -p 폴더/자식폴더/자식폴더
예제 2) work 폴더 만들기
oracle@488a2397e634:~$ mkdir -p work/2021/05
oracle@488a2397e634:~$ cd ./work
oracle@488a2397e634:~/work$ ls
2021
oracle@488a2397e634:~/work$ cd ./2021
oracle@488a2397e634:~/work/2021$ ls
05
oracle@488a2397e634:~/work/2021$ cd 05
oracle@488a2397e634:~/work/2021/05$
연습 1) report/2021/05 폴더 만들기
oracle@2d5f598932bb:~$ mkdir -p report/2021/05
연습 2) report/2022/05 폴더 만들기 : -p 옵션 안쓰고 만들기
oracle@2d5f598932bb:~$ cd report/
oracle@2d5f598932bb:~/report$ ls
2021
oracle@2d5f598932bb:~/report$ mkdir 2022
oracle@2d5f598932bb:~/report$ ls
2021 2022
oracle@2d5f598932bb:~/report$ cd 2022
oracle@2d5f598932bb:~/report/2022$ ls
oracle@2d5f598932bb:~/report/2022$ mkdir 05
oracle@2d5f598932bb:~/report/2022$ ls
05
oracle@2d5f598932bb:~/report/2022$
3. 폴더 삭제 : rmdir 폴더명(디렉토리명)
(참고) 빈 폴더만 삭제돼서 폴더 안에 파일이 있으면 삭제 안됨, 그 파일까지 가서 직접 삭제해야함
예제 3) report/2021/05 에서 05 폴더만 삭제하기
# 사용법 : rmdir 폴더명(디렉토리명)
oracle@2d5f598932bb:~$ cd report/2021
oracle@2d5f598932bb:~/report/2021$ ls
05
oracle@2d5f598932bb:~/report/2021$ rmdir 05
oracle@2d5f598932bb:~/report/2021$ ls
연습 1) report/2021에서 2021, 2022 폴더 삭제하기
oracle@2d5f598932bb:~/report$ rmdir 2021
oracle@2d5f598932bb:~/report$ ls
연습 2) report 폴더도 삭제하기
# report 안에 있는 자식 폴더(디렉토리) 모두 삭제하고 마지막에 report 삭제하기
oracle@2d5f598932bb:~/report$ rmdir 2022
rmdir: failed to remove '2022': Directory not empty
oracle@2d5f598932bb:~/report$ cd 2022
oracle@2d5f598932bb:~/report/2022$ ls
05
oracle@2d5f598932bb:~/report/2022$ rmdir 05
oracle@2d5f598932bb:~/report/2022$ cd ..
oracle@2d5f598932bb:~/report$ ls
2022
oracle@2d5f598932bb:~/report$ rmdir 2022
oracle@2d5f598932bb:~/report$ cd ..
oracle@2d5f598932bb:~$ ls
report work
oracle@2d5f598932bb:~$ rmdir report
oracle@2d5f598932bb:~$ ls
4. 빈 파일 만들기 : touch 파일명 파일명2 ...
(폴더는 파란, 파일은 흰색)
예제 4) work 폴더(디렉토리)에서 newfile 빈파일을 만드세요
oracle@2d5f598932bb:~$ cd work/
oracle@2d5f598932bb:~/work$ ls
2021
oracle@2d5f598932bb:~/work$ touch newfile
oracle@2d5f598932bb:~/work$ ls
2021 newfile
oracle@2d5f598932bb:~/work$
연습 1) work 폴더에서 newfile2, newfile3 빈파일을 만드세요
oracle@488a2397e634:~$ cd work // work 파일안에 들어가서 만들기
oracle@488a2397e634:~/work$ ls
2021 newfile
oracle@488a2397e634:~/work$ touch newfile2
oracle@488a2397e634:~/work$ ls
2021 newfile newfile2
oracle@488a2397e634:~/work$ touch newfile3
oracle@488a2397e634:~/work$ ls
2021 newfile newfile2 newfile3
oracle@488a2397e634:~/work$
5. 빈 파일 삭제하기 : rm 파일명 파일명2 ...
예제 6) work 폴더에서 newfile 삭제하기
oracle@488a2397e634:~/work$ rm newfile
oracle@488a2397e634:~/work$ ls
2021 newfile2 newfile3
oracle@488a2397e634:~/work$
연습 1) work 폴더(디렉토리)에서 newfile2, newfile3 삭제하기
oracle@488a2397e634:~/work$ rm newfile2 newfile3
oracle@488a2397e634:~/work$ ls
2021
oracle@488a2397e634:~/work$
6. 파일 내용을 화면에 출력하기 : cat 파일명 (폴더는 안됨)
예제 6) /etc 폴더(디렉토리)로 이동해서 hostname 파일의 내용을 화면에 출력하세요
# (참고) hostname 파일 : 리눅스의 환경파일(컴퓨터명이 있음)
oracle@488a2397e634:~/work$ cd /etc
oracle@488a2397e634:/etc$ ls host*
host.conf hostname hosts
oracle@488a2397e634:/etc$ cat hostname
488a2397e634
oracle@488a2397e634:/etc$
7. 파일의 내용이 많을 때 사용하는 뷰어 : less 파일명
- 스페이스 바 : 다음 페이지
- b 키 : 이전 페이지
- q 키 : less 뷰어 종료
- /찾을문자열 : 검색기능, 아래페이지로 검색
- ?찾을문자열 : 검색기능, 윗 페이지로 검색
예제 7) 개인 환경설정 파일(숨김파일) : .bashrc 보기
oracle@488a2397e634:~$ pwd
/home/oracle
oracle@488a2397e634:~$ ls -al
total 28
drwxr-xr-x 3 oracle dba 4096 Feb 21 08:07 .
drwxr-xr-x 1 root root 4096 Feb 21 01:32 ..
-rw------- 1 oracle dba 61 Feb 21 03:01 .bash_history
-rw-r--r-- 1 oracle dba 220 Apr 4 2018 .bash_logout
-rw-r--r-- 1 oracle dba 3771 Apr 4 2018 .bashrc
-rw-r--r-- 1 oracle dba 807 Apr 4 2018 .profile
drwxr-xr-x 3 oracle dba 4096 Feb 21 08:14 work
oracle@488a2397e634:~$ less .bashrc
oracle@488a2397e634:~$
8. 파일 복사하기 : cp 복사할파일명 새로운파일명
예제 8) work 폴더에서 newfile을 만들고 복사해서 newfile2 만드세요
oracle@488a2397e634:~$ cd work
oracle@488a2397e634:~/work$ ls
2021
oracle@488a2397e634:~/work$ touch newfile
oracle@488a2397e634:~/work$ ls
2021 newfile
oracle@488a2397e634:~/work$ cp newfile newfile2
oracle@488a2397e634:~/work$ ls
2021 newfile newfile2
oracle@488a2397e634:~/work$
연습 1) work 폴더에서 newfile 복사해서 newfile3, newfile4 만드세요
oracle@488a2397e634:~/work$ ls
2021 newfile newfile2
oracle@488a2397e634:~/work$ cp newfile newfile3
oracle@488a2397e634:~/work$ ls
2021 newfile newfile2 newfile3
oracle@488a2397e634:~/work$ cp newfile newfile4
oracle@488a2397e634:~/work$ ls
2021 newfile newfile2 newfile3 newfile4
cd 2021 이런식으로 하면 안되고 cd /usr/work/2021 이런식으로 폴더에 들어가서 폴더명을 적어야함
최상위 폴더에서 자식폴더 2021을 바로 찾을수없기에 절대경로나, 상대경로를 통해서 들어가야함
9. 폴더(디렉토리) 안에 파일 복사하기 : cp 복사할파일명 폴더명
예제 9) work 에서 dir1 폴더를 만들고 newfile을 dir1 안에 복사해놓으세요
oracle@488a2397e634:~/work$ mkdir dir1
oracle@488a2397e634:~/work$ ls
2021 dir1 newfile newfile2 newfile3 newfile4
oracle@488a2397e634:~/work$ cp newfile dir1
oracle@488a2397e634:~/work$ ls
2021 dir1 newfile newfile2 newfile3 newfile4
oracle@488a2397e634:~/work$ cd dir1
oracle@488a2397e634:~/work/dir1$ ls
newfile
oracle@488a2397e634:~/work/dir1$
10. 파일 변경 / 이동
10-1) 파일명 변경 명령어 : mv 파일명 변경할파일명
(mv : move_이동,변경)
예제 10) work 폴더 안에 있는 newfile을 file1으로 변경하세요
oracle@488a2397e634:~/work/dir1$ mv newfile file1
oracle@488a2397e634:~/work/dir1$ ls
file1
oracle@488a2397e634:~/work/dir1$
연습 1) work 밑에 있는 newfile2 -> file2, newfile3 -> file3으로 변경하세요
oracle@488a2397e634:~/work$ mv newfile2 file2
oracle@488a2397e634:~/work$ ls
2021 dir1 file2 newfile newfile3 newfile4
oracle@488a2397e634:~/work$ mv newfile3 file3
oracle@488a2397e634:~/work$ ls
2021 dir1 file2 file3 newfile newfile4
oracle@488a2397e634:~/work$
10-2) 파일 이동 명령어 : mv 파일명 경로(절대경로/상대경로/폴더명)
예제 11) file2를 dir1 폴더 안으로 옮기기(이동)
oracle@2d5f598932bb:~/work$ mv file2 dir1
oracle@2d5f598932bb:~/work$ ls
2021 dir1 file3 newfile newfile4
oracle@2d5f598932bb:~/work$ cd dir1
oracle@2d5f598932bb:~/work/dir1$ ls
file1 file2
oracle@2d5f598932bb:~/work/dir1$ cd ..
oracle@2d5f598932bb:~/work$
# 복습 : 절대경로 : / 기준으로 경로 정의
ex) /home, /home/oracle 등
# 상대경로 : . 또는 .. 이용해서 경로를 정의
ex) ./report, cd .. 등
'Linux' 카테고리의 다른 글
#40 [docker] 컨테이너 (0) | 2024.02.22 |
---|---|
#40 [Linux] 권한 : chmod [사용자(u,g,o)][+/-][권한(r,w,x)] 파일명, chmod 숫자 파일명 (0) | 2024.02.22 |
#40 [Linux] 셀, 셀변수, 프롬프트, echo $SHELL, echo $PATH, locale -a, 환경설정 파일 (0) | 2024.02.22 |
#40 [Linux] vi 에디터 : 명령어모드 / 편집모드 (0) | 2024.02.22 |
#38 [Docker, Linux] 설치 (0) | 2024.02.20 |