Linux_p #1
cat -n /var/log/messages
cat -n /var/log/messages |tr 'tty' 'TTY' |grep 'TTY' | head -5
-> ~ 결과를 | tty를 TTY로 변경한뒤 | TTY만 5줄
cat -n /var/log/messages |tr 'tty' 'TTY' |grep 'TTY' > TTY.xtx
-> 결과를 TTY.txt 에 저장
cat -n /etc/passwd | tr 'root' 'ROOT' | grep 'ROOT'
-> root를 ROOT로 바꿔서 ROOT가 들어간것만 출력
cat -n /etc/passwd |tr 'root' 'ROOT' |grep -i 'root'
-> root 단어가 대문자로 바뀐것이 아니라 r,o,o,t가 대문자로 변경된것이다.
[root@centos1 centos]# cat > input.txt
Hi,
welcome to Linux.
Have fun, fun.
Thanks a lot.
[root@centos1 centos]# cat input.txt
Hi,
welcome to Linux.
Have fun, fun.
Thanks a lot.
[root@centos1 centos]# wc input.txt
4 10 51 input.txt
-> wc - 줄 단어 문자 수
wc
-> -l , -w, -c = 줄 , 단어, 문자
cat /etc/passwd |grep -i 'rOoT' |wc -l
-> 읽어서 대소문자 무시하고 root가 있는 줄 수
-------------------------
- stat
stat /etc/passwd
adduser paul
passwd paul
stat /etc/passwd
[root@centos1 centos]# which ssh
/usr/bin/ssh
[root@centos1 centos]# whereis ssh
ssh: /usr/bin/ssh /etc/ssh /usr/share/man/man1/ssh.1.gz
locate ssh
-> 파일 위치
[root@centos1 centos]# find / -name ssh -type f
/usr/bin/ssh
/usr/share/bash-completion/completions/ssh
[root@centos1 centos]# echo $HOME
/root
-> 현재 환경변수
[root@centos1 centos]# echo $HOSTNAME
centos1.kahn.edu
-> 호스트네임
[root@centos1 centos]# echo > echo.txt
-> 파일생성
[root@centos1 centos]# cat echo.txt
-> 빈 파일 확인
[root@centos1 centos]# echo "IM CENTOS" >> echo.txt
-> 파일에 데이터 입력
[root@centos1 centos]# cat /proc/sys/net/ipv4/ip_forward
1
[root@centos1 centos]# echo "0" > /proc/sys/net/ipv4/ip_forward
[root@centos1 centos]# cat "0" > /proc/sys/net/ipv4/ip_forward
cat: 0: No such file or directory
[root@centos1 centos]# cat /proc/sys/net/ipv4/ip_forward
0
[root@centos1 centos]# echo "1" > /proc/sys/net/ipv4/ip_forward
[root@centos1 centos]# cat /proc/sys/net/ipv4/ip_forward
1
-> 바로바로 변경 가능
wget https://downloads.mariadb.org/interstitial/mariadb-10.1.21/source/mariadb-10.1.21.tar.gz
->wget 으로 다운로드/설치
curl -O abc.git https://github.com/docker/docer.git > abc.git
-> 다운로드
su -c 'yum -y install lftp'
->루트에서 작업할 것은 ' ' 안에 넣고 명령함
->passwd 입력 후 진행
$ su -c nano /etc/lftp.conf
->passwd 입력 후 진행
-> 맨밑에 set net:limit-rate 10240000:0 추가
-> 다운로드를 10메가 , 업로드는 무한
lftp -c "set ftp:passive-mode on;set net:max-retries 3;set net:timeout 5;mget -c ftp://ftp.intel.com/readme.txt"
-> passive 모드를 켜라 ; 재시도를 3번까지 ; 타임아웃 시간을 5분; 파일이 여러개면 여러파일을 이어받기 (mget)
cat /etc/passwd | head -5
more /etc/passwd | head -5
less /etc/passwd | head -5
-> cat, more, less 로 읽을 수 있다
head /etc/passwd
-> 디폴트 값으로 위에서 10줄 보여줌
head -3 /etc/passwd
-> 위에서 3줄 보여줌
tail /etc/passwd
-> 디폴트 값으로 밑에서 10줄 보여줌
tail -3 /etc/passwd
-> 밑에서 3줄 보여줌
tail -f /var/log/secure
-> -f 옵션 - 실시간으로 대기하면서 보여줌
$ bc
= 계산
정확한 값 scale
디폴트 값은 정수
Scale=4 소수점 4째자리 까지
$ bc -q Cel2Fah
->bc에 파일을 불러올 수 있음
[root@centos1 centos]# let "SUM = 5+5"
[root@centos1 centos]# printf $SUM
10[root@centos1 centos]# printf "$SUM\n"
10
->sum이라는 변수에 10을 넣고 프린트
->문자 + res가능
$ tee
$ script
하는 행동 exit 까지 모두 저장
# sendmail
Mailinator.com 가입없이 실행
일시적으로 메일을 저장
# ruu.kr
History
!280
->해당번호 명령어 실행
!!
->마지막 명령어 실행
!$
->마지막으로 실행되었던 문자열 명령어 실행
$ history -c
->모든 history 삭제