2. 26 (월) 정리 - Linux 기본 명령어 3 / Network ip주소

---------------------------------------------------------------------------------------------------
Linux

- cp : 파일이나 디렉토리를 복사
#cp [옵션] 원본 복사대상명
옵션
"-arpf 묶어서 사용"
-a : 원본 속성 유지
-r : 하위 디렉토리/파일 모두 복사
-p : 파일의 소유와 권한을 보존한 채 복사
-f : 강제 실행
-u : 새 파일 덮어쓰기 금지

[root@su1-localhost test]# echo abc > abc.txt
[root@su1-localhost test]#
[root@su1-localhost test]# cp -arpf abc.txt copyabc.txt
[root@su1-localhost test]# ls
abc.txt  copyabc.txt
[root@su1-localhost test]# cat copyabc.txt
abc

- mv : 파일이나 디렉토리를 이동
#mv [옵션] 원본 이동파일명
옵션
-f : 강제 실행
-b : 파일이 덮어씌워질 경우 백업파일을 생성
-d : 디렉토리 삭제
-i : 삭제 전 일일이 삭제여부 확인
-v : 삭제 파일 만들기
++ 파일의 이름을 바꿀때도 사용

[root@su1-localhost test]# mkdir testintest
[root@su1-localhost test]# ls
abc.txt  copyabc.txt  testintest
[root@su1-localhost test]# mv abc.txt ./testintest/
[root@su1-localhost test]# ls
copyabc.txt  testintest
[root@su1-localhost test]# ls ./testintest/
abc.txt
[root@su1-localhost test]# mv copyabc.txt copy.txt
[root@su1-localhost test]# ls
copy.txt  testintest

- rm : 파일이나 디렉토리를 삭제
++ rmdir을 쓰지 않는 이유 : 디렉토리가 비어있어야만 사용가능
#rm [옵션] 대상파일
옵션
-r : 대상 중 디렉토리가 있는 경우 디렉토리도 삭제
-f : 강제 실행
 → 거의 항상 두 옵션을 전부 사용

[root@su1-localhost test]# rm -rf testintest
[root@su1-localhost test]# ls
copy.txt
[root@su1-localhost test]# rm -rf copy.txt
[root@su1-localhost test]# ls
[root@su1-localhost test]#

- ln : Link 파일 생성 (soft, hard)
soft link - 원본파일을 가리키는 파일을 만듦
hard link - 원본 파일과 동등한 level의 파일을 만듦
++ 모든 데이터는 쓰레기통 뒤지기 기법에 노출될 위험이 있다 (지운데이터 복구)
# ln [옵션] 원본파일 링크파일
옵션
-s : soft link 생성 (디렉토리의 경우 soft link만 가능) - 디폴트의 경우 하드링크
++ 하드링크의 경우 같은 파일을 가리키므로 inode값이 같음.
ex> 하드링크 - 같은사람 복제 / 소프트링크 - 가명
-f : 대상이 존재하는 경우 지우고 link 파일 생성

[root@su1-localhost ~]# ln -s test testln
[root@su1-localhost ~]# ls -li
합계 76
1014940 -rw-r--r-- 1  root root        4  3월 16 10:00 135
1014934 -rw------- 1  root root   2714  3월 15 12:53 anaconda-ks.cfg
1014825 drwxr-xr-x 7 root root   4096  3월 16 09:47 bin
1014835 drwxr-xr-x 2 root root   4096  3월 15 12:48 conf
1014818 -rw-r--r-- 1  root root  21235  3월 15 12:53 install.log
1014819 -rw-r--r-- 1  root root        0  3월 15 12:35 install.log.syslog
1014941 drwxr-xr-x 3 root root   4096  3월 16 10:26 test
1014937 -rw-r--r-- 1  root root        6  3월 16 09:52 test1.txt
1014938 -rw-r--r-- 1  root root     965  3월 16 09:52 test2.txt
1014939 -rw-r--r-- 1  root root        6  3월 16 09:54 test3.txt
1014944 lrwxrwxrwx 1 root root       4  3월 16 10:29 testln -> test
[root@su1-localhost ~]# cd testln
[root@su1-localhost testln]# ls
testin
[root@su1-localhost testln]# cd /root/test
[root@su1-localhost test]# ls
testin
[root@su1-localhost test]#

++) # passwd  : 계정의 패스워드를 바꾸는 명령어



---------------------------------------------------------------------------------------------------
네트워크

# IP 구조
고정 넷마스크의 구조
ex> 1.1.1.0 ~ 1.1.1.255 까지의 네트워크
위의 네트워크를 하나의 네트워크로 사용하고 싶을때의 고정 넷마스크는
255.255.255.0 이다.
(이 중 1.1.1.0 과 1.1.1.255는 사용할 수 없기 때문에 사용가능한 host는 254개이다.)
1.1.1.0 에서 앞의 3칸은 네트워크를 구분하는 주소로 Prefix라고 한다.
표기는 다음과 같다 -> 1.1.1.0/24 (/24 는 비트의 개수, 3칸이므로 8+8+8 = 24)

* 한 네트워크에서 라우터를 두고 네트워크를 분할하고 싶은 경우
게이트웨이의 넷마스크를 그대로 사용한다면, 게이트웨이 외부와는 통신 가능하나,
내부와 통신이 불가능.
→ 네트워크를 나누어 주어야 함.
방법)
11111111 11111111 11111111 00000000 의 넷마스크에서
25번째 비트를 1로 바꾸어준다.
-> 11111111 11111111 11111111 10000000 가 된다.
이는 25비트까지 네트워크 주소를 의미한다는 뜻이 되므로 호스트 주소는 7비트가 된다.

- 호스트 주소

       0000000  → 0
   ↗
0
   ↘
       1111111  → 127

       0000000  → 128
   ↗
1
   ↘
       1111111  → 255

위와 같이 두 개의 네트워크로 쪼개질 수 있다.


//////////////////////////////////////////////////////////////////////////////////////////
1.1.1.0 ~ 1.1.1.127/25          와           1.1.1.128 ~ 1.1.1.255/25 로 나뉜다.
실사용주소는 ↓
1.1.1.1 ~ 1.1.1.126/25          와           1.1.1.129 ~ 1.1.1.254/25
//////////////////////////////////////////////////////////////////////////////////////////


IP 주소                   1. 1. 1. 1                    1. 1. 1. 129
넷마스크             255.255.255.128              255.255.255.128

   1  ->  00000001                129  ->  10000001
128  ->  10000000                128  ->  10000000
----------------------------------------------------------------------------------------
            00000000                            10000000


댓글

이 블로그의 인기 게시물

Linux Server - FTP 실습 (2 / 2) : 사용자 제한 ( ftpuser / user_list )

전자서명 개념

3.27 (화) - Network (패킷 통신 - 4가지 지연)