환경 변수
- 환경변수 값 확인 $echo $SAMPLE (윈도우 – echo % SAMPLE%) – 전체 환경변수 내용 출력 $env (윈도우 – set)
- – 환경변수 자동설정 일반적인 우분투의 경우 : 홈 디렉토리의 ~.bashrc나 ~ /.profile에 export SAMPLE=test와 같이 지정한 후 source~ /.bashrc나 source~ /.profile로 환경변수에 반영
- $nano $HOME/.bashrc 파일의 맨 마지막에
- export SAMPLE=/test 라인 추가하고 control-O/control-X 순서대로 눌러 저장 & 탈주
- $ source $HOME/.bashrc$echo $SAMPLE 하고 환경변수 지정 확인
- 도커에서는 .bshrc나 .profile이 자동으로 실행 x$dockerrun–env SAMPLE=test–name=ubuntu1ubunt
- – DockerfileENV SAMPLE=test – 환경 변수 확인 echo $SAMPL 쉘 사용법
- Linux에서의 파일 편집
- – 윈도우/맥으로 파일을 만들어 업로드 : vscode, eclipse, ultraedit, atom, … – vi/vim-emacs – 우분투 : nano(CLI)/gredit(GUI)-touch
- touch (빈 파일 (길이 0) 생성) #touch smaple.txt
- sed (문자열대체)# nano sample.txt // sample.txt에 2줄입력 GoodmpringVery Good
- $ sed’s / Good / Great / g’s ample.txt // Good를 찾아서 Great으로 바꿈 (범위: / g’ (모두)) Great Morning Very Great
- $cat sample.txt // 원본 파일은 바뀌지 않았음을 알 수 있다 Good Moring Very Good
- $ sed – i ‘ s / Good / Great / g ‘ sample . txt // 실제 파일을 변경 Great MoringVery Great
- $ sed’s/^Great/Good/g’s ample.txt // 행 맨 앞에 있는 Great을 Good로 대체한 Good Morning Very Great
- $sed’s/Great $/Good/g’s ample.txt // 행 맨 뒤에 있는 Great을 Good로 대체하여 Great Moring Very Good
- 심볼릭 링크(윈도우 바로가기에 해당) ln-s 원본폴더/파일링크명
- # In – s sample . txt sampl – link . txt
- # ls – allrwxrwxrwx 1 sample sample 10 Nov 2 07 : 15 sample – link . txt – > sample . txt
- # rm sample – link . txt
- 계정 생성 #cat/etc/passwd…sample:x:1000:,,:/home/sample:/bin/bash…
- # cat / etc / group … sample : x : 1000 : …
- # cd / home # ls
- 계정삭제(sudo)deluser-rf xxxxxx
- – r : remove (계정뿐만 아니라 안에 있는 폴더도 삭제) – f : by force (강제)
- # deluser sample # su samplesu : user sample does not exist
- # cd / home # ls
- su ( switch user ) su xxxx
- # su sample # sudo ls
- sudo/sudoer_root 계정으로 바꾸지 않고 root 권한 이용 sudo 명령 그룹 추가 (하지 않으면 sudo는 사용 가능) #usermod-aG sudo xxxxxxxx
- # usermod – aG sudo sample # su sample # sudo ls
- 비밀번호 번경-passwd-passwd $xxxxxxx
- usermod
- groups / id
- Group 관련 – 그룹 작성 : groupadd 그룹명 – 사용자 그룹 추가 : usermod – a – G 그룹명 사용자명 – 폴더 그룹 소유권 변경 : chown 소유자 : 그룹 폴더명 – 폴더권한(rwx) 변경 : chmodxx 폴더명