티스토리 뷰

레드헷 리눅스 Red Hat Linux version

파일 또는 디렉토리 관리 기본 명령어

Managing file and directory by using basic command

 

 

 

1. ls (list에 약자, intial of list) -> 파일 목록 확인 ( check file list )

 

 형식Format ) [root@jasonlee~]# ls 옵션Option 디렉토리Directory

 ->디렉토리 안에 존재하는 목록 확인 Check the list exist in directory

 

ex) [root@jasonlee~]# ls -l      

=>현재 디렉토리의 목록을 자세히 확인

   Check list in directory detail.

    

     [root@jasonlee~]# ls -l /etc 

=> /etc 디렉토리 안에 있는 목록 자세히 확인

   Check list in /etc directiroy detail.

 

[root@jasonlee~]# ls -al

=> 숨겨진 파일 확인

   Check invisible file

 

[root@jasonlee~]# ls -il

=> 파일의 inode 번호 확인

   Check inode number of file

 

 

 

[root@jasonlee~]# ll 은 [root@jasonlee~]# ls -l 과 같은 명령어이다.

ll is same inpust source as ls -l

 

 

2. cd (change direction)

=> 작업 디렉토리 변경 change the directory where you work on now

 

 형식Format ) [root@jasonlee~]# cd 디렉토리directory

 

ex) [root@jasonlee~]# cd ..

=> 상위 디렉토리로 이동

   change to upper directory

 

[root@jasonlee~]# cd directory

=> 하위 디렉토리로 이동

   chagne to lower directory

 

[root@jasonlee~]# cd /directory

=> /directory 로 이동

   change to /directory

 

 

 

[root@jaylee121 /]# pwd

=> 현재 디렉토리 확인 show current directory

 

 

3. mkdir (make directory)

형식Format) [root@jasonlee~]# mkdir directory

 

ex) [root@jasonlee~]# mkdir aaa

=> 현재 디렉토리 아래에 생성

   Make another directory in current directory

 

[root@jasonlee~]# mkdir /bbb

=> /bbb 디렉토리 아래에 생성

   Make another directory in /bbb directory

 

[root@jasonlee~]# mkdir aaa bbb

=> 디렉토리 여러개 생성

   Make more than one directories at once

 

 

 

 

 

 

4. rmdir(remove directory) 디렉토리 삭제

형식(Format) => [root@jasonlee~]# rmdir 디렉토리directory

 

ex) [root@jasonlee~]# rmdir aaa

=> aaa 디렉토리 아래에 파일이 존재하면 삭제 불가능

   Can not remove aaa directory if file exists inside

 

형식(Format) => [root@jasonlee~]# rm 옵션Option 파일File

 

ex) [root@jasonlee~]# rm -rf aaa.txt

=> aaa.txt 파일 삭제

   Remove aaa.txt file

 

-r 의 의미 Meaning = 디렉토리 삭제하기 위한 옵션

                             Option that removes directory

 

-f 의 의미 Meaning = 무조건 삭제 옵션

                             Remove without ask user

 

 

 

5. cat => 파일의 내용보기 show file contents

    형식(Format) => [root@jasonlee~]# cat file

 

ex)

[root@jasonlee~]# cat > aaa.txt 

=> aaa.txt 라는 파일 생성

   create aaa.txt file

 

=> 내용 입력

  input contents you want to create

 

=> ctrl + d 입력 종료

   Finish input

 

[root@jasonlee~]# cat aaa.txt

 => aaa.txt 라는 파일내용 보기

   show contents of aaa.txt file

 

[root@jasonlee~]# cat >> aaa.txt

=> aaa.txt 추가 내용 출력

   input addiditional contents of aaa.txt file

 

 

 

 

 

6. cp(copy)

형식(Format)

=> [root@jasonlee~]# cp 원본파일 대상파일

    [root@jasonlee~]# cp Originalfile Objectfile

 

=> [root@jasonlee~]# cp -R  원본디렉토리 대상디렉토리

    [root@jasonlee~]# cp -R OriginalDir ObjectDir

 

 

 

 

 

7. mv(Move) 파일 또는 디렉토리 이동 및 이름 변경

                Move directory or file. Also change their name

 

형식(Format)

=> [root@jasonlee~]# mv 원본Original 대상Object 

 

ex) [root@jasonlee~]# mv aaa.txt  /home

=> aaa.txt 파일을 /home 디렉토리로 이동

    Move aaa.txt file to /home directory

 

[root@jasonlee~]# mv aaa.txt bbb.txt

=> aaa.txt 파일명 bbb.txt로 변경

   change file name from aaa.txt to bbb.txt

 

 

 

 

 

 

 

8. ln(link) 파일 링크

형식(Format)

=> [root@jasonlee~]# ln 원본파일 대상파일

    [root@jasonlee~]# ln origianalFile objectFile

 

 

 => [root@jasonlee~]# ln -s 원본파일 대상파일

     [root@jasonlee~]# ln -s originalFile objectFile

링크 파일 생성 Create Link File with new name.

 

 

ex) [root@jasonlee~]# cp aaa.txt ccc.txt

=> 파일 내용 복사 (두 파일의 inode 번호가 다름)

    Copy content of files (Two file have different inode number)

 

[root@jasonlee~]# ln aaa.txt ddd.txt

=> 파일 완전 복사 (두 파일의 inode 번호가 같음)

   Link content of files (Two file have same inode number)

 

=> 원본 파일 내용을 변경하면, 복사파일 ccc.txt는 그대로이지만 링크된 ddd.txt는 원본파일 변경내용과 같이 바뀐다.

    If change content of original file aaa.txt, the content of ccc.txt has no changes but likned file ddd.txt will changes as aaa.txt has changes.

 

 

 

 

ex) [root@jasonlee~]# ln -s link ccc.txt ccc

=> 링크 파일명을 파일명으로 표시되는 링크파일 생성

create link file ccc shown in new file name ccc rather than ccc.txt

 

파일이나 디렉토리를 보다 쉽게 제어하기 위해 사용

most of use for handle file or directory easily. giving easy and short name you prefer on link file to link original file.

 

 

   

 

9. 특수 문자 사용 Use of punctuation mark

> : 명령의 결과를 파일에 저장 Save the result of command in file

ex) [root@jasonlee~]# ls -l /etc/*.conf > conf.txt

[root@jasonlee~]# cat conf.txt

 

 

 

| (vertical bar) : 명령의 결과를 이용하여 다른 명령을 실행

Execute another command by using results of output

ex) [root@jasonlee~]# ls -l /etc/*.conf | more

=> .conf 파일 목록 확인한 결과에 more이라는 명령어를 사용하여 목록확인간에 more 옵션 이용

    use the more option to check the list of .conf file

 

 

 

; (semicolon): 명령을 순차적으로 실행 execute command by order

ex) [root@jasonlee~]# mkdir aaa; ls -l

 

 

 

 

10. 명령의 매뉴얼 확인 see the manual of command

형식(Format) => man 명령Command => q 종료quit

              or => 명령Command -- help

 

11. 단축키 Abbreviation Key

crtl + c => 명령 취소 Command Cancelation

crtl + d => 입력 종료 End Input

crtl + z => 명령 일시중지 Hold Command

 

 

 

 

 

 

 

 

 

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함