묻고 답해요
130만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨시스템엔지니어가 알려주는 리눅스 실전편 Bash Shell Script
백업 스크립트 질문입니다
안녕하세요 2-5강에서 백업 쉘스크립트 강의를 듣고 스크립트를 작성했는데 실행해보니 아무일도 일어나지 않고 대기만 되는 상황이에요 ㅜㅜ 디버깅 옵션을 주고 실행하니이곳에서 멈추는데 제가 어떤걸 잘못한걸까요? ㅠㅠ 아래는 작성한 스크립트 입니다#!/bin/bash -x## 변수 설정HOST="$(/usr/bin/hostname)"LOG="/tmp/backup.log"PUSH="/vagrant/SHELL/backup/telegram.sh"DATE="$(/bin/date +%Y.%m.%d)"BAK_LIST="/etc/nginx /usr/share/nginx/html/www" #백업할 파일BAK_PATH="/mnt/BACKUP/${HOST}" #백업파일 저장할 디렉토리BAK_FILE="${BAK_PATH}/${DATE}_${HOST}.tgz" #백업파일명## 스토리지에 마운트/usr/bin/mount /mnt## 로그파일 생성/usr/bin/touch "${LOG}"## 백업 디렉토리 확인if [ -e "${BAK_PATH}" ]then /bin/echo "백업 디렉토리가 있어요!"else /usr/bin/mkdir -p "${BAK_PATH}"fi## ----로그기록 시작{ /bin/echo /bin/echo "=== backup start :" /bin/date /bin/echo ## 백업 /usr/bin/tar czpPf "${BAK_FILE}" ${BAK_LIST} ## 백업파일 정보NAME="$(/usr/bin/ls -al "${BAK_FILE}" | awk '{print $9}')" SIZE="$(/usr/bin/ls -al "${BAK_FILE}" | awk '{print $5}')" /bin/echo "=== backup info: " /bin/echo " | filename: ${NAME}" /bin/echo " | filesize: ${SIZE}Byte" /bin/echo /bin/echo /bin/echo "=== backup success :" /bin/date /bin/echo}>|"${LOG}"## ----로그 기록 끝## 스토리지에 언마운트/usr/bin/umount /mnt## 텔레그램으로 백업 로그 전송"${PUSH}" "${HOST}" "$(/usr/bin/cat "${LOG}")"## 로그 파일 삭제/usr/bin/rm -f "${LOG}"
-
미해결리눅스 쉘 스크립트 마스터
하드 링크, 심볼릭 링크
안녕하세요. 강의 잘 보고 있습니다. 강의 시청 중 궁금한 점이 몇가지 있습니다.하드 링크는 파일 복사라고 생각하면 되나요..?그렇다면 cp 명령어가 있는데 하드링크를 사용하는 이유는 무엇인가요?심볼릭 링크 생성시 권한이 rwx가 모두 생기는데.. 바로가기 폴더라고하면 원본 폴더의 권한을 따라가야하는거 아닐까요..?만약 10바이트를 가진 A라는 파일을 하드링크하여 B라는 파일을 생성하면 총 20바이트의 사이즈를 차지할 것이라고 생각했는데 맞을까요?3의 예시에서 B를 하드링크가 아닌 심볼릭링크로 생성하게 되면 노출되는 사이즈는 A,B 모두 10바이트로 표현은 되지만 실제 사이즈는 10바이트만 차지하는게 맞을까요?? (링크만 걸어놓은거기때문에)답변 부탁드립니다. 감사합니다!
-
미해결리눅스 필수 유틸리티 4종 마스터 - awk, sed, grep, find
Mac 터미널 정규식 인식 오류
grep 은 잘되는데 정규식을 이용하면 아래와 같이 패턴검색이 안되는데 원인을 모르겠습니다. zsh: no matches found: [hH]ello
-
해결됨시스템엔지니어가 알려주는 리눅스 실전편 Bash Shell Script
VSCode나 Putty로 서버에 원격접속하려면 어떻게 환경을 구성해야하나요?
안녕하세요? 먼저, vagrant를 사용할 수 없어 N. vagrant를 사용하지 않고 구축할 수 있는 실습환경을 참고하여 실습환경을 구축했습니다.하지만 제가 리눅스 서버로 원격 접속하여 과제를 한 경험이 많아서 이번에도 그렇게 하고 싶은데 configuration에서 애를 먹는 중이에요.VSCode에서 ssh 원격접속을 위해서는 ~/. ssh/config 파일에 host를 새로 추가해야하는데HostName을 cent1의 경우 192.168.56.1로 하는게 맞는지 확실하지가 않습니다. 주석 친 172.18.1.91로는 connection timed out이 뜹니다.그리고 개인 비밀키인 IdentityFile은 https://github.com/bashbomb/VWS_vagrant_script/blob/master/CONF/ssh/id_rsa 에서 받았는데깃허브의 authorized_keys와 cent1 vm의 authorized_keys가 서로 달라서 깃허브의 ssh 설정이 제 로컬 환경에서 그대로 사용가능한 것인지 모르겠습니다.VSCode terminal로 원격접속을 시도하면 아래와 같은 메시지가 나옵니다. 아마 IdentityFile로 지정한 개인 키가 vm 서버의 authorized_keys 공개키로 검증이 되지 않는 것 같은데 그렇다면 어떤 개인 키를 사용해야될까요? 혼자서 해결이 되지 않아 도움 부탁드립니다.
-
해결됨시스템엔지니어가 알려주는 리눅스 실전편 Bash Shell Script
permission dany가 떠요
git clone https://github.com/bashbomb/VWS_vagrant_script.git 입력했는데 저렇게 뜨네요 어떻게 해야하나요
-
미해결시스템엔지니어가 알려주는 리눅스 실전편 Bash Shell Script
m1 지원
안녕하세요.얼마전 virtualBox Beta 이긴 하지만 드디어 m1을 지원하기 시작했는데요.혹시 여기에 맞춰져서 실습을 진행하는방법이 있을까요?
-
해결됨시스템엔지니어가 알려주는 리눅스 기초편 Bash Shell Script
실습환경에 대한 문의 드립니다.
리눅스는 상용 버전에 따라 명령어가 달라질 수 있다고 알고있습니다.해당 강의에서 배울 명령어들은 리눅스 상용 버전에 다 사용이 가능한 명령어들인가요?그리고 실습환경을 웹이서 구동되는 Linux를 알려주셨는데 저는 직접 설치해서 사용하고자 합니다.어떤 리눅스를 설치하면 강의 듣는데 문제가 없을지 확인 부탁드립니다.감사합니다.
-
해결됨시스템엔지니어가 알려주는 리눅스 실전편 Bash Shell Script
vagrant up 실행 중 에러
안녕하세요, 윈도우10 환경에서 2-1 서버 구축 강의를 보며 진행 중 오류가 발생해 문의 드립니다. 실행 로그는 아래와 같습니다. $ vagrant upBringing machine 'cent1' up with 'virtualbox' provider...Bringing machine 'cent2' up with 'virtualbox' provider...Bringing machine 'cent3' up with 'virtualbox' provider...==> cent1: Preparing master VM for linked clones... cent1: This is a one time operation. Once the master VM is prepared, cent1: it will be used as a base for linked clones, making the creation cent1: of new VMs take milliseconds on a modern system.==> cent1: Importing base box 'rockylinux/8'...==> cent1: Cloning VM...==> cent1: Matching MAC address for NAT networking...==> cent1: Checking if box 'rockylinux/8' version '5.0.0' is up to date...==> cent1: Setting the name of the VM: cent1==> cent1: Clearing any previously set network interfaces...==> cent1: Preparing network interfaces based on configuration... cent1: Adapter 1: nat cent1: Adapter 2: hostonly cent1: Adapter 3: hostonly==> cent1: Forwarding ports... cent1: 22 (guest) => 2222 (host) (adapter 1)==> cent1: Running 'pre-boot' VM customizations...==> cent1: Booting VM...==> cent1: Waiting for machine to boot. This may take a few minutes... cent1: SSH address: 127.0.0.1:2222 cent1: SSH username: vagrant cent1: SSH auth method: private key cent1: cent1: Vagrant insecure key detected. Vagrant will automatically replace cent1: this with a newly generated keypair for better security. cent1: cent1: Inserting generated public key within guest... cent1: Removing insecure key from the guest if it's present... cent1: Key inserted! Disconnecting and reconnecting using new SSH key...==> cent1: Machine booted and ready![cent1] No Virtualbox Guest Additions installation found.The guest's platform ("rocky") is currently not supported, will try generic Linux method...Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.isoMounting Virtualbox Guest Additions ISO to: /mntmount: /mnt: WARNING: device write-protected, mounted read-only.Installing Virtualbox Guest Additions 6.1.36 - guest version is unknownVerifying archive integrity... All good.Uncompressing VirtualBox 6.1.36 Guest Additions for Linux........VirtualBox Guest Additions installerCopying additional installer modules ...Installing additional modules .../opt/VBoxGuestAdditions-6.1.36/bin/VBoxClient: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory/opt/VBoxGuestAdditions-6.1.36/bin/VBoxClient: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directoryVirtualBox Guest Additions: Starting.VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernelmodules. This may take a while.VirtualBox Guest Additions: To build modules for other installed kernels, runVirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version>VirtualBox Guest Additions: orVirtualBox Guest Additions: /sbin/rcvboxadd quicksetup allVirtualBox Guest Additions: Kernel headers not found for target kernel4.18.0-348.20.1.el8_5.x86_64. Please install them and execute /sbin/rcvboxadd setupmodprobe vboxguest failedThe log file /var/log/vboxadd-setup.log may contain further information.An error occurred during installation of VirtualBox Guest Additions 6.1.36. Some functionality may not work as intended.In most cases it is OK that the "Window System drivers" installation failed.Redirecting to /bin/systemctl start vboxadd.serviceJob for vboxadd.service failed because the control process exited with error code.See "systemctl status vboxadd.service" and "journalctl -xe" for details.Got different reports about installed GuestAdditions version:Virtualbox on your host claims:VBoxService inside the vm claims: 6.1.36Going on, assuming VBoxService is correct...Redirecting to /bin/systemctl start vboxadd-service.serviceJob for vboxadd-service.service failed because the control process exited with error code.See "systemctl status vboxadd-service.service" and "journalctl -xe" for details.Unmounting Virtualbox Guest Additions ISO from: /mntGot different reports about installed GuestAdditions version:Virtualbox on your host claims:VBoxService inside the vm claims: 6.1.36Going on, assuming VBoxService is correct...Got different reports about installed GuestAdditions version:Virtualbox on your host claims:VBoxService inside the vm claims: 6.1.36Going on, assuming VBoxService is correct...Got different reports about installed GuestAdditions version:Virtualbox on your host claims:VBoxService inside the vm claims: 6.1.36Going on, assuming VBoxService is correct...Restarting VM to apply changes...==> cent1: Attempting graceful shutdown of VM...==> cent1: Booting VM...==> cent1: Waiting for machine to boot. This may take a few minutes...==> cent1: Machine booted and ready!==> cent1: Checking for guest additions in VM... cent1: No guest additions were detected on the base box for this VM! Guest cent1: additions are required for forwarded ports, shared folders, host only cent1: networking, and more. If SSH fails on this machine, please install cent1: the guest additions and repackage the box to continue. cent1: cent1: This is not an error message; everything may continue to work properly, cent1: in which case you may ignore this message.==> cent1: Setting hostname...==> cent1: Configuring and enabling network interfaces...==> cent1: Mounting shared folders... cent1: /vagrant => C:/playground/VWS_vagrant_scriptVagrant was unable to mount VirtualBox shared folders. This is usuallybecause the filesystem "vboxsf" is not available. This filesystem ismade available via the VirtualBox Guest Additions and kernel module.Please verify that these guest additions are properly installed in theguest. This is not a bug in Vagrant and is usually caused by a faultyVagrant box. For context, the command attempted was: mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant The error output from the command was: /sbin/mount.vboxsf: mounting failed with the error: No such device 어떻게 하면 수정하여 환경 구축할 수 있을지 알고 싶습니다. 감사합니다.
-
해결됨시스템엔지니어가 알려주는 리눅스 기초편 Bash Shell Script
강의를 초반을 듣는중에 궁금한점이 있어 문의드립니다.
강의에서 vagrant 를 이용하는데 따로 설치파일을 제공하거나 아님 설치에 대한 영상이 있을까요 ?
-
해결됨시스템엔지니어가 알려주는 리눅스 기초편 Bash Shell Script
bash와 zsh은 어느 정도의 차이가 나나요?
bash와 zsh이 어느 정도의 차이가 나고, 학습해야 할 분량이 어느 정도 되는지 궁금합니다. ------------------ 강의에서는 zsh이 언급이 되어있지 않았지만 Mac OS나 다른 고급 사용자들은 zsh도 같이 사용한다는 자료를 보았습니다. ( 강의 화면 맨 위에도 zsh이라는 문구가 있네요. ) 제가 알아본 바로는 부모가 같은 '셸'이기에 둘이 매우 유사하다고는 하는데 학습자 입장에서는 얼마나 차이가 나고, 실무에서 얼만큼 사용되는지 가늠이 안되네요. bash 사용만 숙달 시킨다면 zsh은 유사도가 크기 때문에 따로 크게 시간을 투자해서 공부할 필요가 없다고 생각하면 되나요? ( 만약 잘못된 점이 있다면 피드백 부탁드립니다. 감사합니다. )
-
해결됨시스템엔지니어가 알려주는 리눅스 기초편 Bash Shell Script
웹 리눅스 환경으로만 진행해야 하나요?
웹 리눅스 환경(JSLinux, codeonweb)으로만 진행해야 하나요? 여차저차 유튜브 영상 보면서 WSL로 우분투 설치를 한 상태인데 둘이 크게 다른지 궁금하여 물어봅니다...( 일단, WSL으로 구동한 상태로 강의 수강 진행하다가 문제가 생기면 바꿔 보겠습니다. )
-
해결됨시스템엔지니어가 알려주는 리눅스 기초편 Bash Shell Script
mount에 대해서 질문드립니다.
mount 학습중에 질문이 있습니다. 예를들어 하나는 aws 환경의 EC2 인스턴스환경이고 또다른환경은 제가 따로 사용하는 리눅스 서버의경우 mount 를 사용할수있나요? (또다른환경은 제 로컬에 인스톨한 리눅스 또는 또다른 클라우드 리눅스 서버입니다.)
-
미해결시스템엔지니어가 알려주는 리눅스 실전편 Bash Shell Script
http://172.18.1.91/www/index.html 접속이 안되는데 왜 안되는 거죠 ??
http://172.18.1.91/www/index.html 접속이 안되는데 왜 안되는 거죠 ??
-
해결됨시스템엔지니어가 알려주는 리눅스 기초편 Bash Shell Script
쉘 스크립트 안에서
awk_chk.awk 파일의 내용을 쉘 스크립트로 작성해보려고 노력해봤습니다. 결론부터 말하자면 정상적으로 결과값이 출력되기는 하는데 변수에 조금 더 간단하게 식을 넣을 수 있는 방법이 없을까요? 감사합니다 #!/bin/bash PER=${1} if [[ ${#} -ne 1 ]]; then echo -e "해당 스크립트 사용방법\n${0} [PERCENT ( 1 ~ 100 % )]" exit 1 fi if [[ ${PER} -gt 100 ]] || [[ ${PER} -lt 0 ]]; then echo -e "PERCENT : 1 ~ 100\n다시 입력해주세요" exit 1 fi if [[ ${PER} =~ [^0-9] ]]; then echo -e "DISK PERCENT를 입력해주세요 [ 1 ~ 100 ]" exit 1 fi DISK_LISTS=($(df -h | awk '{gsub(/%/,""); print $5}' | grep -vi 'use')) MNT=($(df -h | awk '{gsub(/%/,""); print $6}' | grep -vi "mounted" )) for idx in "${!DISK_LISTS[@]}"; do disk="${DISK_LISTS[${idx}]}" mount="${MNT[${idx}]}" if [[ $disk -ge ${PER} ]]; then echo -e "${disk}\t${mount}\n" fi done
-
해결됨시스템엔지니어가 알려주는 리눅스 기초편 Bash Shell Script
쉘 스크립트 작성해보았습니다
GOAL=$[ ${RANDOM}% 100+1 ] # OR GOAL=$((${RANDOM}% 100+1)) loop=true COUNT=1 while [ "${loop}" ]; do # 입력 기회 20번으로 제한 if [[ ${COUNT} -eq 21 ]]; then echo "아쉽네요, 다음 기회에 !" break fi read -p "1~100 까지의 숫자를 입력해보세요 (게임 종료 : 'q') : " num # 사용자가 'q'를 누른 경우 if [[ ${num} = "q" ]]; then echo "게임이 종료됩니다" echo"" break fi # 입력된 값이 없는경우 if [[ ! ${num} ]]; then echo "숫자가 입력되지 않았습니다! 다시 입력해주세요" echo "" fi # 지정된 범위를 초과하는 경우 if [[ ${num} -gt 100 ]]; then echo "숫자가 너무 커요! 다시 입력해주세요 (1 ~ 100)" echo "" continue elif [[ ${num} -lt 0 ]]; then echo "숫자가 지정된 범위보다 작습니다 (1 ~ 100)" echo "" continue fi # 숫자가 아닌 값이 입력 되었을 경우 if [[ ${num} =~ [^0-9]$ ]]; then echo -e "입력된 값이 숫자가 아닙니다!\n입력하신 값 : ${num}" continue fi # 숫자 비교 if [[ ${num} -gt ${GOAL} ]]; then echo -e "입력 값이 더 커요 ! \n남은 기회 : $((20 - ${COUNT}))" elif [[ ${num} -lt ${GOAL} ]]; then echo -e "입력 값이 더 작아요 ! \n남은 기회 : $((20 - ${COUNT}))" elif [[ ${num} -eq ${GOAL} ]]; then echo "축하합니다! 총 ${COUNT}번 만에 맞추셨어요!" break fi ((COUNT+=1)) # ((COUNT=COUNT + 1 )) , $((COUNT+=1)) , $[ COUNT+=1 ] done 선생님 강의 너무 재밌어요 시간만 있다면 실전편까지 하루종일 들어버리고 싶어요
-
미해결시스템엔지니어가 알려주는 리눅스 실전편 Bash Shell Script
강의 교재를 공유해주실 수 있을까요?
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요? 제가 리눅스 강좌를 수강하고 있습니다. 리눅스 기초편과 활용편으로 듣고 있는데 강사님께서 강의하시는 교재가 있을까요? 가능하다면 공유해주시면 고맙겠습니다. 건강 조심하십시오. 감사합니다.
-
미해결리눅스 쉘 스크립트 마스터
book이 변수가 아니라 파일인가요?
안녕하세요 쉘스크립트 강의 잘 듣고있습니다! 궁금한점이 있는데요, book="The old man and the sea.mp3"가 파일을 생성한건가요? 뒤에있는 내용보면 변수를 생성한 것 같은데, 파일이라 하셔서요. 그리고 똑같이 따라했지만 저는 ls 조회시 "The old man and the sea.mp3"라는 이름의 파일이 존재하지 않고, 파일이 없으니 삭제되지도 않습니다. 선생님과 제 결과가 다른 이유가 무엇일까요?
-
미해결시스템엔지니어가 알려주는 리눅스 기초편 Bash Shell Script
이전 강의에서도 나온거였는데... 어떻게 하는지 궁금해서 여쭤봅니다
대화실 쉘 스크립트 강의에서 11:18초 쯤에 쉘의 작성 내용을 비주얼블럭으로 블럭을 씌운뒤 한번에 주석처리하시는 부분이 있는데 이건 어떻게 하는건가요?? 제가 해볼려고 했을때는 자꾸 블럭이 풀리네요
-
미해결리눅스 쉘 스크립트 마스터
true 가 0인가요??
3분 40초 쯤에 설명하실 때, true = 0, false = 1 이라고 말씀 하셨는데, C++, java 등의 컴퓨터 언어에선 true=1, false=0 으로 사용하고 있잖아요. 쉘 스크립트 에서만 true = 0 인 건가요?