o 기본 명령어 

파일목록 출력  (LiSt)                     (dir)

화면 지우기     (clear, Crtl + L )       (cls)

디렉토리 생성 (MaKe DIRectory)      (md, mkdir)

디렉토리 이동 (Change Directory)    (cd)

작업디렉토리출력 (Print Working Directory)

디렉토리 삭제 (ReMove DIRectory)   (rd, rmdir)

파일 생성 (touch, echo, install, cp),   (copy con, echo)

파일 삭제 (ReMove)                      (del)

파일 복사 (CoPy)                          (copy)    

파일 이동 (MoVe)                         (move)

파일 이름변경 (MoVe)                   (ren)

파일 바로가기 (LiNk) 

파일 내용보기 (cat, tac, head, tail, less, more, view, vi, nano, pico ...)

 - 파일 내용 전체 보기 cat

 - 파일 내용 거꾸로 보기 tac

 - 파일 내용 위에서 10줄 head 

 - 파일 내용 밑에서 10줄 tail or 


===================================================================

LAB> 윈도우 기본 명령어를 사용해보자.

윈도우키 + R -> cmd  

C:\Users\user1> cd \     <-- 최상위 디렉토리로 이동해라.

c:\> dir                         <-- 현재 디렉토리의 파일리스트를 출력해라

c:\> cls                         <-- 화면지워라

c:\> md Test                  <-- Test 디렉토리를 생성해라

c:\> cd Test                   <-- Test 디렉토리로 이동해라

c:\> echo 1234               <-- 1234 를 화면에 출력해라.

c:\> echo 1234 >  1.txt     <-- 1.txt 파일안에 1234 를 넣어라   ( > )

c:\> echo 5678 >> 1.txt    <-- 1.txt 파일안에 5678 을 추가해라 ( >> )

c:\> echo 3456 >  1.txt     <-- 1.txt 파일안에 3456 을 넣어라   ( > )

c:\> more 1.txt               <-- 1.txt 파일의 내용을 출력해라

c:\> dir                         <-- 현재 디렉토리의 파일리스트를 출력해라

c:\> del 1.txt                  <-- 1.txt 파일을 삭제해라

c:\> cd ..                       <-- 상위 디렉토리로 이동해라

c:\> rd Test                   <-- Test 디렉토리를 삭제해라

c:\> cd \                      <-- 최상위 디렉토리로 이동해라

c:\> mkdir Test2             <-- Test2 디렉토리를 생성해라

c:\> cd Test2                 <-- Test2 디렉토리로 이동해라

c:\> copy c:\windows\system32\calc.exe .  <-- calc.exe 를 복사해라

c:\> ren calc.exe calc2.exe    <-- calc.exe calc2.exe 로 이름을 변경해라

c:\> mkdir Test3                <-- Test3 디렉토리를 생성해라

c:\> move calc2.exe Test3    <-- calc2.exe 를 Test3 디렉토리로 이동해라

c:\> dir Test3                    <-- Test3 디렉토리를 출력해라

c:\> copy con 2.txt             <-- 0byte 짜리 파일 2.txt를 생성해라

^Z 엔터                            <-- Ctrl + Z 누르고 엔터를 친다

===================================================================



===================================================================

LAB> 리눅스 기본 명령어를 사용해보자.


파일목록 출력 (LiSt)

# ls 

디렉토리 생성 (MaKe DIRectory)

# mkdir TEST

디렉토리 이동 (Change Directory)

# cd TEST

작업디렉토리출력 (Print Working Directory)

# pwd

상위 디렉토리로 이동 

# cd ..

디렉토리 삭제 (ReMove DIRectory)

# rmdir TEST

파일 생성

# touch a.txt

ls 옵션을 이용해서 출력

# ls -l

파일 삭제 (ReMove)

# rm a.txt

파일 복사 (CoPy)

# cp install.log install.log2

파일 이동 (MoVe)

# mkdir 7.7

# mv install.log 7.7

# ls 7.7

파일 이름변경 (MoVe)

# cd 7.7

# ls 

install.log

# mv install.log a.txt

# ls

a.txt

===================================================================



===================================================================

LAB> 기본 명령어 연습


# ls

1.txt  7.7  anaconda-ks.cfg  install.log2  install.log.syslog

# mkdir Test   <-- Test 디렉토리를 생성한다

# dir   <-- Linux 에서도 윈도우 사용자를 위해 dir 명령어가 존재한다

1.txt  7.7  anaconda-ks.cfg  install.log2  install.log.syslog  Test

# ls    <-- 현재 디렉토리의 파일 리스트를 출력한다 (ls . 과 동일)

1.txt  7.7  anaconda-ks.cfg  install.log2  install.log.syslog  Test

# cd Test  <-- Test 디렉토리로 이동한다.

# pwd      <-- 현재 디렉토리의 경로를 출력한다

/root/Test

# echo 1234 > 1.txt   <-- 1234 의 내용을 가진 1.txt 파일을 생성한다

# ls          <-- /root/Test 디렉토리에 1.txt 파일이 생성되었다

1.txt

# cat 1.txt   <-- 1.txt 파일의 내용을 출력한다

1234

# more  1.txt <-- 1.txt 파일의 내용을 출력한다

1234


- 0byte 크기의 파일을 생성하는 여러가지 방법

# touch 2.txt  

# install /dev/null 3.txt

# cp /dev/null 4.txt

# ls -l      <-- 파일의 리스트를 자세히(-l 옵션) 보여준다

total 20

-rw-r--r-- 1 root root 5 Jul  7 18:53 1.txt

-rw-r--r-- 1 root root 0 Jul  7 19:09 2.txt

-rwxr-xr-x 1 root root 0 Jul  7 19:11 3.txt

-rw-r--r-- 1 root root 0 Jul  7 19:11 4.txt


# mkdir 5.txt    <-- 5.txt 디렉토리를 생성한다

# ls -l

total 28

-rw-r--r-- 1 root root    5 Jul  7 18:53 1.txt

-rw-r--r-- 1 root root    0 Jul  7 19:09 2.txt

-rwxr-xr-x 1 root root    0 Jul  7 19:11 3.txt

-rw-r--r-- 1 root root    0 Jul  7 19:11 4.txt

drwxr-xr-x 2 root root 4096 Jul  7 19:19 5.txt  <-- d 를 주목!!!

~


- cp 의 인자는 2개이면 첫번째 인자를 두 번째 인자로 복사하지만

3개 이상의 인자가 오면 마지막 인자는 디렉토리가 와야한다.

# cp 1.txt 2.txt 3.txt 4.txt 6.txt  <-- 6.txt 디렉토리가 없으므로 에러

cp: target `6.txt' is not a directory

# ls

1.txt  2.txt  3.txt  4.txt  5.txt  <-- 5.txt 디렉토리가 있으므로 복사

# cp 1.txt 2.txt 3.txt 4.txt 5.txt

# ls 5.txt

1.txt  2.txt  3.txt  4.txt

# rm -f 5.txt/1.txt  <-- 5.txt 디렉토리의 1.txt 파일을 강제(-f 옵션)로 삭제한다.

# rm -f 5.txt/2.txt  <-- 5.txt 디렉토리의 2.txt 파일을 강제(-f 옵션)로 삭제한다.

# rm -f 5.txt/3.txt  <-- 5.txt 디렉토리의 3.txt 파일을 강제(-f 옵션)로 삭제한다.

# rm -fv 5.txt/4.txt <-- 5.txt 디렉토리의 4.txt 파일을 강제(-f 옵션)로 삭제하면서

# 화면에 삭제된 것을 출력(-v 옵션)한다.

removed `5.txt/4.txt'


- mv 를 이용해서 파일의 이름을 변경하고 파일을 이동해보자.

- 조건은 아래 두 가지가 존재한다.

- 1. 파일명을 그대로 옮길 것인가 ? 

- 2. 파일명을 이름을 변경하고 옮길 것인가 ?

# ls

1.txt  2.txt  3.txt  4.txt  5.txt

# mv 5.txt 6.txt

# ls -F

1.txt  2.txt  3.txt*  4.txt  6.txt/


# mv 1.txt 6.txt

# ls

2.txt  3.txt  4.txt  6.txt

# ls 6.txt/

1.txt

# mv 2.txt 6.txt/22.txt

# ls 6.txt/

1.txt  22.txt

# mv 3.txt 6.txt/33.txt

# ls 6.txt/

1.txt  22.txt  33.txt


- 현재 디렉토리에 33.txt 파일을 3.txt 로 변경한다.

- 아래 1~3의 명령어들은 모두 동일한 결과를 가져온다.

- 1. mv 6.txt/33.txt ./3.txt 

- 2. mv 6.txt/33.txt /root/Test/3.txt

- 3. mv 6.txt/33.txt  3.txt  

# mv 6.txt/33.txt  3.txt  

# ls

1.txt  22.txt  3.txt  4.txt  6.txt

               ~~~~~

# ls 6.txt/  <-- 파일이 다 옮겨졌으므로 아무 것도 출력이 안되다.



- 파일 삭제

# rm 1.txt 

rm: remove regular file `1.txt'? y

# rm -f 22.txt 

# rm -fv 3.txt 

removed `3.txt'

# rm -f 4.txt 

# ls

6.txt

- rmdir 은 디렉토리를 삭제하는 명령어지만 디렉토리에 파일이 하나라도

존재하면 삭제가 안된다. 그러므로 잘 사용하지 않고 rm -rf 를 많이 사용한다.

# touch 6.txt/a.txt

# rmdir 6.txt/

rmdir: 6.txt/: Directory not empty

# rm -rf 6.txt/


- mv 로 파일(디렉토리)의 이름을 변경한다.

# cd ..

# ls

1.txt  7.7  anaconda-ks.cfg  install.log2  install.log.syslog  Test

# mv Test TEST

# ls

1.txt  7.7  anaconda-ks.cfg  install.log2  install.log.syslog  TEST



+ Recent posts