command (8) 썸네일형 리스트형 [Linux]경로 상관없이 명령어 실행하기 Purpose 소스코드로 설치한 서비스를 명령어를 입력하는 경로 상관없이 실행하기 위함 root@jv0535 [~]haproxy -v -bash: haproxy: command not found /root 경로에서 haproxy 명령어를 실행할 수 없다 Solution 1. 실행파일 복사 소스 컴파일 후 생성된 실행파일을 아래 경로로 복사한다 ## 실행파일 복사 cp ~/haproxy-2.4.3/haproxy /usr/local/bin/ cp /box/nginx/sbin/nginx /usr/local/bin/ ## 적용 source /etc/profile 2. 변수 등록 실행파일을 환경변수로 등록한다 vim /etc/profile or ~/.bash_profile or ~/.bashrc PATH=$PAT.. [Kubernetes]Check cluster IPs range in Kubernetes Purpose Check cluster IPs range Services IP range kubectl cluster-info dump | grep -m 1 service-cluster-ip-range "--service-cluster-ip-range=10.96.0.0/12", Pods IP range kubectl cluster-info dump | grep -m 1 cluster-cidr "--cluster-cidr=10.254.0.0/16", [Kubernetes]kubectl command 자동 완성 kubectl cheat sheet setting bashrc 혹은 profile 설정이 가능 곳에 아래 내용을 입력하고 적용한다. # for bash source [Linux]How to use ln command - make links between files Purpose The ln utility creates a new directory entry (linked file) which has the same modes as the original file. hardlink 하드 링크를 생성하면 하드링크 파일이 생성되고 원본 파일과 같은 inode를 사용한다. 사용법 ln basefile.txt hardlink.txt inode 보는 명령어 ls -il [filename] Create hardlink Check inode softlink (symbolic link) 소프트 링크를 생성하면 새로운 inode를 생성하고, 데이터는 원본 파일에 연결한다. 사용법 ln -s basefile.txt softlink.txt Create softlink Check ino.. [Linux]How to use basename command in CentOS - strip directory and suffix from filenames Purpose Print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX. 파일명에서 접미사를 삭제할 때 사용한다. 나의 경우 gitlab restore 스크립트를 작성할 때 사용하였다. backup 파일이 "1620209195_2021_05_05_13.2.0_gitlab_backup.tar" 와 같은 형식으로 떨어졌고, restore 명령어에서는 "_gitlab_backup.tar" 이 부분이 불필요하여 basename 명령어를 사용하여 해당 내용을 제거 하였다. suffix remove a trailing suffix option: -s # without -s root@jv054.. [Linux]How to use scp command in CentOS - secure copy (remote file copy program) Purpose scp copies files between hosts on a network. 서버 간 파일 전송을 위해 사용한다. Option -p : 원본 권한 속성 유지 -P : ssh port num -c : 압축 복사 -v : 과정 출력 복사 -a : 아카이브 모드 복사 -r : 디렉터리 내 모든 파일 or 디렉터리 복사 1. 원격지로 파일 전송 write 권한이 있어야 전송가능 원격지에서 받고 나면 목적지에서는 rw-rw-r-- 와 같은 권한을 가진다. 기본 문법 scp [option] [소스디렉터리] [원격지ID]@[원격지IP]:[원격지디렉터리] -P: ssh 연결 포트 -r : 하위 디렉터리까지 전송 단일 파일 전송 scp -P 2211 /home/asmanager/scpfile1 asma.. [Linux]Find and Delete old log files in CentOS Purpose Delete old log files 오래된 로그 삭제를 위한 명령어 필요한 상황에 맞게 작성하여 Crontab에 추가하여 사용할 수 있다. A few days ago # 사용법 1 find -name '/경로/*.log' -mtime +(원하는날짜 -1) |xargs rm # 사용법 2 find /home/searchuser/sf-1/log/*/*.log -type f -mtime +30 | xargs rm -f find /home/searchuser/sf-1/log/*/*.log -type f -mtime +30 -exec rm -f {} \; 현재 위치 하위에서 .log 파일을 찾아서 mtime(수정시간)이 30일 이상 된 것을 지움(xargs rm) Specific month ## .. [Docker]Docker system prune Purpose Delete old data that is not used in docker docker system prune https://docs.docker.com/engine/reference/commandline/system_prune/ Remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes. option -filter : Provide filter values f : Do not prompt for confirmation a : Remove all unused images not just dangling ones until=120h : until () - only.. 이전 1 다음