본문 바로가기
리눅스

centos : 기본명령어

by 닐스 2021. 5. 31.

계정관리 : 그룹

 

  • 그룹ID 지정

 

usermod -u 510 testuser

usermod -g 510 testuser

 

vi /etc/group

weblogic:x:510:weblogicuser,testuser

 

  • 그룹명 지정

 

usermod -G weblogic testuser

 

vi /etc/group

weblogic:x:510:weblogicuser,testuser

 

 

service

centos 6.x 버전 centos 7.x 버전 설명
service name start systemctl start name.service 서비스 시작
service name stop systemctl stop name.service 서비스 중지
service name restart systemctl restart name.service 서비스 재시작
service name condrestart systemctl try-restart name.service 서비스가 구동중이었을 경우에만 재시작
service name reload systemctl reload name.service 설정 재구동
service name status systemctl status name.service
systemctl is-active name.service
서비스 구동 여부 확인
service --status-all systemctl list-units --type service --all 모든 서비스의 상태 표시

 

 파일생성 : 날짜포함

/home/oracle/filename$(date '+%Y-%m-%d').log

 

 파일 비우기

cat /dev/null > xxxx.xxx

 

 더미 파일 생성

# fallocate -l 2G test_file

 

■ exec

 

앞선 명령어의 결과를 입력으로 받아 "\;" 라는 표기자를 만날때까지 읽고 실행

(앞의 실행결과가 { } 안에 들어온다.

#find /home/test -type f -size +5M -exec ls -l {} \;

 

 폴더용량 확인

du -h --max-depth=1

 

 TCP 덤프

tcpdump -i eno1 dst x.x.x.x and tcp port 55000 and "tcp[tcpflags] & (tcp-syn|tcp-ack) != 0"

 

■ 디렉토리 : 하위 디렉토리 까지 한번에 생성

mkdir -p vehicles/{sedan,coupe,convertible,truck}

 

■ 크론탭

  • 설치여부확인 : ps -ef | grep cron
  • 분(0-59)  시간(0-23)  일(1-31)  월(1-12)   요일(0-7) : 0부터 일요일, 매분은 * * * * *
  • crontab <-e> <-l> <-r>
  • service crond <start> <stop> <restart>

 

■ 실시간 변경값 확인

watch -d -n1 "cat /proc/net/bonding/bond0"

 

■ 환경변수

  • /etc/profile      : 전체 사용자
  • /etc/bashrc      : 전체 bashrc
  • ~/.bash_profile : 로그인     ( 특정 계정 )
  • ~/.bash_logout : 로그아웃  ( 특정 계정 )
  • ~/.bashrc        : bashrc     ( 즉정 계정 )
  • 인식순서

       /etc/profile -> ~./bash_profile -> ~/.bashrc -> /etc/bashrc

 

[-]# env

[-]# export num1=1                       : 덮어쓰기

[-]# export num1=$num1:/etc/bin     : 추가하기

 

별칭 설정 : alias

 

[-]# alias <alias_name>='<command>'

 

■ 캐시 메모리 비우기

[-]# sync && echo 3 > /proc/sys/vm/drop_caches

 

■ 정렬

[-]# ls | sort

 

■ 파일 사이즈 확인

[-]# ls -alSh

  • -S : 사이즈 크기순 정렬

 

■ ssh 원격명령

ssh 아이디@서버주소 명령어

 

sshpass 패스워드 ssh 아이디@서버주소 명령어

 

네트워크 셋팅 : IP

  • centos 7.x 버전 :
    • #> nmcli d
  • IP 셋팅 첫번째 방법 : /etc/sysconfig/network-scripts/ifcft-eth0
  • IP 셋팅 두번째 방법 : [7]# nmtui
  • DNS 설정

[-]# vim /etc/resolv.conf

---------------------------

nameserver x.x.x.x

nameserver x.x.x.x

---------------------------

[-]# systemctl restart network

 

CD 마운트 경로

 

  • /run/media/<사용자계정명>

 

폴더 용량 확인

du -d N 디렉토리명

  • d 옵션으로 몇 단계 하위 디렉토리까지 출력할지 정할 수 있습니다.

'리눅스' 카테고리의 다른 글

오라클 11g R2 ( Oracle 11g R2 ) 설치  (0) 2021.07.30
Centos 7 템프 ( temp ) 만들기  (0) 2021.07.16
cenos 7 스왑 ( swap ) 수정  (0) 2021.07.16
센토스 ( cenos 7 ) ssh 터미널 설정  (0) 2021.07.15