Linux 기초 명령어 모음

2024. 3. 3. 16:32DevOps

리눅스를 사용할 때 너무 다양한 명령어와 옵션이 있는데 서버 개발하면서 쓸 수밖에 없을 것 같은 것 몇 개만 정리했어요.

저도 매뉴얼은 안 보고 매크로처럼 자동으로 쓰는 것 같아요.

자주 쓰다보면 외워서 쓰게 되는데 잘 안 쓰던 옵션도 다시 봤어요.

 


curl (client URL)

 

curl

command line tool and library for transferring data with URLs (since 1998) Supports... DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS

curl.se

 

기본 사용법:

 

사용 예시:

  • -H: HTTP 헤더 지정
  • -d: HTTP 요청 본문 지정
curl -X POST https://kingsubin.com\
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{"hello":"world", "foo":"bar"}'
  • -F: multipart/form-data 형식으로, 주로 파일 업로드
curl -X POST https://kingsubin.com/upload \
-F "file=@/path//file.jpg"

 

nslookup (name server lookup)

 

DNS Lookup

Find all DNS records for a domain name with this online tool. Nslookup shows A, AAAA, CNAME, TXT, MX, SPF, NS, SOA and more.

www.nslookup.io

 

기본 사용법:

  • `nslookup [options] `
    • `nslookup kingsubin.com`

 

사용 예시:

  • -type: DNS 레코드 타입 지정 (A, CNAME, MX, NS, ...)
    • `nslookup -type=mx kingsubin.com`
  • -debug: debug, DNS 조회 세부 정보
    • `nslookup -debug kingsubin.comn`

 

telnet

  • 원격 컴퓨터 접속, 네트워크 연결 테스트, 호스트와 포트로의 연결 가능여부 확인
  • `telnet <hostname> <port>`

 

ping

  • 네트워크 연결의 상태를 확인

 

사용 예시:

  • -c: iCMP 패킷 개수 지정, 지정하지 않으면 중지할 때까지
    • `ping -c 5 google.com`
  • -i: 패킷 보내는 간격(초) 지정
    • `ping -i 2 google.com`

 

lsof (List open File)

 

lsof Man Page - macOS - SS64.com

lsof List open files. Syntax lsof [options] [names] Options -? -h Display help text. -a Causes the list selection options to be ANDed. -A A Specify A as an alternate name list file where the kernel addresses of the dynamic modules might be found. This opti

ss64.com

 

사용 예시:

  • -u: 사용자가 열어 둔 파일
    • `lsof -u subin.lee`
  • -c: 커맨드가 열어 둔 파일
  • -p: 지정한 PID 가 열어 둔 파일
  • -i: 네트워크 연결 정보, 추가 포트번호나, 프로토콜 지정 가능
    • `lsof -i`
    • `lsof -i :8000`
  • -n: IP 주소 표시
    • `lsof -i -n -P`

 

ps (Process Status)

 

ps Man Page - macOS - SS64.com

Process status, information about processes running in memory. Since ps cannot run faster than the system and is run as any other scheduled process, the information it displays can never be exact. The ps utility displays a header line, followed by lines co

ss64.com

 

사용 예시:

  • a: 모든 사용자
  • u: 프로세스 상세정보
  • x: 콘솔에서 실행되지 않는 프로세스
    • `ps aux`
  • -e: 실행 중인 모든 프로세스
  • -f: 실행 중인 프로세스 상세 정보
  • -u: 지정한 사용자가 실행중인 프로세스
    • `ps -u subin.lee`
  • -p: 지정한 PID 정보
    • `ps -p 63439`

 


3년 전에 적은 신기한 리눅스 명령어 게시글도 있네요. 지금은 다 알고 있는 게 신기하고 다행이에요.

https://kingsubin.com/336

 

kingsubin

잡다한 게 있어요..

kingsubin.com

 
 
 

'DevOps' 카테고리의 다른 글

Udemy Docker & Kubernetes 강의 후기  (0) 2024.03.31
Github Actions self-hosted runners  (1) 2023.06.03
GCP Monitoring Mattermost Notification  (0) 2023.05.12
ubuntu server 설정  (3) 2023.04.09
AWS GCP 도메인 이전  (0) 2023.01.04