한글 설정 방법
Ctrl + Shitp + P 버튼을 누른다음 Configure Display Language 를 검색 합니다.
한국어를 선택하고 재실행 합니다.
Ctrl + Shitp + P 버튼을 누른다음 Configure Display Language 를 검색 합니다.
한국어를 선택하고 재실행 합니다.
=> cannot create temp file for here-document: 장치에 남은 공간이 없음
[root@mysvr:/root]$ fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x8135267e. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-41943039, default 2048): =>엔터 Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): =>엔터 Using default value 41943039 Partition 1 of type Linux and of size 20 GiB is set Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
pvcreate /dev/sdb1
pvscan
pvdisplay
vgextend centos /dev/sdb1
lvextend /dev/mapper/centos-root -l +100%FREE
[root@mysvr:/root]$ resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root
Couldn't find valid filesystem superblock.
[root@mysvr:/root]$ blkid /dev/mapper/centos-root
/dev/mapper/centos-root: UUID="f4704f6c-5120-4c0f-b46b-7a0c31f390e5" TYPE="xfs"
xfs_growfs /dev/mapper/centos-root
리눅스에서 커널버전을 업그레이드 하는 방법에 대해 알아보겠습니다.
현재 설치된 서버는 Centos 6.9 버전입니다.
uname -r
cat /proc/version
cat /proc/sys/kernel/osrelease
dmesg | grep "Linux version"
아래 사이트에서 원하는 커널 버전을 다운로드 받습니다.
저는 3.14 버전으로 업그레이드를 하기 위해 3.14 커널 버전을 다운로드 받습니다.
cd /var
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.14.1.tar.gz --no-check-certificate
tar xvzf linux-3.14.1.tar.gz
https://mirrors.edge.kernel.org/pub/linux/kernel/
Index of /pub/linux/kernel/
mirrors.edge.kernel.org
yum install ncurses-devel
yum groupinstall "Development Tools"
cd /usr/src
ln -s /var/linux-3.14.1 linux
make mrproper
make clean
cp /boot/config-2.6.32-754.35.1.el6.x86_64 ./.config
make all
make moules_install
make install
ERROR: modinfo: could not find module snd_page_alloc
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <dev-account@centos7.(none)>) not allowed
gitlab 올라간 특정 디렉토리만 다운로드 받을 수 있는 방법을 소개 합니다.
일반적으로 git clone 을 수행 하면 gitlab 에 등록된 프로젝트를 모두 다운로드 받게 되는데
이럴경우 원하지 않는 파일도 모두 다운로드 받게 되어 비효율 적입니다.
이번 글에서는 git config core.sparsecheckout true 명령을 통해 프로젝트중 원하는 디렉토리만 다운로드 방법을 소개 하겠습니다.
mkdir test
cd test
git init
git remote add -f origin http://xxx.xxx.xxx.xxx:6060/comdoc/testProject.git
echo "guide_doc/doc" > .git/info/sparse-checkout
git config core.sparsecheckout true
git pull origin main
git add option_test.sh
git commit -m "option test shell commit"
git push origin main
git show-ref
git remote -v
git status
git branch -m master main
netstat -tulpn | awk '/LISTEN/ {print $4}' | awk -F ":" '{print $NF}' | sort -n
22
#!/bin/bash
read -p " 원하는 포트 범위를 입력하세요:" check_port_range
echo " $check_port_range 범위 이상의 포트 범위를 체크합니다. "
# 현재 사용 중인 포트와 포트 범위를 확인하는 스크립트
# netstat 명령어를 사용하여 현재 사용 중인 포트를 확인하고 awk로 정리합니다.
# 마지막에 sort 명령어를 사용하여 포트를 정렬합니다.
used_ports=$(netstat -tulpn | awk '/LISTEN/ {print $4}' | awk -F ":" '{print $NF}' | sort -n | uniq)
# 포트 범위를 확인하는 함수
check_port_range() {
local start_port=$1
local end_port=$2
port_range=$(expr $end_port - $start_port)
if [ $port_range -ge $check_port_range ]; then
echo " [ $(expr $port_range ) ] : $(expr $start_port + 1 ) ~ $(expr $end_port + 1 ) "
fi
}
# 사용 중인 포트를 확인하면서 포트 범위를 확인합니다.
IFS=$'\n'
start_port=0
echo "PORT_RANGE : START_PORT ~ END_PORT"
echo "================================================="
for port in $used_ports; do
check_port_range "$start_port" "$port"
start_port=$port
done
아래 경로에서 Visual Studio Code 를 다운로드 받습니다.
https://code.visualstudio.com/
Visual Studio Code - Code Editing. Redefined
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
code.visualstudio.com
Host [alias]
HostName [ip addr]
User [account_name]
Port [port number]
IdentityFile [key location]
리눅스에서는 파일시스템의 디스크 사용량을 df -h 명령으로 확인 할수 있습니다.
이번 글에서는 마운트된 디스크가 여러개일때 쉘스크립트를 사용해서
평균 사용량을 계산하는 스크립트작성하는 방법에 대해 알아보겠습니다.
df -h명령을 수행 하면 아래 그림처럼 시스템의 디스크 사용량을 확인 할수 있습니다.
각 항목의 설명은 다음과 같습니다.
이때 현재 Disk 사용율은 Use% 항목으로 표시됩니다.
디스크 사용량 공식은 Usage Percentage=(Size - Avail ) / size ×100 입니다.
쉘스크립트를 사용해 디스크가 여러개일때 평균 사용량을 체크하는 스크립트를 작성 합니다.
#사용량 체크 Mount Disk 정보
declare -a system_mounted_disks=(
/
/data1
/data100G
/data65G
/data300G
)
system_disk_chk(){
total_size=0
total_used_size=0
total_avail_size=0
df -h ${system_mounted_disks[1]} | awk 'NR==1'
for disk in "${system_mounted_disks[@]}"
do
df -h $disk | awk 'NR==2'
disk_size=$(df -k $disk --output=size | awk 'NR>1 {gsub(/[A-Za-z]/, "", $1); printf "%.0f\n", $1}')
disk_used_size=$(df -k $disk --output=used | awk 'NR>1 {gsub(/[A-Za-z]/, "", $1); printf "%.0f\n", $1}')
disk_avail_size=$(df -k $disk --output=avail | awk 'NR>1 {gsub(/[A-Za-z]/, "", $1); printf "%.0f\n", $1}')
total_size=$((total_size + disk_size))
total_used_size=$((total_used_size + disk_used_size))
total_avail_size=$((total_avail_size + disk_avail_size))
done
echo "--------------------------------------------------------------------"
echo "DISK Total Size : $(expr $total_size / 1024 / 1024) GB"
echo "DISK Total Size(Used) : $(expr $total_used_size / 1024 / 1024) GB"
echo "DISK Total Size(Avail) : $(expr $total_avail_size / 1024 / 1024) GB"
echo "DISK Use(%) : $(echo "scale=2; ($total_size - $total_avail_size) / $total_size * 100" | bc) (%) "
echo "--------------------------------------------------------------------"
}
system_disk_chk
다음과 같이 5개 마운트된 디스크의 사용량 체크해보겠습니다.
이번 글에서는 우분투에서 윈도우로 접속하는 방법에 대해 알아보겠습니다.
방법은 의외로 간단합니다.
우분투에서 원격데스크탑 유틸을 설치한후 접속할 윈도우 서버에서 원격 데스크탑 연결을 허용해 주면 됩니다.
sudo apt-get install rdesktop
이번글에서는 윈도우 환경에서 C 언어로 작성된 프로그램을 컴파일하고 실행하는 방법에 대해 알아보겠습니다.
리눅스 환경에서 윈도우환경에서 gcc 설치후 C 코드 컴파일하고 실행 방법에 대해 소개 하도록 하겠습니다.
Window 10 환경에서 VS Code 와 Mingw 를 설치하도록 하겠습니다.
아래 경로에서 다운로드를 받습니다.
Installer 도 있지만 설치시 제 환경에서는 에러가 발생해서 바이너리 다운로드후 압축 해제 했습니다.
https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/
하단 스크롤 하면 다운로드 매뉴가 나옵니다.
Download x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z (MinGW-w64 - for 32 and 64 bit Windows)
A complete runtime environment for gcc The mingw-w64 project is a complete runtime environment for gcc to support binaries native to Windows 64-bit and 32-bit operating systems.
sourceforge.net
윈도우 환경 변수 설정
GCC 설치 버전 확인
아래 경로에서 Visual Studio Code 를 다운로드 받습니다.
https://code.visualstudio.com/
Visual Studio Code - Code Editing. Redefined
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
code.visualstudio.com
VS Code 실행 및 C/C++ 확장 팩을 설치
VS Code C 컴파일 환경 설정
gcc 컴파일 경로 설정
C/C++ 환경 설정
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:/Program Files (x86)/Windows Kits/8.0/Include/um",
"C:/Program Files (x86)/Windows Kits/8.0/Include/shared",
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include",
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64",
"browse": {
"path": []
},
"compilerPath": "C:/mingw64/bin/gcc.exe",
"compilerArgs": []
}
],
"version": 4
}
빌드 환경 구성
{
"version": "2.0.0",
"runner": "terminal",
"type": "shell",
"echoCommand": true,
"presentation": {
"reveal": "always"
},
"tasks": [
{
"label": "save and compile for C++",
"command": "g++",
"args": [
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"group": "build",
"problemMatcher": {
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"label": "save and compile for C",
"command": "gcc",
"args": [
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"group": "build",
"problemMatcher": {
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"label": "execute",
"command": "cmd",
"group": "build",
"args": [
"/C",
"${fileDirname}\\${fileBasenameNoExtension}"
],
"problemMatcher": []
},
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 활성 파일 빌드",
"command": "C:\\mingw64\\bin\\gcc.exe",
"args": [
"-g",
"-lm",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "디버거에서 생성된 작업입니다."
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe 활성 파일 빌드",
"command": "C:\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "디버거에서 생성된 작업입니다."
},
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 활성 파일 빌드",
"command": "C:\\mingw64\\bin\\gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-lm"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "test"
}
]
}
test.c 파일 을 만들어 테스트 코드를 작성합니다.
#include <stdio.h>
int main()
{
printf("Hello, world!\n");
printf("C Program Compile Test \n");
return 0;
}
실행 매뉴 버튼 클릭후 테스트 코드를 컴파일 및 실행 합니다.
테스트 결과
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("1 번째 [%s]:\n",argv[1]);
printf("2 번째 [%s]:\n",argv[2]);
printf("Hello, world!\n");
printf("C Program Compile Test \n");
return 0;
}
launch.json
{
// IntelliSense를 사용하여 가능한 특성에 대해 알아보세요.
// 기존 특성에 대한 설명을 보려면 가리킵니다.
// 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요.
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 활성 파일 빌드 및 디버그",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\build\\${fileBasenameNoExtension}.exe",
"args": ["1 args ","2 args "],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "gdb에 자동 서식 지정 사용",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe 활성 파일 빌드"
},
]
}
실행 매뉴 버튼 클릭후 테스트 코드를 컴파일 및 실행 합니다.
실행을 하면 입력 한 변수 값도 실행시에 프로그램에 전달 할수 있습니다.