반응형

검색

# Word 검색

grep -r 'word' ./

grep -r 'word' ./*/src/main -- include '*.java' | wc -l

grep apple fruitlist.txt
grep -i apple fruitlist.txt ignore
grep -w apple fruitlist.txt word

 

# 파일 검색

find [검색경로] -name [파일명]

find -name test.jar

find ./ -name 'file1'
find ./ -name "*.jpg"

find ./ -name "*.jpg" -exec rm {} \; : 확장자가 .jpg인 파일만 찾아서 바로 삭제
find ./ -type d
find ./ -type f
find ./ -type f | wc -l : 특정 디렉토리에 find 조건에 맞는 결과 값이 몇개 존재
find ./ -name "*.txt" -exec sed -i 's/hi/hello/g' {} \; : 확장자가 .txt인 파일만 찾아내고, txt 파일 안에 있는 ‘hi’ 라는 문자열을 ‘hello’로 변경

 

파일 및 디렉토리

mv [original.txt] [rename.txt] : 파일명 변경

mkdir [directory] : 폴더 생성
rm -rf [file or directory] : 파일 및 폴더 삭제

 

pwd(print working directory) :현재 경로 확인

 

# 파일 결합

cat [file1]
1
cat [file2]
2
cat [file1] [file2] > [file3]
cat [file3]
1
2
cat [file1] >> [file2]
cat [file2]
2
1

 

프로세서 종료

killall [process name]

df -h // storage usage
du -sh [directory] // directory storage usage

 

코드 라인 측정

 wc -l find . -name '*.java'

 

Password 설정

sudo passwd root

 

파일 내용 확인

head -n 50 test.log : 파일 앞 부분 n 라인 출력

tail -n 50 test.log : 파일 마지막 부분 n 라인 출력

   

파일/폴더 확인

df -m : 디스크 용량 확인

du : 폴더 용량 확인

 

파일 권한 변경

chmod 777 [file] : 모든 사용자에 모든 권한 부여

chmod 000 [file] : 모든 사용자에 모든 권한 제거

 

실행 파일 위치 확인

whereis

which

 

Shell 환경 설정 파일

/etc/profile : 시스템 전역 쉘 변수

/etc/bashrc : 쉘 함수, alias 시스템 전역 변수 정의

~/.bash_profile : 유저 개인의 환경 설정

~/.bashrc : 유저 개인의 alias 및 변수 설정

~/.bash_logout : 로그아웃 설정파일

 

Java Path 설정

whereis, which로 java 경로 확인

bashrc 파일에 path 설정

source ~/.bachrc : bashrc 설정 파일 적용

 

 

 

 

 

반응형

+ Recent posts