전체 글 154

Linux , caller (호출자) 가 누구인지 아는 방법

어떤 함수 a() 가 다양한 프로세스에 의에 빈번하게 호출 된다면, log 로 남길 때, 누가 본인을 호출 했는지 확인 하고자 하는 경우가 있다. 실험 환경은 Ubuntu Linux 5.3.1 계열의 x86_64 아키텍쳐 이다. backtrac 를 사용하는 예) #include #include #include #include int nptrs; void *buffer[BT_BUF_SIZE]; char **strings; nptrs = backtrace(buffer, BT_BUF_SIZE); rintf("backtrace() returned %d addresses\n", nptrs); strings = backtrace_symbols(buffer, nptrs); if (strings == NULL) { p..

Linux_system 2022.12.09

apue.3e 컴파일 하기

Advanced Programming in the UNIX Environment Thrd Edition 의 예제를 compile 하려면 다음과 같이 하면 된다. Source code download : https://github.com/vdpa4me/apue.git vdpa4me/apue Example of Advanced Programming in the UNIX Environment - vdpa4me/apue github.com /apue/apue.3e/lib 로 이동한다. Makefile 을 editor 로 열어서, 아래 부분을 수정한다. PLATFORM=$(shell $(ROOT)/systype.sh) 부분을 PLATFORM=linux 로 변경한다. (systype.sh 실행시 permission..

Linux_system 2022.12.09

User ID/Group ID

ls -l 로 출력 되는 항목을 보면 , 다음과 같이 카테고리를 나눌 수 있다. ben@ben-ubuntu-server:~/share/apue_github/apue/ben$ ls -l total 180 -rw-rw-r-- 1 ben ben 21 Jun 15 08:14 data -rwxrwxr-x 1 ben ben 17632 Jun 17 02:26 fig1_3 -rw-rw-r-- 1 ben ben 397 Jun 15 07:21 fig1_3.c 1) 파일 유형. '-' 는 일반파일, 'd'는 디렉토리, 'b' 는 블록 디바이스, 'c'는 문자 디바이스, 'I'는 링크를 뜻한다. 2) 허가권 'r' 은 read able , 'w' 는 write able , 'x' sms execute able 이다. 3자리씩..

Linux_system 2022.12.09

POSIX.1 이 뭐지?

OSIX (Portable Operating System Interface) 1003.1 operating system interface standard 만약 어떤 운영체제가 "POSIX compliant" 하다면, 반드시 제공해야 하는 service 들을 정의 한것이 1003.1 operating system interface standard 이다. 대부분의 computer vendor 들이 이 standard 를 채용 했다 해당 문서는 계속 진화해 왔다. IEEE Standard 1003.1-1988 IEEE Standard 1003.1-1990 (Insternational Standard ISO/IEC 9945-1:1990) 이 1003.1-1990을 일반적으로 POSIX.1 이라고 한다.

Linux_system 2022.12.09

netplan 고정 IP 설정시, 서브넷 마스크 작성법

netmask 255.255.255.0 게 어떻게 24가 되는가? netmask 를 모두 2진수로 변경한 다음 , 왼쪽에서 부터 1이 모두 몇개인지 쓴다. 예) 255.255.255.0 = 11111111.11111111.11111111.00000000 = 8 + 8 + 8 + 0 = 24 255.255.254.0 = 11111111.11111111.11111110.0 = 8+8+7+0 = 23 ## 참조 ## netplan 설정하는 방법: https://blog.dalso.org/article/ubuntu-20-04-lts-nework Ubuntu 20.04 LTS 네트워크 연결하기.(고정IP 할당) - 달소씨의 하루 Connection failed Activation of network connect..

Linux_system 2022.12.09

C/C++ 에서 실행 시간을 측정하는 8가지 방법

https://levelup.gitconnected.com/8-ways-to-measure-execution-time-in-c-c-48634458d0f9 8 Ways to Measure Execution Time in C/C++ Unfortunately, there isn’t a one-size-fits-all solution. Here you will find some of the available options. levelup.gitconnected.com 참조는 위와 같으며, 혹시 page 가 삭제될 경우를 대비하여, 코드를 다시 복사 함 #include #include int main () { double sum = 0; double add = 1; // Start measuring time au..

Linux_system 2022.12.09

c# sftp 사용 ubuntu 로 file 전송

해당 프로그램은 Windows 10 위에서 실행되는 C# 으로 만들어진 sftp client 로, Ubnunt 에서 실행되는 sftp server 로 접속하여, Windows 에서 Ubuntu 로 file을 전송한다. using Renci.SshNet; using Renci.SshNet.Sftp; //IP, Port, ID, PW using (SftpClient client = new SftpClient("111.111.111.111", 22, "root", "root")) { client.KeepAliveInterval = TimeSpan.FromSeconds(60); client.ConnectionInfo.Timeout = TimeSpan.FromMinutes(180); client.Operation..

C# ping program

해당 프로그램은 Windows 10 위에서 실행되는 C# 으로 만들어진 프로그램에서 , 외부 OS에 ping 으로 보내, network 연결을 확인하는 프로그램 입니다. try { Ping ping = new Ping(); PingOptions options = new PingOptions(); options.DonFragment = true; string data = "Hello World!"; byte[] buffer = ASCIIEncoding.ASCII.GetBytes(data); int timeout = 120; PingReply reply = ping.Send(IPAddress.Parse("111.111.111.111"), timeout, buffer, options); if (reply.St..