Back-End/Linux 27

[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] hostname(domain)을 alias 설정하는 방법(gethostbyname)

hostname(domain)을 alias 설정하는 방법 /etc/hosts 를 이용하면 IP를 domain과 연결해줄 수 있다. # /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.0.15 realdomain 위 내용은 fakedomain 이라는 도메인이 192.168.0.15 IP에 연결되어있다는 의미이다. 그렇다면 fakedomain 이라는 도메인을 realdomain 과 연결하고 싶다면 어떻게 해야할까? 방법 1 로컬 DNS 서버를 구축해서 CNAME..

Back-End/Linux 2022.10.28

[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

[CentOS] GUI에서 Shell Script를 더블클릭으로 실행하기

CentOS 7 GUI에서 Shell Script를 더블클릭으로 실행하기 Shell Script를 작성하고 실행할 때, 보통 터미널에서 ./script.sh 와 같이 실행한다. GUI를 사용하고 있다면 윈도우나 맥에서처럼 더블클릭으로 실행하려 해도 자꾸만 텍스트 편집기가 열리게 된다. 스크립트를 바로 실행하거나, 터미널에서 실행하게끔 하고 싶으면 [프로그램] - [보조 프로그램] - [파일] 실행 후 파일로 커서가 잡힌 상태에서 상단바에서 [파일] - [기본 설정] - [동작] - [해당 사항 실행] 또는 [어떻게 할지 물어보기] 로 설정해주면 된다.

Back-End/Linux 2022.03.29

[Linux] IPC 관련 명령어 사용법(ipcs, ipcrm)

IPC 관련 명령어 사용법(ipcs, ipcrm) IPC (Inter-Process Communication) 프로세스 간 통신 프로세스들 사이에 서로 데이터를 주고받는 행위 또는 그에 대한 방법이나 경로를 뜻한다. 여러 IPC 방식이 있지만, ipcs/ipcrm 명령어에서 확인 가능한 자원은 메시지큐(Message Queue), 공유메모리(Shared Memory), 세마포어(Semaphore)이다. 1. ipcs 명령어란? IPC 자원에 대한 정보를 제공한다. ipcs 명령어 사용법 ipcs [resource-option] [output-format] ipcs [resource-option] -i id ipcs 명령어 옵션 OPTIONS -i, --id id Print details only on t..

Back-End/Linux 2021.11.05

[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
728x90
반응형