본문 바로가기

분류 전체보기219

Shell, Shell Script, .sh란 01 Shell1. 정의사용자가 입력한 명령어 커널에게 전달될 때 해석기즉, 명령어 해석기이자 스크립트 언어해석 기능, 프로그래밍 기능, 사용자 환경 변수 설정 가능 2. 종류종류약자Bourne Shellbsh?C ShellcshKorn ShellkshBash Shellbash02 Shell Script (.sh 파일, 쉘 파일)1. 정의command line에서 특정 기능이 수행되도록 지정된 Script (명령어들의 집합)쉘에 의해 수행되도록 작성된 프로그램interpretor 방식으로 작동제어 구조에 따라 쉘 명령어나 함수 실행 가능즉, 평문의 텍스트 파일로 하나의 명령어처럼 실행될 수 있는 실행 가능한 프로그램쉘이 파일의 내용을 읽어 처리선택/반복 등의 프로그래밍 구조를 사용할 수 있음긴 작업, 반.. 2024. 4. 30.
case문 사용법 (shell script) 01 case문 기본 사용법1. 기본 형식case ~ in으로 시작, esac로 끝맺힘;;를 분기별 끝 또는 다음 줄에 입력하여 분기 종료 명시*)는 default과 같은 개념으로 생략 가능case 파라미터/입력값 in 조건1) 실행명령 ;; 조건2) 실행명령 ;; *) 앞의 조건들 미해당 시 실행명령esac02 case문 활용1. 전달 인자 (argument) 활용.sh 파일(본인)을 소싱(sourcing)할 때 .sh 파일 안에서 $# 전달 인자 (argument) 사용 가능$0은 스크립트명, 그 뒤에 올 $1, $2, $3, ... 전달 인자 계속 추가 가능예시root@server # cat case_script.sh#!/bin/bashcase $1 in appl.. 2024. 4. 30.
unzip (압축 파일 해제 명령어) 00 개요리눅스 환경 터미널에서 .zip 압축 파일을 풀 수 있음01 unzip이란1. 정의lists and extracts files in zip archives.기본값으로 extracts zipfile entries to the current directory, creating directories as neededZip files do not store ownership info The extracted files are owned by the user that runs the commandYou must have write permissions on the directory where you are extracting the ZIP archive.2. 문법# 기본 문법unzip [-Z] optio.. 2024. 4. 29.
readonly (shell script 명령어) 01 readonly란1. 정의Shell 변수 (shell variable)를 설정할 때 설정된 값을 변경 불가능하게 하는 명령어 (Mark shell variables as unchangeable)즉, VAR=value 라고만 명시하면 VAR 값을 나중에 변경/삭제 가능하지만 readonly VAR=value 라고 명시하면 추후에 VAR 값 변경/삭제 불가능  Shell 변수란참조:  2024.04.30 - [Shell] - Shell 변수 (variable)Shell Script에서 어떤 데이터 종류(숫자, 문자, 파일명 등등)를 갖고 있던지 궁극적으로는 문자열 형태로 할당되는 변수2. 문법readonly [-aAf] [name[=value] ...]readonly -p3. 옵션An argument .. 2024. 4. 29.
if문 사용법 (shell script) 01 if 문 기본 사용법0. python과 비교# pythonif a == b: return 'a is equal to b'else: return 'a does not equal to b' # shellif [ a -eq b ];then echo 'a is equal to b'else echo 'a does not equal to b'fi 1. 기본 형식if 로 시작, fi로 끝맺힘if 다음 한칸 띄고 [ 넣고 한칸 띄고 값과 조건식을 넣고 한칸 띄고 ] [ ] 안에 값/조건식 앞뒤로 공백 없으면 스크립트 에러가 나므로 유의if [ 값1 조건식 값2 ];then 수행문fi if [ 값1 조건식 값2 ];then 수행문else 수행문fiif [ 값1 조건식 값2 ]then 수행문.. 2024. 4. 29.
nohup (터미널 끊겨도 proc 진행 시키는 명령어) 01 nohub이란1. 정의리눅스에서 프로세스 (process, proc)를 실행한 터미널 (terminal, tty)의 세션 연결이 끊어지더라도 프로세스를 계속해서 동작시키는 명령어 원래 리눅스에서는 터미널에서 ssh 세션 로그아웃(logout) 발생 시 해당 터미널에서 실행한 프로세스들에게 HUP signal을 전달하여 종료시키게 되는데 이 HUP signal을 프로세스가 무시(ignore)하도록 하고 프로세스들을 마치 데몬(daemon)인 것처럼 동작시키는 명령어라서 nohup 이라고 명명또한 nohup 명령어로 인해 백그라운드에서 실행된 프로세스들의 표준 출력(standard output)은 nohup.out 파일로 재지향(redirection)됨터미널이 종료되어도 표준 출력은 nohup.out .. 2024. 4. 29.
lsfstartup, lsfrestart, lsfshutdown (LSF 명령어) 01 lsfstartup1. 정의starts the LIM, RES, and sbatchd daemons on all hosts in the cluster (not including mbatchd???)2. 문법# lsfstartup -pdsh [-delay seconds] [-num_hosts number]# lsfstartup [-f]# lsfstartup [-h | -V]3. 설명can be only used by root or users who are listed in the lsf.sudoers filestart LIM, RES, and sbatchd daemons (이 순으로) on all hostswhen live configuration w/ the bconf command is enabl.. 2024. 4. 29.
rpm과 yum (패키지 설치 도구) 00 개요Linux 환경에서 설치를 하다 보면 .rpm, rpm, yum, repository, yum.repos.d, .repo 등 비슷한 용어들을 접할 것이다각 용어가 뭘 뜻하는지 정리하고자 한다01 용어0. .rpm.rpm은 어떤 소프트웨어의 패키지이다 contains the files in CPIO archive (similar to tar, just different format) and some info (e.g. which other packages it needs) and scripts which needs to be run when package is installed/upgraded/removed (those are automatically run by /usr/bin/rpm)1. re.. 2024. 4. 26.
YAML (프로그래밍 언어) 01 YAML이란'Yet Another Markup Language'의 약자'사람이 읽을 수 있는' 데이터 직렬화 언어구성 파일 (Configuration File)을 작성할 때 자주 사용되는 데이터 직렬화 언어 (data serialization language)xml 파일, json 파일도 사람이 읽을 수 있는데 yaml 파일은 어떻게 다른지 궁금하다면..!위와 같이 yaml 파일은 설정에서 필요한 spec과 property 값이 한 눈에 들어옴파일 작성도 다른 양식에 비해 매우 편리그러므로 많이 애용02 YAML 문법key: value 구성으로 작extension: .yml or .yaml has features that come from Perl, C, XML, HTML, and other pro.. 2024. 4. 26.