Linux 20

[gdb] gdb 에서 16진수 hex 값 출력하는 방법

gdb 에서 16진수 hex 값 출력하는 방법 gdb에서 core 파일을 분석할 때 16진수를 저장하는 변수는 윈도우 계산기를 함께 켜놓고 10진수로 출력된 값을 16진수로 변환하여 확인하고 있었다. 근데 이게 귀찮아서 찾아보니까 아주 쉬운 방법이 있었다. 기본적으로, gdb에서 변수 print를 수행하면 해당 변수의 데이터 유형에 따라 출력된다. x Regard the bits of the value as an integer, and print the integer in hexadecimal. d Print as integer in signed decimal. u Print as integer in unsigned decimal. o Print as integer in octal. t Print as ..

Back-End/Linux 2022.12.02

[Linux] 하이픈(`-`)으로 시작하는 파일 삭제하기

하이픈(-)으로 시작하는 파일 삭제하기 파일명이 하이픈(-)으로 시작하는 파일을 관리하려고 할 때, 그냥 단순히 처리하면 아래와 같은 에러가 발생한다. lyw@ /home/lyw/test # ls -al total 0 -rw-rw-r--. 1 lyw lyw 0 Oct 20 20:05 --test.txt lyw@ /home/lyw/test # rm --test.txt rm: unrecognized option '--test.txt' Try 'rm ./--test.txt' to remove the file '--test.txt'. Try 'rm --help' for more information. lyw@ /home/lyw/test # rm \-\-t..

Back-End/Linux 2022.10.25

[Linux] Ubuntu 20.04에 KVM 설치하기

Ubuntu 20.04에 KVM 설치하기 우분투 20.04에 KVM을 설치하는 방법 Step 1: 가상화 지원 여부 확인 다음 명령어로 프로세서(CPU)가 가상화 기능을 지원하는지 확인합니다. $ sudo apt update $ sudo apt install cpu-checker $ kvm-ok아래처럼 출력된다면 프로세서가 가상화를 지원하는 것입니다. INFO: /dev/kvm exists KVM acceleration can be usedStep 2: 요구 패키지 설치 다음 명령어로 KVM 설치에 요구되는 패키지들을 설치합니다. $ sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manag..

Back-End/Linux 2022.08.12

[Linux] bash 쉘 스크립트 특정 문자열이 포함되었는지 확인하는 방법

bash 쉘 스크립트 특정 문자열이 포함되었는지 확인하는 방법 # python 예시 str = "Hello world" if "world" in str : print("Found 'world' string.") else : print("Not Found 'world' string.") 쉘 스크립트에서는 어떤 문자열에 특정 문자열이 포함되어있는지 확인하고 싶을 때 어떻게 해야할까? 첫 번째 방법, 와일드카드(wildcard, asterisk(*)) 사용 if [[ "$str1" == *str2* ]]; then ... else ... fi #!/bin/bash str="Hello world" if [[ "$str" == *world* ]]; then echo "str conta..

Back-End/Linux 2022.06.22

[Linux] /lib, /lib64 의 심볼릭 링크를 삭제했을 때 해결 방법

/lib, /lib64 의 심볼릭 링크를 삭제했을 때 해결 방법 급하다면 https://code-examples.net/ko/q/bae9cb 여기를 참고해서 문제를 해결해보자. 참고 : /lib, /lib64 는 무슨 디렉토리? 시스템 부팅이나 /bin, /sbin 에 있는 바이너리 파일들의 실행에 필요한 공유 라이브러리 디렉토리이다. 문제 상황 /lib64/libc.so.6 (심볼릭링크) 가 /lib64/libc-2.12.so 를 바라보고 있었다. libc-2.17.so 로 버전을 변경해보고자 루트 계정에서 libc.so.6 심볼릭링크를 rm -rf 명령어로 삭제했다. 그리고 ln 명령어로 다시 심볼릭 링크를 생성하려고 하니까 [test:/lib64] rm -rf libc.so.6 [test:/lib6..

Back-End/Linux 2022.04.12

[Linux] wc 명령어 사용법(파일에서 문자, 라인수 세기)

wc 명령어 사용법 1. wc 명령어란? 'word count' 입력으로 받은 파일의 문자, 줄, 바이트를 출력해준다. wc - print newline, word, and byte counts for each file Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. With no FILE, or when FILE is -, read standard input. A word is a non-zero-length sequence of characters delimited by white space. The options below may be used to select..

Back-End/Linux 2021.11.02

[Linux] tcpdump 명령어 사용법(패킷 캡쳐)

tcpdump 명령어 사용법 tcpdump 명령어란? 위키백과 tcpdump는 CLI 환경에서 실행하는 일반적인 패킷 가로채기 소프트웨어이다. 사용자가 TCP/IP 뿐 아니라, 컴퓨터에 부착된 네트워크를 통해 송수신되는 기타 패킷을 가로채고 표시할 수 있게 도와준다. tcpdump 명령어 사용법 tcpdump [ -AbdDefhHIJKlLnNOpqRStuUvxX ] [ -B buffer_size ] [ -c count ] [ -C file_size ] [ -G rotate_seconds ] [ -F file ] [ -i interface ] [ -j tstamp_type ] [ -m module ] [ -M secret ] [ -P in|out|inout ] [ -r file ] [ -V file ] [..

Back-End/Linux 2021.10.06

[Linux] find 명령어 -exec 옵션 사용법(특정 파일 문자열 치환)

find 명령어 -exec 옵션 사용법(특정 파일 문자열 치환) find 명령어란? find 명령어 사용법 참고 -exec 옵션? -exec utility [argument ...] ; 검색된 파일들에 대해서 명령(utility) 실행find 명령어 사용법 문서에서는 위와 같이 간단하게만 적었다. 이 옵션은 find 명령어로 찾은 결과를 원하는 명령어에 적용시켜준다. -exec 옵션 사용법 find 조건 -exec 명령어 {} \; 실행시킬 명령어의 범위는 -exec 부터 \; 까지 {} 는 find 명령어로 찾은 결과 -exec 옵션 사용 예시 (다양한 예시는 리눅스 백과사전 - [리눅스] find 명령어 실습 를 참고.) 특정 파일에서 문자열을 치환하는 방법을 찾아보다가 find 명령어와 perl을 ..

Back-End/Linux 2021.10.05

[Linux] bash 쉘 스크립트 배열(Array) 사용법

bash 쉘 스크립트 배열(Array) 사용법 배열 선언하는 방법 #!/bin/bash arr_1=("abc" "123" "456" ) arr_2=(1 2 3) arr_3[0]=1 arr_3[1]=2 echo ${arr_1[0]} # abc echo ${arr_2[1]} # 2 echo ${arr_3[1]} # 2 이외에, 아래와 같이 빈 배열을 선언하고 요소를 하나씩 추가하는 방법도 있다. #!/bin/bash arr=() arr+=("abc") arr+=("123") arr+=("456") 배열 참조하는 방법 #!/bin/bash arr=("Lee YW" "Array" "Test") # - 개별 요소 참조 echo "arr[0] = ${arr[0]}" # - 전체 요소 참조 echo "arr[*] =..

Back-End/Linux 2021.07.28

[Linux] find 명령어 사용법

find 명령어 사용법 find 명령어란? walk a file hierarchy 특정 조건을 만족하는 파일들을 찾을 때 사용한다. find 명령어 사용법 find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]아무것도 없이 명령어만 실행하면 현재 디렉토리 하위의 모든 디렉토리 및 파일을 출력해준다. find 명령어 옵션 옵션 너무 많다 -empty 빈 디렉토리나 크기가 0인 파일 검색 -ctime n[smhdw] (change time) 파일의 내용 및 속성이 변경된 시간을 기준으로 파일 검색 -exec utility [argument ...] ; 검색된 파일들에 대해서 명령(utility) 실행 -name pattern 이름이 pattern에 해당하..

Back-End/Linux 2021.07.27
728x90
반응형