linux (8) 썸네일형 리스트형 [linux] sed로 빈줄 제거 sed : 스트림 에디터 sed '/^\\s\*$/d' 명령행 분해 sed: stream editor 명령행, 텍스트를 파싱하고 변경한다. '/^\s*$/d': sed가 수행하는 명령 /^\s*$/: 레귤러 익스프레션으로 블랭크 라인을 매치한다. ^: 라인의 시작을 알림 \s*: 공백 캐릭터를 매치(spaces or tabs), including none. $: 라인의 끝 d: sed가 레귤러 익스프레션을 수행하여 매치한 라인을 지우라고 시킴 그래서 이 명령에 텍스트 입력을 수행하면 빈줄이 지워진 텍스트를 출력한다. 예_ example.txt 파일이 빈줄을 가졌을 때 이를 지우려면 다음과 같이 명령. 이것은 터미널에 결과를 출력한다. sed '/^\s*$/d' .. [linux] wget 파일 다운로드 ### wget -P : 다운로드 파일이 저장될 디렉토리를 지정하는데 쓰이는 옵션 ```bash wget -P /path/to/directory URL ``` 예) http://example.com/file.zip 를 다운받아 /home/user/downloads 에 저장하는 경우 ```bash wget -P /home/user/downloads http://example.com/file.zip ``` 환경변수 환경변수 추가 현재 세션에서만 유용하게 임시로 설정 export command 사용 export VARIABLE_NAME=value 예) MY_VAR 환경변수에 'HelloWorld'를 셋팅 export MY_VAR=HelloWorld 확인 echo $MY_VAR 영구적인 세팅 환경변수를 영구적으로 추가하려면 configuration files ~/.bashrc, ~/.profile or ~/.bash_profile에 추가한다. open shell profile file nano ~/.bashrc 파일 맨 밑에 'export' command를 추가한다. bash export MY\_VAR=HelloWorld 저장후 나와서 실행 source ~/.bashrc ## 폴더를 PATH environment va.. [nc] NetCat: Versatile Network Utility for TCP/UDP nc, or Netcat, is a versatile networking utility for reading from and writing to network connections using TCP or UDP protocols. It's often dubbed the "Swiss Army knife" of networking due to its wide range of capabilities. Netcat is commonly used for a variety of tasks related to networking diagnostics, development, and general purpose network communication. Key Features of Netcat: Port Scan.. [linux] 파일 비교 방법 1. diff diff 명령이 일반적 기본 사용법:diff file1.txt file2.txt 출력: 두 파일의 차이를 출력. 첫번째 파일을 두번째 파일과 같게 하기 위한 정보도 제공 Options: -y or --side-by-side: 하나씩 출력 -i: 대소문자 구분 무시 -w: 공백 무시 --color: 출력을 컬러로 표시 2. cmp The cmp command is simpler and faster than diff when you just want to check if the files are identical or where they first differ. Basic Usage:cmp file1.txt file2.txt Output: 기본으로, 두 파일이 다른 곳을 먼저 출력하고 만일 두.. [linux] Monitor GPU Power Consuption Monitor Power Consumption: display the power usage of the GPU in watts and refresh the data every 1000 milliseconds (1 second). adjust the refresh rate by changing the value of --loop-ms nvidia-smi --query-gpu=power.draw --format=csv --loop-ms=1000 Logging Power Consumption: nvidia-smi --query-gpu=power.draw --format=csv --loop-ms=1000 > gpu_power_log.txt [linux] 디렉토리 접근 권한 정보 변경 drwxr-xr-x 6 root root 4096 2월 1 16:38 workspace workspace 디렉토리는 다음과 같은 권한 설정을 가지고 있습니다: drwxr-xr-x: 디렉토리(d)이며, 소유자(root)는 읽기(r), 쓰기(w), 실행(x) 권한이 있습니다. 소유자 그룹(root)과 다른 사용자들은 읽기(r)와 실행(x) 권한만 가지고 있으며, 쓰기 권한은 없습니다. 소유자와 그룹 모두 root로 설정되어 있습니다. 이 설정에 따르면, root 사용자만이 workspace 디렉토리에 파일을 생성하거나 삭제할 수 있습니다. 일반 사용자가 이 디렉토리 내에서 git clone과 같은 쓰기 작업을 시도하면 "permission denied" 오류가 발생할 것입니다. 디렉토리의 소유권 변경 현재 .. Permission Denied 문제 git clone 명령어를 사용할 때 "permission denied" 오류 발생 원인 및 해결방법 1. 디렉토리 접근 권한 원인: 사용자가 git clone을 실행하려는 디렉토리에 쓰기 권한이 없을 때 발생합니다. 해결 방법: 해당 디렉토리의 권한을 확인하고 수정합니다. 터미널에서 다음 명령어를 사용하여 권한을 확인하고 수정할 수 있습니다. 권한 확인: ls -l /path/to/directory 권한 변경 (필요한 경우): sudo chmod -R u+rw /path/to/directory 또는 디렉토리 소유권을 현재 사용자로 변경: sudo chown -R $USER /path/to/directory 2. SSH 키 접근 권한 원인: SSH를 통해 git clone을 실행하는 경우, SSH .. 이전 1 다음