[Shell] Find

Find it and do what you want

It’s safe to say that the find command in Linux is one of the must-know operations for backend developers, unless you are using a Windows-server

Continue reading

[Shell] df

How to identify and kill zombie/defunct processes in Linux without reboot

  • Linux에서는 maximum process 개수가 잇고 그리고 process id가 존재
  • maximum에 다다르면, 새로운 process를 시작이 불가능
  • zombie process는 그들이 parent process로부터 적절하게 정리되지 않은 dead process이다
  • process가 linux에 죽을때, 메모리로부터 모든것을 즉시 제거한다.
    1. process status는 EXIT ZOMBIE로 변하고 parent process는 child process로부터 SIGCHLD signal을 받는다
    2. parent process는 dead process의 exit status를 읽기 위해 wait() 시스템 콜을 호출
    3. parent process는 dead process로부터 정보를 얻는다
    4. wait()이 호출 된 후, zombie process는 완전히 메모리부터 제거
  • 위의 과정은 보통 굉장히 빨리 발생하고 system에 zombie process로부터 쌓이는 것을 보지 못함
  • parent process가 적절히 프로그래밍 되지 않고, wait() 시스템 호출을 절대로 하지 않으면, 그것의 zombie children은 계속 메모리에 남는다

Continue reading

[Shell] Linux tools

Linux tools that I learned 10 years ago, which I still use every day

ps and htop - listeing and finding proceess

  • htop 프로그램은 더 유연하고 사용하기 쉬움
  • terminal에서 sorting column을 mouse로 지원 htop

ss and netstat - what ports is that process using

  • netstat은 old way이고 요즘 배포판은 ss가 많이 적용
  • ss -ntaupe
  • ss -ntpl : listening port만 찾기 위함

    options

  • -n : lists processing using numeric address
  • -t : list TCP connections
  • -a : list all connections listening and establised
  • -u : lists UDP connections
  • -p : shows the process using the socket - probably the most useful
  • -e : shows some extened information like the uid

Shell job control - fg/bg/jobs

Continue reading

[Shell] df

DF(Disk Free)

Name

df - report file system disk space usage

Synopsis

df [OPTION]…[FILE]

Description

  • df : displays the amount of disk space availabe on the file system containing each file name argument
  • Disk space is shown in 1K blocks by default
  • df shows the space available on tht file system rather than on the file system containg the device node(which is always the root file system)
  • disk의 남은 용량을 확인

Options

  • -a,–al : include dummy file systems
  • -B,–block-size=SIZE : user SIZE-byte blocks
  • –direct : show statistics for a file instead of mount point
  • -h,–human-readable : print size in human readable format(e.g , 1K 234M 2G)
  • -i,–inodes : list inode information instead of block usage
  • -T,–print-type : print file system type

Example

  • df -TH
  • df -T /home/bastion

Continue reading

[Shell] Date

DATE

  • 일자,시간을 처리 |옵션|내용| | – |–| | d | 원하는일자를 지정 | + | 출력포맷지정 |
  • 예제
    • 일자 출력 포맷 지정 ```

    # 년월일 형태 $ date +%Y%m%d 20190212
    # %를 지원하지 않는 환경(ex: crontab)에서는 특수기호로 입력 $ date +\%Y\%m\%d 20190212
    # 년월일 시간 출력 $ date +”%Y%m%d %H:%M:%S” 20190212 08:46:53 # 주차 계산 $ date +%W 06

      -  **일자 변경**
    

    # 1일 전 $ date +%Y-%m-%d -d ‘1 days ago’ 2019-02-11
    # 1일 후 $ date +%Y-%m-%d -d ‘+1days’ 2019-02-13
    # 20190101 일자 지정후 1일 추가 $ date +%Y-%m-%d -d ‘20190101 +1days’ 2019-01-02 ```

Continue reading

[Shell] print

Print

Modifiers for print Formats

printf "%s %s\n", "don't", "panic"
printf "%2$s %1$s\n", "panic", "don't"
  • Minus
    • width 식별자
    • left-justify 인수
  • space
    • 양수 : space 우측에서 시작
    • 음수 : 마이너스 좌측에서 시작
  • `

Continue reading

Pagination