사용자 계정 확인

전체 사용자 계정 확인

cat /etc/passwd

 

useradd를 이용해 등록된 사용자만 보기

grep /bin/bash /etc/passwd

 

사용자 계정 설명

adm

시스템 관리자를 위한 별도의 계정

 

lp

로컬 프린터 서버 계정

 

sync

원격지 서버 동기화 계정

 

shutdown

시스템 종료 계정

 

halt

강제 시스템 종료 계정

 

news

뉴스그룹 서버용 계정

 

uucp

유닉스 시스템과 파일 복사를 위한 프로토콜 계정

 

operator

특수목적용 계정으로, 시스템 백업 등 여러 사용자가 시스템을 공통 관리하기 위해 사용되는 계정

 

games

X11(X윈도우) 화면에서 게임을 할 때 사용하는 계정

 

avahi-autoipd

DNS 관련된 계정

avahi-autoipd is a service provided by the Avahi daemon on Linux, which implements network services discovery using the mDNS/DNS-SD (Multicast DNS / DNS Service Discovery) protocol. Specifically, avahi-autoipd is responsible for assigning an Automatic Private IP Addressing (APIPA) address to a network interface when it cannot obtain an IP address from a DHCP server.

 

avahi-autoipd is part of the Avahi service on Linux systems and is responsible for assigning link-local IP addresses (APIPA addresses) when a DHCP server is unavailable. It helps maintain basic network connectivity on local networks and is part of the broader Zero Configuration Networking (zeroconf) system.

 

tss

암호화 키 생성, 플랫폼 무결성 검증과 관련된 TPM 소프트웨어 스택 관리용 계정

The tss user on a Linux system is a system user created to manage the Trusted Platform Module (TPM) software stack. TPM is a hardware component that provides secure generation and storage of cryptographic keys, as well as platform integrity verification.

The tss user is associated with the TrouSerS software (or other TPM-related software), which is the open-source implementation of the TPM Software Stack (TSS). This user is created to run the TPM-related services with minimal privileges for security purposes.

 

The tss user in Linux is a system account created to manage the TPM Software Stack (TSS) and run TPM-related services, ensuring secure interactions with the Trusted Platform Module (TPM). It provides essential security features for cryptography, encryption, and platform integrity in systems with TPM hardware.

 

postfix

메일 전송 관련 계정

The postfix user on a Linux system is a system account created for the Postfix mail transfer agent (MTA). Postfix is a widely used open-source software for routing and delivering email. It’s designed to be secure, fast, and easy to configure, often serving as a replacement for the older Sendmail MTA.

The postfix user is used to run Postfix services and processes with minimal privileges, adhering to the principle of least privilege to enhance security.

 

The postfix user on Linux is a system account created to run the Postfix mail transfer agent (MTA). It ensures that Postfix's email processing tasks are handled securely by limiting privileges, as most Postfix processes run under the postfix user instead of root. This helps enhance the security of the mail server and minimizes the risk of exploitation.

 

saslauth

인증 관련 계정

The saslauth user on a Linux system is a system account associated with the Cyrus SASL (Simple Authentication and Security Layer) authentication library. SASL is a framework that provides authentication and data security services for network protocols such as SMTP, IMAP, and LDAP.

The saslauth user is created to run the SASL authentication daemon (saslauthd), which handles authentication requests from various services and applications. This system account ensures that the saslauthd service runs with minimal privileges, adhering to security best practices.

 

The saslauth user on Linux is a system account used to run the SASL authentication daemon (saslauthd), which provides secure user authentication for various services like email, LDAP, and others. The saslauth user ensures that the saslauthd process runs with minimal privileges, enhancing the overall security of the system by reducing potential attack surfaces.

 

polkitd

시스템 전체 권한 관리용 계정

The polkitd user on a Linux system is a system account used by Polkit (formerly known as PolicyKit), which is a framework for managing system-wide privileges. Polkit is commonly used to handle authorization for actions that require elevated privileges (such as running administrative tasks) in a controlled and secure manner.

 

The polkitd user in Linux is a system account used to run the Polkit daemon (polkitd), which is responsible for managing and making authorization decisions on privileged system actions. By running Polkit with minimal privileges under the polkitd user, the system enhances security while allowing non-root users to perform administrative tasks based on defined policies.

 

nobody

최소 권한이 필요한 프로세스용 계정

The nobody user on a Linux system is a system account used for processes that do not require ownership by a specific user or for which minimal privileges are necessary. This account is commonly used to run services and processes that don’t need access to any critical system resources or files. By running these services under the nobody user, the system limits their access, improving security.

 

The nobody user on Linux is a non-privileged system account used to run processes with minimal system access. It provides an extra layer of security by ensuring that services that don’t need high privileges can only interact with limited parts of the system. This user is commonly used for network-facing services, daemons, or temporary file ownership, and it operates with the least possible permissions to reduce security risks.

 

named

DNS 서버용 계정

The named user on a Linux system is a system account created for running the BIND (Berkeley Internet Name Domain) service, which is one of the most common DNS (Domain Name System) server software packages. The BIND DNS server (often called named, short for name daemon) translates domain names into IP addresses and vice versa.

The named user ensures that the DNS server runs with limited privileges, adhering to the principle of least privilege, which enhances security by minimizing the potential damage that could occur if the DNS service were compromised.

 

The named user on Linux is a system account created to run the BIND DNS server daemon (named) with limited privileges. This enhances the security of the system by ensuring that the DNS service, which is often exposed to the internet, cannot access or modify sensitive files. BIND is one of the most widely used DNS server software packages, and running it under the named user follows the principle of least privilege to reduce security risks.:

디스크 관련

디스크 사용량 보기

// 루트부터 뎁스별로 확인해가기
du -h --max-depth=1 
// 또는
du -h -d 1

디렉토리 크기로 정렬

// 내림차순
du -m -d 1 | sort -rn

// 오름차순
du -m -d 1 | sort -n

디스크 free 용량 보기

df -h

 

사용자 관련

사용자 추가

useradd [username]

 

사용자 추가하면서 그룹에도 추가

useradd -G [groupname] [username]

 

사용자 비밀번호 변경

passwd [username]

 

기존 사용자를 그룹에 추가

usermod -a -G [groupname] [username]

 

사용자 삭제

- 계정만 삭제

userdel [계정명]

- 계정 + 홈디렉토리 삭제

userdel -r [계정명]

 

디렉토리 관련

현재 디렉토리 위치(경로) 보기

pwd

 

디렉토리 생성

mkdir [생성할 디렉토리명]

예) mkdir test

 

디렉토리 삭제

- 빈 디렉토리 삭제

rmdir [삭제할 디렉토리명]

예) rmdir test

 

- 비어있지 않은 디렉토리와, 하위 파일들 모두 삭제

rmdir -r [삭제할 디렉토리명]

예) rmdir -r test

 

- 비어있지 않은 디렉토리와, 하위 파일(쓰기 금지된 파일 포함)들 모두 삭제

rmdir -rf [삭제할 디렉토리명]

예) rmdir -rf test

 

포트 관련

사용중인 포트 확인

netstat -ltup

ss -lntu

 

파일 관련

특정 파일에 실행권한 추가

// sudo chmod +x /usr/local/bin/[파일명]
sudo chmod +x /usr/local/bin/docker-compose

대부분의 OS, 프로그램은 로그를 남겨 장애시 원인 분석에 이용하게 된다.

리눅스, 특히 CentOS7 에서는 rsyslog라는 로그 시스템이 다양한 로그를 남긴다.

또한 로그가 계속 쌓이면 파일 사이즈가 비대해져 디스크 공간 부족이 생길 수 있고, 파일을 열어 분석하는 작업도 쉽지 않기에, logrotate라는 프로그램이 쌓인 로그를 파일로 분할하고, 오래된 로그 파일을 삭제하는 등의 작업을 한다.

 

rsyslog

시스템의 다양한 로그를 남긴다

1. 로그 파일 저장 위치 : /var/log/ 디렉토리 하위에 저장

2. 주요 로그파일

로그파일 설명
messages 인증, 메일, cron을 제외한 대부분의 로그가 기록되는 파일
secure 인증, 즉 보안 관련 로그가 저장되는 파일
maillog 메일 관련 모든 로그가 저장되는 파일
cron cron 관련 모든 로그가 저장되는 파일
spooler uucp, news의 심각한 로그가 저장되는 파일
boot.log 부팅 메시지가 저장된 로그 파일

3. rsyslog 운영

rsyslog 시작

# systemctl start rsyslog

rsyslog 재시작

# systemctl restart rsyslog

rsyslog 종료

# systemctl stop rsyslog

rsyslog 상태확인

# systemctl status rsyslog

 

logrotate (로그로테이트)

쌓인 로그를 파일로 분할하고, 오래된 로그 파일을 삭제하는 등의 작업을 하여 로그를 관리한다.

파일을 어떻게 분할할지, 어떤 주기로 로테이트 시킬지 등은 logrotate 설정에서 가능하다.

1. logrotate 설정 : /etc/logrotate.conf

2. logrotate 설정파일 보기/수정하기

아래 명령어로 설정파일을 열어보고, 수정 후 저장하면 된다.

# vi /etc/logrotate.conf

logrotate.conf 내용 예

: 매주 로테이트, 최대 4개의 과거 로그 보관, 로그 파일 사이즈가 10M 이상이 되면 로테이트, 로그파일 압축 보관하는 예이다.

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

size 10M

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
    minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.

3. logrotate 실행

기본 실행

logrotate는 crond 데몬에 의해 매일 실행된다.

실행되는 파일 위치 : /etc/cron.daily/logrotate

 

직접 실행

설정 변경 후 바로 적용시키는 방법이다.

# logrotate -f /etc/logrotate.conf

리눅스에서 메모리 사용량을 보는 명령어들.

1. free

# free

실행 예

[root@xxx ~]# free
              total        used        free      shared  buff/cache   available
Mem:        1014548      727124       63300       29336      224124       37804
Swap:       4194300     4038808      155492

2. top

# top -n1 | grep Mem

실행 예

[root@xxx ~]# top -n1 | grep Mem
KiB Mem :  1014548 total,    89956 free,   727076 used,   197516 buff/cache
KiB Swap:  4194300 total,   154628 free,  4039672 used.    51492 avail Mem

3. meminfo

# cat /proc/meminfo | grep Mem

실행 예

[root@xxx ~]# cat /proc/meminfo | grep Mem
MemTotal:        1014548 kB
MemFree:           78344 kB
MemAvailable:      51884 kB

4. 메모리 사용량 많은 순 프로세스 보기 (상위 10개)

# ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11

실행 예

[root@xxx ~]# ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11
USER       PID  PPID   RSS  SIZE    VSZ %MEM %CPU     TIME COMMAND
mysql    10516 23044 143008 1758848 1846496 14.0 1.7 05:34:29 mysqld
apache    5283 21714 74816 426328 1144364  7.3 0.5 01:09:07 httpd
apache   22804 21714 74288 422436 1140472  7.3 0.3 00:40:52 httpd
apache   13757 21714 72580 285308 899728  7.1 0.7 00:52:34 httpd
apache   29439 21714 72260 152552 870560  7.1 0.3 00:07:30 httpd
apache   31022 21714 71752 254996 973004  7.0 0.7 00:48:15 httpd
apache   20054 21714 70388 386368 1104376  6.9 0.6 01:06:43 httpd
apache   20619 21714 69824 320396 934816  6.8 0.6 00:57:03 httpd
apache   19557 21714 69468 224524 836812  6.8 0.8 00:47:03 httpd
apache    8839 21714 64728 177964 893840  6.3 0.9 00:39:52 httpd

+ Recent posts