vi 기본 탭 사이즈는 8이다.

:set tabstop=4
:set shiftwidth=4

명령모드에서 'set tabstop=4' 를 입력해서 탭 크기를 조절한다. shiftwidth 로 들여쓰기할 때 크기를 조절한다.

$ vi ~/.vimrc
set tabstop=4
set shiftwidth=4

계정에 설정하고 싶으면 홈 디렉토리의 .vimrc 파일(~/.vimrc)에 위와 같이 설정하자.

출처 : https://www.lesstif.com/system-admin/vim-tab-space-4-18220149.html

 

vim 에서 tab 을 space 4개로 처리하게 설정하기

 

www.lesstif.com

 

728x90
$ tail -f log.csv
2022-03-19 1:21 | WARN | warning
2022-03-19 1:21 | WARN | warning
2022-03-19 1:22 | FATAL | fatal
2022-03-19 1:23 | ERROR | error
2022-03-19 1:24 | INFO | info
2022-03-19 1:25 | WARN | warning
2022-03-19 1:22 | FATAL | no fatal
2022-03-19 1:23 | ERROR | no error^Z
[1]+  Stopped                 tail -f log.csv

shell 에서 프로세스 실행 중에 멈추려면 Ctrl + Z 를 입력한다.

$ fg
tail -f log.csv

멈췄던 프로세스로 돌아가려면 fg 를 입력한다.

$ bg
[1]+ tail -f log.csv &

bg 를 입력하면 백그라운드로 돌아간다.

$ ps -aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user        77  0.0  0.0   7272   512 pts/0    S    23:47   0:00 tail -f log.csv
user        82  0.0  0.0  10860  3320 pts/0    R+   23:50   0:00 ps -aux
$ kill -STOP 77

[1]+  Stopped                 tail -f log.csv

pid 로 멈추고 싶으면 'kill -STOP' 을 이용한다.

$ kill -CONT 77

pid 로 다시 실행하고 싶으면 'kill -CONT' 를 이용한다.

$ kill -9 77
[1]+  Killed                  tail -f log.csv

강제 종료는 'kill -9' 을 이용한다.

출처 : https://stackoverflow.com/questions/27844970/how-to-pause-resume-a-process-in-linux

 

How to Pause/Resume a process in Linux

I record my program until it closes. Start Command: cvlc screen:// --screen-left=0 --screen-top=0 --screen-width=1280 --screen-height=960 --screen-fps=30 \ --sout '#transcode{vcodec=mp2v, vb=800,...

stackoverflow.com

 

728x90

현재 커밋할 내용을 이전에 커밋한 내용에 합치고 싶을 때는 Amend Last Commit 을 체크하면 된다.

이전에 commit 한 것들을 합치고 싶을 때는 log 창을 띄워서 'Combine to one commit' 을 선택하면 된다.

아니면 rebase 를 선택한 후 합칠 대상을 Squash 로 선택하면 된다.

출처 : https://nochoco-lee.tistory.com/314

 

52.1: TortoiseGit : 커밋들 squash 하기

본 문서는 Git Notes for Professionals (라이센스:CC-BY-SA) 를 한글로 번역한 문서입니다. 번역상 오류가 있을 수 있으므로 정확한 내용은 원본 문서를 참고하세요. Section 52.1: TortoiseGit : 커밋들 squash 하기

nochoco-lee.tistory.com

 

728x90
uint64_t a{ 0 };
printf("%llu", a);

MSVC 에서 uint64_t 형식을 printf 로 출력하려면 %llu 를 사용한다.

ConsoleApplication1.cpp: In function ‘int main()’:
ConsoleApplication1.cpp:10:16: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   10 |     printf("%llu", a);
      |             ~~~^   ~
      |                |   |
      |                |   uint64_t {aka long unsigned int}
      |                long long unsigned int
      |             %lu

하지만 g++ 로 컴파일 하면 바로 format 관련 경고가 뜬다. 

typedef signed char        int8_t;
typedef short              int16_t;
typedef int                int32_t;
typedef long long          int64_t;
typedef unsigned char      uint8_t;
typedef unsigned short     uint16_t;
typedef unsigned int       uint32_t;
typedef unsigned long long uint64_t;

MSVC 에서는 uint64_t 를 unsigned long long 으로 선언한 반면 g++ 에서는 long unsigned int 로 취급해서 %lu 를 사용해야한다.

uint64_t a{ 0 };
printf("%" PRIu64, a);

MSVC, g++ 양쪽에서 문제없이 컴파일 되려면 형식 지정자로 cinttypes 헤더에 선언된 PRIu64 와 같은 매크로를 사용하면 된다. 

참고 : https://stackoverflow.com/questions/14535556/why-doesnt-priu64-work-in-this-code

 

Why doesn't PRIu64 work in this code?

As per this answer, I tried printing a uint64_t, but it gives me an error: error: expected ``)' before 'PRIu64' Following is the minimal code showing what I am trying to do: #define

stackoverflow.com

참고 : https://en.cppreference.com/w/cpp/types/integer

 

Fixed width integer types (since C++11) - cppreference.com

int8_tint16_tint32_tint64_t(optional) signed integer type with width of exactly 8, 16, 32 and 64 bits respectivelywith no padding bits and using 2's complement for negative values(provided if and only if the implementation directly supports the type) (type

en.cppreference.com

 

728x90
>wsl --list --online
다음은 설치할 수 있는 유효한 배포 목록입니다.
'wsl --install -d <배포>'를 사용하여 설치하세요.

NAME                                   FRIENDLY NAME
Ubuntu                                 Ubuntu
Debian                                 Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
OracleLinux_8_5                        Oracle Linux 8.5
OracleLinux_7_9                        Oracle Linux 7.9
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
openSUSE-Leap-15.4                     openSUSE Leap 15.4
openSUSE-Tumbleweed                    openSUSE Tumbleweed

wsl 용 CentOS 는 마이크로소프트 스토어에서 찾을 수 없었다.

https://github.com/mishamosher/CentOS-WSL

 

GitHub - mishamosher/CentOS-WSL: A GitHub Actions automated CentOS RootFS to use with WSL

A GitHub Actions automated CentOS RootFS to use with WSL - GitHub - mishamosher/CentOS-WSL: A GitHub Actions automated CentOS RootFS to use with WSL

github.com

 위 사이트에서 받아서 사용하는 것 같다.

설치할 버전의 CentOS 압축 파일을 받자. CentOS7.zip 을 받았다.

압축을 풀고 CentOS7.exe 를 실행하면 된다. ( wsl 설정은 끝났다고 가정한다. )

설치가 끝나면 ext4.vhdx 라는 가상 디스크가 보인다.

> wsl -l
Linux용 Windows 하위 시스템 배포:
Ubuntu(기본값)
CentOS7
Ubuntu-20.04

wsl -l 로 목록을 보면 CentOS7 이 보인다.

>wsl -d CentOS7
# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

-d 옵션으로 CentOS7 을 선택해 실행하면 bash 를 볼 수 있다.

https://linuxconfig.org/how-to-check-centos-version

/etc/centos-release 파일을 통해 접속한 centos 버전을 확인할 수 있다.

728x90

https://www.hostingadvice.com/how-to/ubuntu-show-version/

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal

lsb_release -a 명령을 입력하면 접속한 ubuntu 버전을 확인할 수 있다.

728x90
728x90

기본적인 cpu 사용량은 작업 관리자를 통해 눈으로 확인할 수 있다.

왼쪽에서 '세부 정보' 탭을 선택해 프로세스 명, PID 등도 같이 확인할 수 있다.

https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer

 

Process Explorer - Sysinternals

Find out what files, registry keys and other objects processes have open, which DLLs they have loaded, and more.

learn.microsoft.com

그래프 형태로 확인하고 싶다면 Microsoft Sysinternals Process Explorer 를 이용하면 된다.

해당 프로세스에 마우스 오른쪽 버튼 메뉴에서 'Properties...' 선택 후

Performance Graph 탭에서 CPU Usage History 를 통해 확인할 수 있다.

성능 모니터(perfmon) 을 통해 측정할 수도 있다.

상단의 녹색 + 버튼을 눌러 카운터 추가 창을 띄운다. Process > % Processor Time 을 선택하고 모니터링할 프로세스를 선택하고 추가 버튼을 누르고 확인 버튼을 누른다.

아래쪽에 추가된 카운터가 표시되고 그래프 형태로 확인할 수 있다.

728x90

윈도우즈에서 dll, exe, lib, obj 등 바이너리 빌드에 사용한 Visual Studio 버전을 확인하고 싶을 때가 있다.

> dumpbin /?
Microsoft (R) COFF/PE Dumper Version 14.33.31629.0
Copyright (C) Microsoft Corporation.  All rights reserved.

사용법: DUMPBIN [options] [files]
...

dumpbin 이라고 visual studio 에 포함된 프로그램을 이용할 수 있다.

> dumpbin /dependents test.exe
Microsoft (R) COFF/PE Dumper Version 14.33.31629.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file test.exe

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    KERNEL32.dll
    MSVCP140D.dll
    WS2_32.dll
    VCRUNTIME140D.dll
    VCRUNTIME140_1D.dll
    ucrtbased.dll

  Summary

        ...

exe 나 dll 같은 경우 dumpbin /dependents 를 이용해 VCRUNTIMMxxx.dll 을 통해 빌드에 사용된 버전을 추론할 수 있다.

> dumpbin [binary file] /rawdata | find "_MSC_VER"
> dumpbin test.obj /rawdata | find "_MSC_VER"
  00000010: 43 48 3A 22 5F 4D 53 43 5F 56 45 52 3D 31 39 30  CH:"_MSC_VER=190

lib 나 obj 파일은 dumpbin /rawdata 결과에서 _MSC_VER 을 찾는 방식인데 짤려서 검색이 안되거나 결과가 제대로 안보일 수 있다.

$ strings test.obj | grep -Po '_MSC_VER=\d+'
_MSC_VER=1900

linux 명령어인 strings 를 통해 _MSC_VER 를 찾는게 더 깔끔하게 보인다.

> sls -Ca '_MSC_VER=\d+' .\test.obj |% {$_.matches} | select value

Value
-----
_MSC_VER=1900

powershell 명령어로도 동일하게 할 수 있다.

출처 : https://stackoverflow.com/questions/20503675/detecting-the-msc-ver-of-a-lib

 

Detecting the MSC_VER of a lib

I have a code base that I am compiling in to a library. Normally I would send the library as MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) but my customer is asking for it as MSVC++ 11.0 _MSC_V...

stackoverflow.com

 

728x90

명령줄 실행 시 기본적으로는 해당 실행파일의 경로가 표시된다.

title 명령어를 사용하면 명령줄 이름을 바꿀 수 있다.

>start /?
지정한 프로그램이나 명령을 실행할 수 있도록 별도의 창을 시작합니다.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
      [/MACHINE <x86|amd64|arm|arm64>][command/program] [parameters]

    "title"      창 제목 표시줄에 나타낼 제목입니다.
    ...

start 명령어를 사용해 프로그램이나 배치파일을 실행할 경우 start 명령어 다음에 "title" 로 적어주면 된다.

728x90

+ Recent posts