IT/Unix

Unix 기본 명령어

SpringUpOhWell! 2017. 5. 6. 21:13
반응형

SSH

- 통신 경로 암호화로 도청을 막을 수 있다

- 서버 인증

- 공개키 인증 방식

ssh username@host

ssh keyname username@host


Shell 환경 변수

Bourne Shell 계열

VAR=100 (쉘 변수)

exprot VAR (환경변수)

C Shell 계열

set var=100 (쉘 변수)

setenv var 100 (환경변수)


grep

작은 따옴표는 문자열을 그대로 인용한다

grep '$PASS' /var/www/html

큰 따옴표는 변수의 값이 사용된다

grep "$PASS" /var/www/html


Redirection vs Pipe

파이프는 출력을 다른 프로그램으로 전달한다

date | cur -2

리다이렉션은 파일이나 스트림으로 출력을 전달할 때 사용된다

tail -10 log.txt > output.txt


> /dev/null 2>&1

/dev/null 은 버린다는 뜻이다. 즉 > /dev/null 은 표준출력을 버린다(discard).

cat myfile.txt > /dev/null 2>&1

2>&1 는 표준에러를 표준출력으로 보낸다(redirect)

결국 > /dev/null 2>&1 은 표준에러와 표준출력 모두 /dev/null 로 redirect 하게 된다


dirname

strip non-directory suffix from file name

dirname /etc/fruit/apple.txt

결과는 /etc/fruit


pushd / popd

pushd : Adds  a  directory to the top of the directory stack

popd : Removes entries from the directory stack

root@james:~# pushd /etc

root@james:/etc# popd

root@james:~#

pushd dir 하면 dir 로 이동하고

popd dir 하면 원래 위치로 돌아온다



반응형