본문 바로가기
Web & Mobile/Linux

Lecture 63 - Linux(1) 리눅스의 기초

by Bennyziio 2019. 6. 17.
반응형
OS
        Operating System(운영체제)
        Platform
하드웨어
        - OS
        - Windows
        - 가상화(Virtualiazation) - 가상하드웨어
                - AWS(아마존))
                - 네이버N클라우드
                        https://www.ncloud.com/
        
        Oracle virtural Box     - 무료(Java) 느림
        VMware vmware           - 무료/유료
                                - c++
                                - 편리

        Mac Parallel(가상화시스템) - 완전유료/완전편함
                vmware fusion(어둠의 루트)

하드디스크
        윈도우
        : 드라이브별 파티션
        c: d: e:
                - 포맷가능
        리눅스
        : 드라이브 개념이 없고 전부 디렉토리
        => 디렉토리 별로 파티션을 포맷 가능
서버
        - 리부팅(거의 안함)
        - 서버 - 리부팅하는데 5분 걸림

리눅스의 기초

리눅스의 시작
- 핀란드 헬싱키대학교의 학생이었던 리누스 베네딕트 토발즈(Linus Benedict Torvals)가 처음 개발
- 미닉스(MINIX)라는 교육용 운영체제를 참조하여 개발
- 리눅스 개발 소식을 comp.os.minix 뉴스 그룹에 포스팅 : 1991년 8월 26일 -> 리눅스 탄생일

리눅스의 발전과정
- 최초 공개된 리눅스 커널 : 버전 0.01
- 현재 : 안정버전 3.11.2, 개발 버전 3.12
- GNU 프로젝트 : 리눅스 커널에 응용 프로그램 제공 -> GNU/리눅스
- 리눅스 재단 : 2007년 설립
     - 리누스 토발즈 지원
     - 삼성전자, IBM, 인텔, 오라클, 구글, 페이스북, 트위터 등
     - 2005년 이래 7,800명이 넘는 개인과 800여 개의 기업이 커널 개발에 공헌

리눅스의 특징
- 리눅스는 공개 소프트웨어이며 무료로 사용 가능
- 유닉스와의 완벽한 호환성을 유지
- 서버용 운영체제로 많이 사용된다

리눅스의 구조
- 커널 : 리눅스의 핵심
   - 프로세스/메모리/파일시스템/장치 관리
   - 컴퓨터의 모든 자원 초기화 및 제어 기능
- 쉘 : 사용자 인터페이스
   - 명령해석
   - 프로그래밍기능
   - 리눅스 기본 쉘 : 배시 쉘(리눅스 쉘)
- 응용 프로그램
   - 각종 프로그래밍 개발 도구
   - 문서편집도구
   - 네트워크 관련 도구

리눅스 파일의 종류와 특징

root 로그인

사용자
root
        사용자는 root 밑에 평등함
        master
디렉토리
컴퓨터
        루트(/)
                - bin : 실행파일
                - root : root 계정 로그인(root 홈디렉토리) (빌려)
                - home : 사용자ID -> 각 계정 홈디렉토리 (v)
                - usr : windows의 program files랑 같음(사용자 설치파일)
                - etc : 설정파일

 

master 로그인

명령어를 사용해 봅시다

현재 디렉터리 확인하기

[master@localhost ~]$ pwd
/home/master

디렉터리 내용보기

[master@localhost ~]$ ls
공개      문서      비디오  서식                               음악
다운로드  바탕화면  사진    스크린샷, 2018-08-13 20-21-52.png
[master@localhost ~]$ ls -a
.              .bashrc    .mozilla  사진
..             .cache     공개      서식
.ICEauthority  .config    다운로드  스크린샷, 2018-08-13 20-21-52.png
.bash_history  .dbus      문서      음악
.bash_logout   .esd_auth  바탕화면
.bash_profile  .local     비디오

[master@localhost ~]$ ls -f
.              .cache         바탕화면  사진
..             .dbus          다운로드  비디오
.mozilla       .config        서식      스크린샷, 2018-08-13 20-21-52.png
.bash_logout   .ICEauthority  공개      .bash_history
.bash_profile  .local         문서
.bashrc        .esd_auth      음악
[master@localhost ~]$ ls -aF
./             .bashrc    .mozilla/  사진/
../            .cache/    공개/      서식/
.ICEauthority  .config/   다운로드/  스크린샷, 2018-08-13 20-21-52.png
.bash_history  .dbus/     문서/      음악/
.bash_logout   .esd_auth  바탕화면/
.bash_profile  .local/    비디오/

[master@localhost ~]$ ls -f
.              .cache         바탕화면  사진
..             .dbus          다운로드  비디오
.mozilla       .config        서식      스크린샷, 2018-08-13 20-21-52.png
.bash_logout   .ICEauthority  공개      .bash_history
.bash_profile  .local         문서
.bashrc        .esd_auth      음악
[master@localhost ~]$ ls -aF
./             .bashrc    .mozilla/  사진/
../            .cache/    공개/      서식/
.ICEauthority  .config/   다운로드/  스크린샷, 2018-08-13 20-21-52.png
.bash_history  .dbus/     문서/      음악/
.bash_logout   .esd_auth  바탕화면/
.bash_profile  .local/    비디오/

[master@localhost ~]$ ls -l
합계 464
drwxr-xr-x. 2 master master      6  8월 13  2018 공개
drwxr-xr-x. 2 master master      6  8월 13  2018 다운로드
drwxr-xr-x. 2 master master      6  8월 13  2018 문서
drwxr-xr-x. 2 master master      6  8월 13  2018 바탕화면
drwxr-xr-x. 2 master master      6  8월 13  2018 비디오
drwxr-xr-x. 2 master master      6  8월 13  2018 사진
drwxr-xr-x. 2 master master      6  8월 13  2018 서식
-rw-rw-r--. 1 master master 473809  8월 13  2018 스크린샷, 2018-08-13 20-21-52.png
drwxr-xr-x. 2 master master      6  8월 13  2018 음악
[master@localhost ~]$ ls -al
합계 500
drwx------. 15 master master   4096  8월 13 12:02 .
drwxr-xr-x.  3 root   root       20  8월 13  2018 ..
-rw-------.  1 master master    934  8월 13 12:02 .ICEauthority
-rw-------.  1 master master      5  8월 13 11:26 .bash_history
-rw-r--r--.  1 master master     18  4월 11 09:53 .bash_logout
-rw-r--r--.  1 master master    193  4월 11 09:53 .bash_profile
-rw-r--r--.  1 master master    231  4월 11 09:53 .bashrc
drwx------. 16 master master   4096  8월 13 12:03 .cache
drwxr-xr-x. 16 master master   4096  8월 13 11:25 .config
drwx------.  3 master master     25  8월 13  2018 .dbus
-rw-------.  1 master master     16  8월 13  2018 .esd_auth
drwx------.  3 master master     19  8월 13  2018 .local
drwxr-xr-x.  5 master master     54  8월 13  2018 .mozilla
drwxr-xr-x.  2 master master      6  8월 13  2018 공개
drwxr-xr-x.  2 master master      6  8월 13  2018 다운로드
drwxr-xr-x.  2 master master      6  8월 13  2018 문서
drwxr-xr-x.  2 master master      6  8월 13  2018 바탕화면
drwxr-xr-x.  2 master master      6  8월 13  2018 비디오
drwxr-xr-x.  2 master master      6  8월 13  2018 사진
drwxr-xr-x.  2 master master      6  8월 13  2018 서식
-rw-rw-r--.  1 master master 473809  8월 13  2018 스크린샷, 2018-08-13 20-21-52.png
drwxr-xr-x.  2 master master      6  8월 13  2018 음악

한가지 파일 정보를 보고 싶을 때

[master@localhost ~]$ ls -l .esd_auth
-rw-------. 1 master master 16  8월 13  2018 .esd_auth

지정한 파일이 없을때

[master@localhost ~]$ ls -l .esd_auth.txt
ls: cannot access .esd_auth.txt: 그런 파일이나 디렉터리가 없습니다

디렉토리를 보고 싶을 때

[master@localhost ~]$ ls -l /usr
합계 276
dr-xr-xr-x.   2 root root 53248  8월 13  2018 bin
drwxr-xr-x.   2 root root     6  4월 11 13:59 etc
drwxr-xr-x.   2 root root     6  4월 11 13:59 games
drwxr-xr-x.  42 root root  8192  8월 13  2018 include
dr-xr-xr-x.  43 root root  4096  8월 13  2018 lib
dr-xr-xr-x. 149 root root 81920  8월 13  2018 lib64
drwxr-xr-x.  48 root root 12288  8월 13  2018 libexec
drwxr-xr-x.  12 root root   131  8월 13  2018 local
dr-xr-xr-x.   2 root root 20480  8월 13  2018 sbin
drwxr-xr-x. 245 root root  8192  8월 13  2018 share
drwxr-xr-x.   4 root root    34  8월 13  2018 src
lrwxrwxrwx.   1 root root    10  8월 13  2018 tmp -> ../var/tmp

권한이 없는 곳을 들어가려 할때

[master@localhost ~]$ ls -l /root
ls: cannot open directory /root: 허가 거부

윈도우의 dir 명령어도 존재하기는 하지만 ls를 더 많이 쓴다

[master@localhost ~]$ vdir
합계 464
drwxr-xr-x. 2 master master      6  8월 13  2018 공개
drwxr-xr-x. 2 master master      6  8월 13  2018 다운로드
drwxr-xr-x. 2 master master      6  8월 13  2018 문서
drwxr-xr-x. 2 master master      6  8월 13  2018 바탕화면
drwxr-xr-x. 2 master master      6  8월 13  2018 비디오
drwxr-xr-x. 2 master master      6  8월 13  2018 사진
drwxr-xr-x. 2 master master      6  8월 13  2018 서식
-rw-rw-r--. 1 master master 473809  8월 13  2018 스크린샷,\ 2018-08-13\ 20-21-52.png
drwxr-xr-x. 2 master master      6  8월 13  2018 음악

그리하여 자동완성 기능을 사용하면

[master@localhost ~]$ ls -l /usr/l
lib/     lib64/   libexec/ local/   
[master@localhost ~]$ ls -l /usr/local/
합계 0
drwxr-xr-x. 2 root root  6  4월 11 13:59 bin
drwxr-xr-x. 2 root root  6  4월 11 13:59 etc
drwxr-xr-x. 2 root root  6  4월 11 13:59 games
drwxr-xr-x. 2 root root  6  4월 11 13:59 include
drwxr-xr-x. 2 root root  6  4월 11 13:59 lib
drwxr-xr-x. 2 root root  6  4월 11 13:59 lib64
drwxr-xr-x. 2 root root  6  4월 11 13:59 libexec
drwxr-xr-x. 2 root root  6  4월 11 13:59 sbin
drwxr-xr-x. 5 root root 49  8월 13  2018 share
drwxr-xr-x. 2 root root  6  4월 11 13:59 src

디렉터리 이동하기

[master@localhost ~]$ pwd
/home/master
[master@localhost ~]$ cd /tmp/
[master@localhost tmp]$ pwd
/tmp
cd      - 절대디렉토리
                /
        - 상대디렉토리
                현재위치(pwd)
                . 현재
                .. 상위
        - 특수기호
                cd -
                cd / cd ~ / cd ~사용자아이디

절대 경로법

[master@localhost tmp]$ cd /usr/bin/
[master@localhost bin]$ pwd
/usr/bin
[master@localhost bin]$ cd /tmp/
[master@localhost tmp]$ pwd
/tmp

상대 경로법

[master@localhost bin]$ cd /tmp/
[master@localhost tmp]$ pwd
/tmp
[master@localhost tmp]$ cd ../usr/bin/
[master@localhost bin]$ pwd
/usr/bin
[master@localhost bin]$ cd ../../tmp/
[master@localhost tmp]$ pwd
/tmp

디렉터리/파일명

절대 경로

상대 경로

/

cd /

cd ../

home

cd /home

cd ../home

tmp

cd /tmp

cd ../tmp

lib

cd /usr/lib

cd ../usr/lib

ls

cd /usr/bin/ls

cd ../usr/bin/ls

[master@localhost ~]$ cd /usr/bin/
[master@localhost bin]$ pwd
/usr/bin
[master@localhost bin]$ cd ~
[master@localhost ~]$ pwd
/home/master

디렉터리 만들기

[master@localhost ~]$ mkdir tempt 
[master@localhost ~]$ ls 
tempt  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png 
공개   문서      비디오    서식  음악

[master@localhost ~]$ mkdir tmp1 tmp2 tmp3
[master@localhost ~]$ ls
tempt  tmp3      문서      사진                               음악
tmp1   공개      바탕화면  서식
tmp2   다운로드  비디오    스크린샷, 2018-08-13 20-21-52.png

[master@localhost ~]$ mkdir temp/mid/han
mkdir: `temp/mid/han' 디렉토리를 만들 수 없습니다: 그런 파일이나 디렉터리가 없습니다
[master@localhost ~]$ mkdir -p temp/mid/han
[master@localhost ~]$ ls
temp   tmp1  tmp3  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png
tempt  tmp2  공개  문서      비디오    서식  음악
[master@localhost ~]$ ls temp/
mid
[master@localhost ~]$ ls temp/mid/
han
[master@localhost ~]$ ls -R temp/
temp/:
mid

temp/mid:
han

디렉터리 삭제하기

[master@localhost ~]$ rmdir tmp1
[master@localhost ~]$ ls
temp   tmp3      문서      사진                               음악
tempt  공개      바탕화면  서식
tmp2   다운로드  비디오    스크린샷, 2018-08-13 20-21-52.png
[master@localhost ~]$ rmdir tmp2 tmp3
[master@localhost ~]$ ls
temp   공개      문서      비디오  서식                               음악
tempt  다운로드  바탕화면  사진    스크린샷, 2018-08-13 20-21-52.png
[master@localhost ~]$ rmdir tmp
rmdir: failed to remove `tmp': 그런 파일이나 디렉터리가 없습니다
[master@localhost ~]$ rmdir -p temp/mid/han/
[master@localhost ~]$ ls
tempt  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png
공개   문서      비디오    서식  음악

[master@localhost ~]$ cd
[master@localhost ~]$ pwd
/home/master
[master@localhost ~]$ mkdir ch2
[master@localhost ~]$ ls
ch2    공개      문서      비디오  서식                               음악
tempt  다운로드  바탕화면  사진    스크린샷, 2018-08-13 20-21-52.png
[master@localhost ~]$ cd /ch2
bash: cd: /ch2: 그런 파일이나 디렉터리가 없습니다
[master@localhost ~]$ pwd
/home/master
[master@localhost ~]$ ls
ch2    공개      문서      비디오  서식                               음악
tempt  다운로드  바탕화면  사진    스크린샷, 2018-08-13 20-21-52.png
[master@localhost ~]$ cd /home/master/ch2/
[master@localhost ch2]$ pwd
/home/master/ch2
[master@localhost ch2]$ mkdir one two three
[master@localhost ch2]$ ls
one  three  two
[master@localhost ch2]$ cd ../ch2/one/
[master@localhost one]$ mkdir tmp/test
mkdir: `tmp/test' 디렉토리를 만들 수 없습니다: 그런 파일이나 디렉터리가 없습니다
[master@localhost one]$ mkdir -p tmp/test
[master@localhost one]$ ls
tmp
[master@localhost one]$ rmdir two three
rmdir: failed to remove `two': 그런 파일이나 디렉터리가 없습니다
rmdir: failed to remove `three': 그런 파일이나 디렉터리가 없습니다
[master@localhost one]$ cd ../
one/   three/ two/   
[master@localhost one]$ cd ../../ch2/
[master@localhost ch2]$ pwd
/home/master/ch2
[master@localhost ch2]$ rmdir two three
[master@localhost ch2]$ ls
one
[master@localhost ch2]$ cd
[master@localhost ~]$ pwd
/home/master

파일 다루기

파알 내용 연속 출력하기

[master@localhost ~]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[master@localhost ~]$ cat -n /etc/hosts
     1	127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
     2	::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

화면 단위로 파일 내용 출력하기

파일 뒷부분 출력하기

[master@localhost ~]$ tail /etc/services 
3gpp-cbsp       48049/tcp               # 3GPP Cell Broadcast Service Protocol
isnetserv       48128/tcp               # Image Systems Network Services
isnetserv       48128/udp               # Image Systems Network Services
blp5            48129/tcp               # Bloomberg locator
blp5            48129/udp               # Bloomberg locator
com-bardac-dw   48556/tcp               # com-bardac-dw
com-bardac-dw   48556/udp               # com-bardac-dw
iqobject        48619/tcp               # iqobject
iqobject        48619/udp               # iqobject
matahari        49000/tcp               # Matahari Broker
[master@localhost ~]$ tail -5 /etc/services 
com-bardac-dw   48556/tcp               # com-bardac-dw
com-bardac-dw   48556/udp               # com-bardac-dw
iqobject        48619/tcp               # iqobject
iqobject        48619/udp               # iqobject
matahari        49000/tcp               # Matahari Broker

파일 앞부분 출력하기

[master@localhost ~]$ head /etc/services 
# /etc/services:
# $Id: services,v 1.55 2013/04/14 ovasik Exp $
#
# Network services, Internet style
# IANA services version: last updated 2013-04-10
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports
[master@localhost ~]$ head -5 /etc/services 
# /etc/services:
# $Id: services,v 1.55 2013/04/14 ovasik Exp $
#
# Network services, Internet style
# IANA services version: last updated 2013-04-10

0 byte 짜리 파일을 만들고 싶을 때

[master@localhost ~]$ touch test.txt
[master@localhost ~]$ ls
ch2    test.txt  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png
tempt  공개      문서      비디오    서식  음악
[master@localhost ~]$ touch test1 test2 test3 test4
[master@localhost ~]$ ls
ch2       test1  test4     문서      사진                               음악
tempt     test2  공개      바탕화면  서식
test.txt  test3  다운로드  비디오    스크린샷, 2018-08-13 20-21-52.png

파일(디렉터리) 복사하기

[master@localhost ~]$ mkdir sub1
[master@localhost ~]$ cp test1 sub1/
[master@localhost ~]$ ls sub1/
test1
[master@localhost ~]$ cp test2 test3 test4 sub1/
[master@localhost ~]$ ls sub1/
test1  test2  test3  test4
[master@localhost ~]$ mkdir sub2
[master@localhost ~]$ cp t* sub2/
cp: omitting directory `tempt'
[master@localhost ~]$ ls sub2/
test.txt  test1  test2  test3  test4

파일 삭제하기

[master@localhost ~]$ rm test.txt
[master@localhost ~]$ ls
ch2   tempt  test3  다운로드  비디오  스크린샷, 2018-08-13 20-21-52.png
sub1  test1  test4  문서      사진    음악
sub2  test2  공개   바탕화면  서식
[master@localhost ~]$ rm test1 test2
[master@localhost ~]$ ls
ch2   tempt  공개      바탕화면  서식
sub1  test3  다운로드  비디오    스크린샷, 2018-08-13 20-21-52.png
sub2  test4  문서      사진      음악

[master@localhost ~]$ rm -i test3 
rm: remove 일반 빈 파일 `test3'? no
[master@localhost ~]$ rm t*
rm: cannot remove `tempt': 디렉터리입니다
[master@localhost ~]$ ls
ch2   tempt     문서      사진                               음악
sub1  공개      바탕화면  서식
sub2  다운로드  비디오    스크린샷, 2018-08-13 20-21-52.png
[master@localhost ~]$ rm -r sub1/
[master@localhost ~]$ ls
ch2   tempt  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png
sub2  공개   문서      비디오    서식  음악
[master@localhost ~]$ rmdir sub2/
rmdir: failed to remove `sub2/': 디렉터리가 비어있지 않음
[master@localhost ~]$ rm -r sub2/
[master@localhost ~]$ ls
ch2    공개      문서      비디오  서식                               음악
tempt  다운로드  바탕화면  사진    스크린샷, 2018-08-13 20-21-52.png

rmdir은 내용이 있으면 못지우는데 rm은 지울 수 있다.

파일 이동 및 파일명 변경

파일명 변경

[master@localhost ~]$ touch test1
[master@localhost ~]$ ls
ch2    test1  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png
tempt  공개   문서      비디오    서식  음악
[master@localhost ~]$ ls -f
.              .dbus          서식                               .bash_history
..             .config        공개                               tempt
.mozilla       .ICEauthority  문서                               ch2
.bash_logout   .local         음악                               test1
.bash_profile  .esd_auth      사진
.bashrc        바탕화면       비디오
.cache         다운로드       스크린샷, 2018-08-13 20-21-52.png
[master@localhost ~]$ ls -F
ch2/    test1  다운로드/  바탕화면/  사진/  스크린샷, 2018-08-13 20-21-52.png
tempt/  공개/  문서/      비디오/    서식/  음악/
[master@localhost ~]$ ls -l
합계 464
drwxrwxr-x. 3 master master     17  8월 13 12:59 ch2
drwxrwxr-x. 2 master master      6  8월 13 12:50 tempt
-rw-rw-r--. 1 master master      0  8월 13 14:40 test1
drwxr-xr-x. 2 master master      6  8월 13  2018 공개
drwxr-xr-x. 2 master master      6  8월 13  2018 다운로드
drwxr-xr-x. 2 master master      6  8월 13  2018 문서
drwxr-xr-x. 2 master master      6  8월 13  2018 바탕화면
drwxr-xr-x. 2 master master      6  8월 13  2018 비디오
drwxr-xr-x. 2 master master      6  8월 13  2018 사진
drwxr-xr-x. 2 master master      6  8월 13  2018 서식
-rw-rw-r--. 1 master master 473809  8월 13  2018 스크린샷, 2018-08-13 20-21-52.png
drwxr-xr-x. 2 master master      6  8월 13  2018 음악
[master@localhost ~]$ mv test1 test2
[master@localhost ~]$ ls
ch2    test2  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png
tempt  공개   문서      비디오    서식  음악
[master@localhost ~]$ mv ./test2 ./test3
[master@localhost ~]$ ls
ch2    test3  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png
tempt  공개   문서      비디오    서식  음악

파일 이동

[master@localhost ~]$ mv test3 sub1/
[master@localhost ~]$ ls
ch2   tempt  다운로드  바탕화면  사진  스크린샷, 2018-08-13 20-21-52.png
sub1  공개   문서      비디오    서식  음악
[master@localhost ~]$ ls sub1/
test3

파일을 다른 디렉터리로 이동하기

[master@localhost ~]$ mv --help
Usage: mv [OPTION]... [-T] SOURCE DEST
  or:  mv [OPTION]... SOURCE... DIRECTORY
  or:  mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
  -f, --force                  do not prompt before overwriting
  -i, --interactive            prompt before overwrite
  -n, --no-clobber             do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 move only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -Z, --context                set SELinux security context of destination
                                 file to default type
      --help     이 도움말을 표시하고 끝냅니다
      --version  버전 정보를 출력하고 끝냅니다

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       never make backups (even if --backup is given)
  numbered, t     make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report mv translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'mv invocation'
[master@localhost ~]$ mv --help |more
Usage: mv [OPTION]... [-T] SOURCE DEST
  or:  mv [OPTION]... SOURCE... DIRECTORY
  or:  mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
  -f, --force                  do not prompt before overwriting
  -i, --interactive            prompt before overwrite
  -n, --no-clobber             do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 move only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -Z, --context                set SELinux security context of destination
                                 file to default type
      --help     이 도움말을 표시하고 끝냅니다
      --version  버전 정보를 출력하고 끝냅니다

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       never make backups (even if --backup is given)
  numbered, t     make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report mv translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'mv invocation'
[master@localhost ~]$ man ls

[master@localhost ~]$ whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
[master@localhost ~]$ ls -l /usr/bin/ls
-rwxr-xr-x. 1 root root 117672  4월 11 13:35 /usr/bin/ls
[master@localhost ~]$ whereis mv
mv: /usr/bin/mv /usr/share/man/man1/mv.1.gz /usr/share/man/man1p/mv.1p.gz

파일 찾기 : find

[master@localhost ~]$ find /usr/ -name ls
/usr/bin/ls
find: ‘/usr/share/polkit-1/rules.d’: 허가 거부
find: ‘/usr/libexec/initscripts/legacy-actions/auditd’: 허가 거부
[master@localhost ~]$ find /home/ -user master
/home/master
/home/master/.mozilla
/home/master/.mozilla/extensions
/home/master/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
/home/master/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/langpack-ko@firefox.mozilla.org.xpi
/home/master/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/.fedora-langpack-install
/home/master/.mozilla/plugins
/home/master/.mozilla/firefox
/home/master/.mozilla/firefox/ioccwrni.default
/home/master/.mozilla/firefox/ioccwrni.default/times.j

파일 링크

파일링크
        바로가기
                하드 링크(X)
                심벌릭 링크(바로가기)

[master@localhost ~]$ pwd
/home/master
[master@localhost ~]$ cp /etc/hosts ./
[master@localhost ~]$ ls
ch2    tempt     문서      사진                               음악
hosts  공개      바탕화면  서식
sub1   다운로드  비디오    스크린샷, 2018-08-13 20-21-52.png
[master@localhost ~]$ cat ./hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[master@localhost ~]$ ln -s hosts hosts2
[master@localhost ~]$ ls
ch2     sub1   다운로드  비디오  스크린샷, 2018-08-13 20-21-52.png
hosts   tempt  문서      사진    음악
hosts2  공개   바탕화면  서식
[master@localhost ~]$ ls -l
합계 468
drwxrwxr-x. 3 master master     17  8월 13 12:59 ch2
-rw-r--r--. 1 master master    158  8월 13 15:00 hosts
lrwxrwxrwx. 1 master master      5  8월 13 15:01 hosts2 -> hosts
drwxrwxr-x. 2 master master     19  8월 13 14:44 sub1
drwxrwxr-x. 2 master master      6  8월 13 12:50 tempt
drwxr-xr-x. 2 master master      6  8월 13  2018 공개
drwxr-xr-x. 2 master master      6  8월 13  2018 다운로드
drwxr-xr-x. 2 master master      6  8월 13  2018 문서
drwxr-xr-x. 2 master master      6  8월 13  2018 바탕화면
drwxr-xr-x. 2 master master      6  8월 13  2018 비디오
drwxr-xr-x. 2 master master      6  8월 13  2018 사진
drwxr-xr-x. 2 master master      6  8월 13  2018 서식
-rw-rw-r--. 1 master master 473809  8월 13  2018 스크린샷, 2018-08-13 20-21-52.png
drwxr-xr-x. 2 master master      6  8월 13  2018 음악
[master@localhost ~]$ cat hosts2
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[master@localhost ~]$ cat hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[master@localhost ~]$ rm hosts
[master@localhost ~]$ ls -l
합계 464
drwxrwxr-x. 3 master master     17  8월 13 12:59 ch2
lrwxrwxrwx. 1 master master      5  8월 13 15:01 hosts2 -> hosts
drwxrwxr-x. 2 master master     19  8월 13 14:44 sub1
drwxrwxr-x. 2 master master      6  8월 13 12:50 tempt
drwxr-xr-x. 2 master master      6  8월 13  2018 공개
drwxr-xr-x. 2 master master      6  8월 13  2018 다운로드
drwxr-xr-x. 2 master master      6  8월 13  2018 문서
drwxr-xr-x. 2 master master      6  8월 13  2018 바탕화면
drwxr-xr-x. 2 master master      6  8월 13  2018 비디오
drwxr-xr-x. 2 master master      6  8월 13  2018 사진
drwxr-xr-x. 2 master master      6  8월 13  2018 서식
-rw-rw-r--. 1 master master 473809  8월 13  2018 스크린샷, 2018-08-13 20-21-52.png
drwxr-xr-x. 2 master master      6  8월 13  2018 음악

[master@localhost ~]$ cat hosts2
cat: hosts2: 그런 파일이나 디렉터리가 없습니다
[master@localhost ~]$ cp /etc/hosts ./
[master@localhost ~]$ ls -l
합계 468
drwxrwxr-x. 3 master master     17  8월 13 12:59 ch2
-rw-r--r--. 1 master master    158  8월 13 15:03 hosts
lrwxrwxrwx. 1 master master      5  8월 13 15:01 hosts2 -> hosts
drwxrwxr-x. 2 master master     19  8월 13 14:44 sub1
drwxrwxr-x. 2 master master      6  8월 13 12:50 tempt
drwxr-xr-x. 2 master master      6  8월 13  2018 공개
drwxr-xr-x. 2 master master      6  8월 13  2018 다운로드
drwxr-xr-x. 2 master master      6  8월 13  2018 문서
drwxr-xr-x. 2 master master      6  8월 13  2018 바탕화면
drwxr-xr-x. 2 master master      6  8월 13  2018 비디오
drwxr-xr-x. 2 master master      6  8월 13  2018 사진
drwxr-xr-x. 2 master master      6  8월 13  2018 서식
-rw-rw-r--. 1 master master 473809  8월 13  2018 스크린샷, 2018-08-13 20-21-52.png
drwxr-xr-x. 2 master master      6  8월 13  2018 음악

[master@localhost ~]$ java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
[master@localhost ~]$ whereis java
java: /usr/bin/java /usr/lib/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz
[master@localhost ~]$ ls /usr/bin/java
/usr/bin/java
[master@localhost ~]$ ls -l /usr/bin/java
lrwxrwxrwx. 1 root root 22  8월 13  2018 /usr/bin/java -> /etc/alternatives/java
[master@localhost ~]$ ls -l /etc/alternatives/java
lrwxrwxrwx. 1 root root 71  8월 13  2018 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java
[master@localhost ~]$ ls -l /usr/lib/jvm/java-1.
java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64/
java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/
[master@localhost ~]$ ls -l /usr/lib/jvm/java-1.
java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64/
java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/
[master@localhost ~]$ ls -l /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java 
-rwxr-xr-x. 1 root root 7304  4월 11 15:16 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java

실제 java 경로는 마지막 위치이다
버전업을 대비해서 위와 같이 심벌릭 링크를 사용해서 실제경로의 내용이 바뀌어도 링크명은 동일하게 하여 연속성을 주기 위해서이다

[master@localhost ~]$ ls -l /usr/lib/jvm 
합계 0 
drwxr-xr-x. 4 root root 100  8월 13  2018 java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64 
drwxr-xr-x. 3 root root  17  4월 11 15:12 java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64 
lrwxrwxrwx. 1 root root  21  8월 13  2018 jre -> /etc/alternatives/jre 
lrwxrwxrwx. 1 root root  27  8월 13  2018 jre-1.7.0 -> /etc/alternatives/jre_1.7.0 
lrwxrwxrwx. 1 root root  35  8월 13  2018 jre-1.7.0-openjdk -> /etc/alternatives/jre_1.7.0_openjdk 
lrwxrwxrwx. 1 root root  52  8월 13  2018 jre-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64 -> java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64/jre 
lrwxrwxrwx. 1 root root  27  8월 13  2018 jre-1.8.0 -> /etc/alternatives/jre_1.8.0 
lrwxrwxrwx. 1 root root  35  8월 13  2018 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk 
lrwxrwxrwx. 1 root root  49  8월 13  2018 jre-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64 -> java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre 
lrwxrwxrwx. 1 root root  29  8월 13  2018 jre-openjdk -> /etc/alternatives/jre_openjdk

리눅스의 문서 편집기

vi
        명령

                특수 : ex 모드

        <- esc키>
        -> 입력키

        입력

저장하지 않고 종료

[master@localhost ~]$ vi test.txt

내용 삭제하기

리눅스에서 자바 써보기

[root@localhost ~]# yum install java-1.8.0-openjdk-devel
[master@localhost ~]$ vi java
[master@localhost ~]$ vi HelloWorld.java
[master@localhost ~]$ cat HelloWorld.java
public class HelloWorld {
	public static void main (String[] args) {
		System.out.println("Hello World");
		}
	}

[master@localhost ~]$ javac HelloWorld.java
[master@localhost ~]$ java HelloWorld
Hello World
반응형

댓글