관리 메뉴

IT 컴퓨터공학 자료실

Learning Linux Command Line - LinkedIn Learning, Scott Simpson Sammary (리눅스 커맨드 라인 강의 요약) 본문

리눅스

Learning Linux Command Line - LinkedIn Learning, Scott Simpson Sammary (리눅스 커맨드 라인 강의 요약)

윤맨1 2021. 10. 7. 17:33

리눅스 쉘 커맨드 강의 요약 ( 3시간 강의 )

 

* 일반적인 커맨드 문법

)

ls lh /user/bin

sort u user.txt

grep i “needle” haystack

 

Command Option(s) Argument(s)

 

* Option(s) 의 특징

커맨드를 어떻게 작동할 지

-로 시작함

보통 한 개의 캐릭터 글자로 사용함

대부분의 Option(s) 명령어는 한 개 혹은 그 이상의 명령어

 

* 실습 1

ls 명령어

: 현재 디렉토리의 파일 목록을 간단히 보여줌

ls l 명령어

: 현재 디렉토리의 파일 목록을 자세히 보여줌

 

* 유용한 단축키

TAP

: 자동적으로 파일이나 폴더의 풀 네임을 치지 않아도 자동적으로 완성해주는 키

: 경로의 내용에 근거하여 추측할 수 있게 도와줌

 

* 텍스트 네비게이션 관련 단축키

Key Combination Result
Ctrl+A(^A) 가장 첫 라인으로 이동
Ctrl+E(^E) 가장 끝 라인으로 이동
Ctrl+Left arrow 왼쪽으로 한 단어 만큼 이동
Ctrl+Right arrow 오른쪽으로 한 단어 만큼 이동
Ctrl+U 커서의 왼쪽 문자들 잘라내기 (버퍼에 저장)
Ctrl+K 커서의 오른쪽 문자들 잘라내기 (버퍼에 저장)
Ctrl+Y 잘라낸 문자 (버퍼) 붙여넣기
Ctrl+Shift+C 클립보드에 복사하기
Ctrl+Shift+V 클립보드에 붙여넣기

* Bash 단축키

Key Combination Result
Up arrow Recall previous commands
Down arrow Scroll previous commands
Ctrl+R Search command history
Ctrl+C Cancel command

 

* 명령어가 생각나지 않을 경우

리눅스의 모든 명령어를 암기해야 할 필요는 없습니다.

man : 명령어의 매뉴얼 페이지를 여는 명령어

자체 내장된 명령어 관련 문서입니다.

ls --help

ex) man ls

 

* 파일에 대해 알아내는 법

 

file 명령어

ex) file myfile.txt

: 파일 타입을 결정한다.

 

stat 명렁어

ex) stat myfile.txt

: 소유권정보와 수정정보 등에 대해 표시한다.

 

* 현재 위치를 알 수 있는 명령어

: pwd

 

* find . -name “poem”

* find . -name “d*”

* find . -name “*d”

 

* 디렉토리 폴더 제거 명령어

: rm rf output

 

* 리눅스 시스템은 다중 유저 환경이다.

사용자들의 파일들은 분리되어 보관된다.

su 명령어로 사용자를 바꾼다.

 

* 사용자 종류

 

일반 사용자

: 자신들의 파일은 수정이 가능하나, 시스템에 관한 파일은 변경할 수 없음

 

 

수퍼 사용자(root)

: 모든 파일을 수정할 수 있으며, 시스템 또한 변경이 가능한 사용자이다.

 

* 파일 권한 (File Permission)

 

rwxrwxrwx the_file

User Group Others

 

rwx

Read Write Execute

 

두 가지의 표현 방법

1. Octal하게

ex) 755, 644, 777


Read (4) Write (2) Execute (1) Result
User r w x 7
Group r - x 5
Others r - - 4

 

* Octal Value

Octal Value Mode Octal Value Mode
0 - - 4 r - -
1 - x 5 r x
2 w - 6 r w -
3 w x 7 r w x

 

 

2. Symbolic하게

ex) a=r, g+w, o-x

* Symbolic File Permission


Read (r) Write (w) Execute (x) Result
User (u) + + + u+rwx
Group (g) = - - g=r
Others (o) - - - o-rwx
All (a)



 

+ adds permission; - remove permission

= adds permission but removes others

 

* Octal 방식과 Symbolic 방식의 비교

Octal Value Symbolic Value Result
777 a+rwx rwxrwxrwx
755 u+rwx, g=rx, o=rx rwxr-xr-x
644 u=rw, g=r, o=r rw-rr--
700 u=rwx, g-rwx, o-rwx rwx------

 

* Symbolic Value 변환 연습

Original Symbolic Value Result
rw-r—r-- +x rwxr-xr-x
rwxrwxrwx g=w, o=r rwx-w-r--
rwxr-xr-x o-rx rwxr-x---
rwxrwxrwx a-x rw-rw-rw-

 

* 일반적인 리눅스 파일 시스템의 구조

/ root (highest level of filesystem hierachy)
home stores user home folders
root stores root’s home folders
etc configuration files for many tools
bin stores binaries (programs)
sbin stores binaries (programs)
lib libraries and shared modules
dev represents devices on the system
mnt where local and remote filesystems and mounted
media where removable storage is mounted
proc virtual filesystem representing processes
sys virtual filesystem representing kernal devices

 

* | (shift + Won 표시)

: pipe로 명령어를 연결한다.

* echo “hello”

* echo “hello” | wc

* echo “hello world from the command line” | wc

 

* Tools for text

- Cat 명령어

Concatenate (v.) : to link together

- Head 명령어

: 첫 줄 출력하는 명령어

- Tail 명령어

: 마지막 줄 출력하는 명령어

 

* Searching for Text 명령어

grep “the” poems.txt

grep n “the” poems.txt

grep “the” poems.txt

grep i “the” poems.txt

 

* Manipulating Text 명령어

cat simple_data.txt

awk ‘{print $2}’ simple_data.txt

awk ‘{print $2 “\t” $1}’ simple_data.txt

 

* Editing Text 명령어

vim을 이용

:wq

 

* To Quit Vim

ESC :q!

 

* Nano 에디터

 

*Tar을 이용한 압축

tar cvf myfiles.tar Exercise\ Files/

tar caf myfiles.tar.gz Exercise\ Files/

tar caf myfiles.tar.bz2 Exercise\ Files/

ls lh

 

mkdir unpack

mv myfiles.tar.bz2 unpack/

cd unpack/

 

tar xf myfiles.tar.bz2

ls lh

 

mkdir unpack2

tar xf myfiles.tar.gz C unpack2

ls lah unpack2

 

* Data Compression (데이터 압축)

: zipunzip 명령어를 이용하여, 압축된 데이터 아카이브 파일을 만들 수 있다.

 

zip exfiles.zip -r Exercise\ Files/

ls lh

 

mv exfiles.zip ~/Downloads/

cd ../Downloads/

unzip exfiles.zip

ls lh

 

* Redirection

Stream Number Usage
Standard input(stdin) 0 Text Input
Standard output(stdout) 1 Normal text output
Standard input(stdin) 2 Error Text

 

* kernal 정보 명령어

cat /etc/*release

uname a

 

* HardwareDisk 정보 명령어

free h

cat /proc/cpuinfo

df h

ip a

 

* Linux Package Manager

Distro Package Manager
Debian, Ubuntu, etc. APT
Red Hat, CentOS YUM
Fedora DNF
SUSE YaST
Arch Pacman