Server/Linux

Linux - 3

포항돼지 2025. 6. 20. 14:44

SSH - SSH secure connection protocol, Secure shell for accessing remote computer

 

SCP,FTP 같이 pacakge installed 됨

Telnet/rlogin 이런건 이제 안씀

 

Server and Credentials : User credential use/ SSH key use , 두가지 방법으로 access가능

 

 

ssh-keygen == ssh key 만드는 거, rsa 방식 4096비트로

ssh_rsa_key.pub == public , server에 넣는거

ssh_rsa_key == private, key 갖고 서버 접속하는거

 

 

Key 만들어서 paste 하면, 이렇게 key pasword 치고, 접속 할수있게 됨

-i == indicate , key가 어딧는지

 

ssh -i ~/.ssh/ssh_rsa_key -p 2222 ubuntu@localhost

로컬에 key 써서 들어가는거, server에 pub key 있어서, 패스워드 안치고 접속 가능

 

authorized_key == public key 랑 같음, 서버 내의 key 값 저장소

 

copy command 안되면, cat 써서, key.pub 값을, authorized_key 값 안에 manually 넣으면 됨

ssh private key == .pub 없는거

public key == authroized file안에, 서버안에 key값 있어야함!! 기억하기

 

~/ , username directory

 

Pipe (|)

2개 프로세스, 2개 커맨드 연결해주는 역할

pipe 통해서 아웃풋 들어가고, 인풋 나오는거

 

 

stdout (standard out) , stdin (standard input)

Temporary space or other 이런데 안들어감 -> in terms of memory , 빠른 연산속도

 

example:

 

ls | grep "txt" , ls 중 txt가 들어간 파일들 grep 해주는거

ps aux = lists all runing process

grep httpd = 아차피써버 찾아라

awk = 2번째 열 프린트해라

 

 

 

awk '{print $2}' -> 2번째 tab print 해라, 여기서는 PID pull 한거 (11,40)

 

Grep (Global Regular Expression Print) - 간단한데 진짜 많이 쓰임

Texting search tool

 

grep 하고 pattern (string or numbers), and file

grep 자체 사용하는거보다, Pipe써서 사용하는경우가 많음

-i 대소문자 구분 X

-v 키워드 빼고, 패턴 포함 x , apple 치면, apple이 들어가있는거만 빠지고 다 보여

-r -R recursively 디렉토리 안에서 여러개 파일 찾아보기

-l 패턴에 맞는 파일네임만, 들어가있는 파일 이름 알려줌

-n 라인넘버 

-c 몇개나 패턴에 매치 됐는지

-E regular expression

 

경험상 cat fruits.txt | grep "apple" , 이런식으로 쓴 경우가 많음

 

grep -E "appl(e|es)" fruits.txt ,fruits.txt 파일안의 apple or apples 찾으라는거

 

 

wc (word count)***

verstatile  ( able to do many different things or to adjust to new conditions, or (of things) able to be used for many different purposes

Polyvalence ( he fact of having many different functions or forms)

 

Polyvalenceversatility는 모두 여러 기능이나 작업을 수행할 수 있는 능력을 설명하는 단어입니다. 그러나 polyvalence는 기능이나 의미의 다양성을 강조하는 반면 versatility는 다양한 상황이나 맥락에 대한 적응성을 강조합니다. Polyvalence는 과학적 또는 기술적 맥락에서 더 일반적으로 사용되는 반면 versatility는 일상 언어에서 더 일반적으로 사용됩니다.

 

 

reads one or more input files and provides statistical information

 

file 같은거 라인카운트 할때많음, 이때 wc많이 사용

 

-l == 라인갯수 세는거

-w == 워드 카운트

-c == bytes 보여주는거

-n == number of charicter

-L == Length of longest line

 

outputs line // word // byte counts

 

echo "Hello World" | wc == echo 로 읽고, 1줄 이있고 2개의 워드가 있으며 12개의 bytes가있따라는 의미

대부분 -l 로 사용 - 라인 몇개인지 세는거