본문 바로가기
TIL/TIL

CLI & GUI & LINUX/UNIX & useful commands

by koreashowme 2020. 1. 15.

WHY COMMAND LINE INTERFACE?

  • 빠르다

  • 강력하다

  • 접근성이 좋다

WHY *NIX (LINUX/UNIX)?

  • 서버 시장에서의 *nix 점유율이 매우 높음

  • AWS 및 Azure등에서 제공하는 서버는 대부분 *nix 계열

  • Open Source!

USEFUL COMMANDS

 

파일 보기 ls

ex)

myuser@mymachine:~$ ls Desktop/ Documents/ Downloads/ hello.txt

 

권한?

ls -al의 상세 내용

(1)              (2) (3)        (4)    (5)   (6)   (7)    (8)

drwxr-xr-x  root  wheel  64B 11 7 14:14 test/

 

  1. 접근 권한 (읽기/쓰기/실행 가능) 여부

    • chmod 명령어

  2. 링크된 파일 갯수

  3. 소유자

  4. 소유그룹

  5. 파일 크기

  6. 만든 날짜

  7. 만든 시간

  8. 파일/디렉토리 이름

ex)

myuser@mymachine:~$

ls -al drwx------+ 59 myuser staff 1.8K 11 7 11:47 Desktop/

drwx------+ 14 myuser staff 448B 10 22 17:04 Documents/

drwx------+ 38 myuser staff 1.2K 11 6 18:44 Downloads/
-rw-r--r--@ 1 myuser staff 209B 10 10 17:45 hello.txt

디렉토리로 이동 cd

ex) myuser@mymachine:~$ cd Downloads

 

주요 명령어

 

  • 빈 파일 생성

    • touch [file_name]

  • 디렉토리 생성

    • mkdir [dir_name]

  • 텍스트 형태의 파일 확인

    • cat [file_name]

  • 파일 및 디렉토리 옮기기

    • mv [file_or_dir] [target_dir]

  • 파일 및 디렉토리 이름 바꾸기

    • mv [file_or_dir] [new_name]

  • 복사

    • cp [file] [target_dir]

    • cp -r [folder]

  •  

삭제

rm

rm 명령어는 정말 삭제할것인지 확인을 하지 않으며 한번 삭제된 파일은 휴지통에 들어가지 않습니다!

  • 파일 삭제

    • rm [filename]

  • 폴더 삭제

    • rm -r [dirname] 

  • 시스템 전체 삭제

    •  rm-rf / 

관리자 권한으로 실행 (super user do)

sudo

 

GUI 프로그램의 실행을 더 간편하게

  • 현재 폴더를 Windows 파일 관리자에서 보기

    • explorer .

  • 현재 폴더를 macOS Finder에서 보기

    • open .

  • 현재 폴더를 VS Code 에디터로 열기

    • code .

자주 사용하게 될 CLI 프로그램

  • 버전 관리 시스템 git

  • Package Manager (프로그램 추가/삭제)

    • Ubuntu: apt

    • macOS: Homebrew

    • Windows: chocolatey

  • 텍스트 에디터 vim

  • 클라우드 서비스 관리 AWS CLI

 

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

* pwd => full path ( 현재 디렉토리 확인)

* ls -al => Detail  확인

* ls => LIST 확인 

* cd . => 현재 디렉토리 확인

* cd / => 최상위 디렉토리

* ../ or .. => 상위 디렉토리 이동

* cd Music => Music directory 로 이동 

* ~ => cd ~ => home directory 확인

* 공백은 TAB => ex) FRANK\ KIM/ 

* touch =>  파일 생성

* cat => read the files 

 

* mv => move or copy 

 

 

sudo 관리자만 사용 가능 !!!! 

sudo touch testfile.txt  => create the files with admin

=> you can't edit it until you change the ownership of the files

 

*chown !!!! ownership 변경!!!

ex) sudo chown frank:staff testfile.txt

 

vim or vi (read and edit files) => :wq (to quit)   ex) vi testfile.txt 

'TIL > TIL' 카테고리의 다른 글

What's a "unit test"? (unit test)  (0) 2020.01.15
Testing, and the value thereof (unit test)  (0) 2020.01.15
테스트 주도 개발 TDD(Test-driven Development)  (0) 2020.01.15
code .  (0) 2020.01.15
git, CLI  (0) 2020.01.15

comment