Skip to content

Instantly share code, notes, and snippets.

@rolroralra
Last active February 22, 2022 11:28
Show Gist options
  • Save rolroralra/c65a886178037538fbe7b8b9ecaa6c05 to your computer and use it in GitHub Desktop.
Save rolroralra/c65a886178037538fbe7b8b9ecaa6c05 to your computer and use it in GitHub Desktop.
Ubuntu

ntp, chronyd (Network Time Protocol)


Proxy Setting

vi /etc/environment
export http_proxy=username:password@proxy-server-ip:8080
export https_proxy=username:password@proxy-server-ip:8082
export ftp_proxy=username:password@proxy-server-ip:8080
export no_proxy=localhost, 127.0.0.1

How to get "Last Accessed File Time" in Ubuntu

$ stat ${filename}

Java Install

Details

#################################
# How to install Java in Ubuntu #
#################################

# 기존 버전 설치 여부 확인
$ java -version
$ dpkg -l | grep openjdk
$ whereis java
$ which java
 
# https://www.azul.com/downloads/zulu/ 
# Openjdk-8-jdk Local Install
$ sudo su
$ tar -xzvf java-8-openjdk-amd64.tar.gz -C /usr/lib/jvm
 
 
# /usr/bin/java 라는 파일이 없을 때, 심볼릭 링크 생성
$ ln -s /usr/lib/java-openjdk-8-amd64/bin/java /usr/bin/java
 
 
$ update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jdk/java-openjdk-8-amd64/bin/java" 1
 
 
# 운영체제 Architecture 확인 방법 (amd vs arm)
$ dpkg --print-architecture
 
 
# 설치 확인
$ java -version


운영체제 CPU Architecture 확인

$ dpkg --print-architecture
amd64

Linux 시스템 로그 파일

Details

Linux System Log File


Nginx Install

Detail

# 기존 버전 설치 여부 확인
$ dpkg -l | grep nginx
$ systemctl status nginx
 
# 기존 버전 삭제
$ dpkg --purge nginx
 
 
# local에 업로드한 패키지 파일을 이용한 수동 설치 (Nginx)
$ dpkg --install nginx_1.16.0-1~xenial_amd64.deb
 
 
# nginx 설치 여부 확인
$ systemctl status nginx
$ dpkg -l | grep nginx


# nginx configuration test
$ nginx -t

# nginx configuration reload
$ nginx -s reload


lsmod, lspci 명령어

# lsmod - Show the status of modules in the Linux Kernel
$ lsmod

# lspci - list all PCI devices
$ lspci

CPU, Memory, Storage, OS version

Details

# OS : uname -a
$ uname -a
$ lsb_release -a

# CPU : lscpu
$ lscpu
$ cat /proc/cpuinfo
$ sudo dmidecode -t processor  # DMI (Desktop Management Interface)
$ nproc  # the number of core

# MEM : free -m
$ free -m
$ cat /proc/meminfo
$ sudo dmidecode -t memory 

# DISK : df --total -h
$ df --total -h
$ df -h


How to empty log file (example: catalina.out)

truncate -s 0 catalina.out

curl 통신 시간 측정

$ for i in {1..10};do time curl localhost:8080/monitor/hlf; done;

pam_tally2 (사용자 계정 비밀번호 오류 횟수 관리)

Details

#전체 계정 패스워드 실패 횟수 확인
$ pam_tally2

#출처: https://boya.tistory.com/127 [Dev. Boya]
#리눅스 계정 비번 오류 횟수 확인
$ pam_tally2 --user ${USER_ID}

#리눅스 계정 비번 오류 초기화
$ pam_tally2 --user ${USER_ID} --reset

# 실제 관련 파일들 위치
$ cd /etc/pam.d


리눅스 패스워드 변경일 확인

Details

$ chage -l root
Last password change					: Nov 19, 2011
Password expires					: never
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7

$ passwd -S root
root PS 2011-11-19 0 99999 7 -1 (Password set, MD5 crypt.)


vimrc

.vimrc comment character

set shiftwidth=2
set tabstop=2
""set ai
""set si
set expandtab
""set bs=indent,eol,start

Regular Expression Cheatsheet

https://www.tutorialspoint.com/unix/unix-regular-expressions.htm

CheatSheet

Regular Expression CheatSheet


Regular Expression - Ungreedy, Group, Lookahead/Lookbehain Assertion

  • Ungreedy

https://unlimitedpower.tistory.com/entry/%EC%A0%95%EA%B7%9C%ED%91%9C%ED%98%84%EC%8B%9D-%EA%B3%BC-%EC%9D%98-%EC%B0%A8%EC%9D%B4%EC%A0%90?category=432268

  • Group

https://unlimitedpower.tistory.com/entry/%EC%A0%95%EA%B7%9C%ED%91%9C%ED%98%84%EC%8B%9D-%EA%B7%B8%EB%A3%B9Group%EC%9D%B4%EB%9E%80-%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80?category=432268

  • Lookarround Assertion

https://unlimitedpower.tistory.com/entry/%EC%A0%95%EA%B7%9C%ED%91%9C%ED%98%84%EC%8B%9D-%EC%9D%B4%EA%B2%83%EC%9D%B4-%EA%B3%A0%EA%B8%89%EC%9D%B4%EB%8B%A4-Positive-Negative-Lookahead-Lookbehind?category=432268


Package for pstree, ps Command

$ sudo apt install procps
$ sudo apt install psmisc

Supervisor (Deamon Manage Process)

https://www.slideshare.net/JackLee27/supervisord-125948403


FileSystem Type

https://movenpick.tistory.com/34

Details

ext         -초기 리눅스에서 사용하였던 종류, 현재는 사용하지 않습니다.

ext2       -현재도 사용하며, 긴~파일시스템이름을 지원하는것이 특징입니다.

ext3       -저널링 파일시스템, ext2보다 파일시스템의 복수/보안기능을 크게향상되었고     

  현재 기본 파일시스템으로 쓰이고 있습니다.

ext4       -16TB까지만 지원하던 ext3과 달리 더큰 용량을 지원하며, 삭제된 파일 복구, 

  파일 시스템 점검속도가 훨~씬 빨라진 파일시스템입니다.

iso9660   -DVD/CD-ROM을 위한 표준 파일시스템으로 읽기만 가능합니다.

nfs         -원격서버에서 파일시스템 마운트할때 사용하는 시스템(Network File System)

swap     -스왑파일시스템, 스왑공간으로 사용되는 파일시스템에 사용합니다.

ufs        -Unix system에서 표준 파일시스템으로 사용합니다.(Unix File System)

vfat        -윈도우95/98등등 ntfs를 지원하기위한 파일시스템에 사용합니다.

msdos    -MS-DOS파티션을 사용하기위한 파일시스템에 사용합니다.

ntfs        -윈도우NT/2000의 nfts를 지원하기위한 파일시스템에 사용합니다.

hfs        -MAC컴퓨터의 hfs를 지원하기위한 파일시스템에 사용합니다.

hpfs      -hpfs를 지원하기위한 파일시스템에 사용합니다.

sysv      -Unix system v를 지원하기위한 파일시스템에 사용합니다.

ramdisk   -RAM을 지원하기위한 파일시스템에 사용합니다.


How to find OS type and version

https://www.cyberciti.biz/faq/how-to-check-os-version-in-linux-command-line/

Details

$ cat /etc/os-release
$ lsb_release -a
$ uname -r
$ hostnamectl
$ cat /proc/version

# description
$ lsb_release -ds
Ubuntu 18.04.3 LTS

# id
$ lsb_release -is
Ubuntu

# release
$ lsb_release -rs
18.04

# codename
$ lsb_release -cs
bionic


dpkg

Details

Description of each field

As you can see from the first three lines:

  • First letter -> desired package state ("selection state"):

    • u ... unknown
    • i ... install
    • r ... remove/deinstall
    • p ... purge (remove including config files)
    • h ... hold
  • Second letter -> current package state:

    • n ... not-installed
    • i ... installed
    • c ... config-files (only the config files are installed)
    • U ... unpacked
    • F ... half-configured (configuration failed for some reason)
    • h ... half-installed (installation failed for some reason)
    • W ... triggers-awaited (package is waiting for a trigger from another package)
    • t ... triggers-pending (package has been triggered)

-Third letter -> error state (you normally shouldn't see a third letter, but a space, instead): - R ... reinst-required (package broken, reinstallation required)


Change Booting Mode (CLI mode, GUI mode)

Details

# Level 5 -> Level 3
$ sudo systemctl isolate multi-user.target

# Level 3 -> Level 5
$ sudo systemctl isolate graphical.target;

# Get Current Booting Mode
$ sudo systemctl get-default
graphical.target

# Set Default Booting Mode (Level 3: CLI, Level 5: GUI)
$ sudo systemctl set-default multi-user.target;
$ sudo systemctl set-default graphical.target;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment