리눅스

 

 

[root@localhost ~]# ls -l glist.txt 
-rw-r--r-- 1 root root 2223  3월  5 11:01 glist.txt
[root@localhost ~]# cp glist.txt file1.txt
[root@localhost ~]# cp glist.txt file2.txt
[root@localhost ~]# cp glist.txt file3.txt
[root@localhost ~]# ls -l file*

-rw-r--r-- 1 root root 2223  3월  5 11:48 file1.txt
-rw-r--r-- 1 root root 2223  3월  5 11:49 file2.txt
-rw-r--r-- 1 root root 2223  3월  5 11:49 file3.txt


[root@localhost ~]# xz file1.txt
[root@localhost ~]# bzip2 file2.txt
[root@localhost ~]# gzip file3.txt
[root@localhost ~]# ls -l file*
-rw-r--r-- 1 root root 976  3월  5 11:48 file1.txt.xz
-rw-r--r-- 1 root root 943  3월  5 11:49 file2.txt.bz2
-rw-r--r-- 1 root root 901  3월  5 11:49 file3.txt.gz


[root@localhost ~]# cp /boot/vmlinuz-3.10.0-514.el7.x86_64  bin1
[root@localhost ~]# cp /boot/vmlinuz-3.10.0-514.el7.x86_64  bin2
[root@localhost ~]# cp /boot/vmlinuz-3.10.0-514.el7.x86_64  bin3
[root@localhost ~]# xz bin1
[root@localhost ~]# bzip2 bin2
[root@localhost ~]# gzip bin3

=>압축 풀림  :  압축명령어  -d  파일명

[root@localhost ~]# xz  -d bin1.xz 
[root@localhost ~]# bzip2 -d bin2.bz2 
[root@localhost ~]# gzip -d bin3.gz 
[root@localhost ~]# ls -l bin


***** 파일 묶기 tar 은 압축은 안하고 묶어만 준다. 원본파일 그대로

[root@localhost ~]# ls  -l bin*
-rwxr-xr-x 1 root root 5392080  3월  5 11:52 bin1
-rwxr-xr-x 1 root root 5392080  3월  5 11:52 bin2
-rwxr-xr-x 1 root root 5392080  3월  5 11:52 bin3
[root@localhost ~]# tar cvf bin.tar bin1 bin2 bin3
bin1
bin2
bin3
[root@localhost ~]# ls -l bin*
-rw-r--r-- 1 root root 16189440  3월  5 12:02 bin.tar
-rwxr-xr-x 1 root root  5392080  3월  5 11:52 bin1
-rwxr-xr-x 1 root root  5392080  3월  5 11:52 bin2
-rwxr-xr-x 1 root root  5392080  3월  5 11:52 bin3


** 원본 파일 삭제  ? 임의 글자 모두
[root@localhost ~]# rm -f bin?


**** 묶은 파일 풀기

[root@localhost ~]# tar xvf bin.tar

[root@localhost ~]# rm -f bin.tar
[root@localhost ~]# ls  bin*
bin1  bin2  bin3


** 압축도 하고 묶어주기도 한다. cvfj 마지막에 확장명 붙일것

[root@localhost ~]# tar cvfj bin.tar.bz2 bin1 bin2 bin3
bin1
bin2
bin3


---- 대문자 J
[root@localhost ~]# tar cvfJ  bin.tar.xz bin1 bin2 bin3


*****  xz 의 경우 압축률이 상당히 좋다.

[root@localhost ~]# ls -l bin.tar*
-rw-r--r-- 1 root root 16134820  3월  5 14:17 bin.tar.bz2
-rw-r--r-- 1 root root  5328148  3월  5 14:20 bin.tar.xz

 

 

 

********** 찾기

[root@localhost ~]# find /etc -name "*.conf" > conf.txt


[root@localhost ~]# find /usr/bin -size +90k -size -100k


[root@localhost ~]# find /usr/bin -size +90k -size -100k -exec ls -l {} \;


 

 

----  시스템 설정  --------------

[root@localhost ~]# system-config-date
bash: system-config-date: 명령을 찾을 수 없습니다...
[root@localhost ~]# yum  -y install system-config-date


[root@localhost ~]# nmtui
[root@localhost ~]# firewall-config
[root@localhost ~]# ntsysv

 

 

 

 

********** 찾기

[root@localhost ~]# find /etc -name "*.conf" > conf.txt


[root@localhost ~]# find /usr/bin -size +90k -size -100k


[root@localhost ~]# find /usr/bin -size +90k -size -100k -exec ls -l {} \;


----  시스템 설정  --------------

[root@localhost ~]# system-config-date
bash: system-config-date: 명령을 찾을 수 없습니다...
[root@localhost ~]# yum  -y install system-config-date


[root@localhost ~]# nmtui
[root@localhost ~]# firewall-config
[root@localhost ~]# ntsysv


-- 예약 cron

[root@localhost ~]# systemctl status crond


[root@localhost ~]# vi /etc/crontab

-- vi corntab 열기

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

 

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
01  3  15  *  * root  run-parts  /etc/cron.monthly
분 시  15일 매달 루트권한 run-parts  (폴더 안에 실행 파일)

 

 


[root@localhost ~]# cd /etc/cron.monthly/
[root@localhost cron.monthly]# ls -l
합계 0
[root@localhost cron.monthly]# vi myBackup.sh   (실행 파일  임의 이름)
     

#!/bin/sh

set $(date)
fname="backup-$2$3.tar.xz"

tar cfj /backup/$fname  /home


[root@localhost cron.monthly]# mkdir /backup
[root@localhost cron.monthly]# systemctl restart crond
# date 01월15일 03시 00분 2019년
[root@localhost cron.monthly]# date 011503002019
2019. 01. 15. (화) 03:00:00 KST
[root@localhost cron.monthly]# systemctl restart crond

=> 그러나 작동을 안해서 다시 만들었다.

[root@localhost cron.monthly]# rm -f myBackup.sh


** cfJ 대문자 
[root@localhost cron.monthly]# gedit myBackup.sh

#!/bin/sh

set $(date)
fname="backup-$2$3.tar.xz"

tar cfJ /backup/$fname     /home

[root@localhost cron.monthly]# date 011503002019
2019. 01. 15. (화) 03:00:00 KST
[root@localhost cron.monthly]# date
2019. 01. 15. (화) 03:00:04 KST
[root@localhost cron.monthly]# systemctl restart crond
[root@localhost cron.monthly]# date
2019. 01. 15. (화) 03:00:19 KST
[root@localhost cron.monthly]#

실행 권한 추가
[root@localhost cron.monthly]# chmod ugo+x myBackup.sh ㅇㅁㅅㄷ


 /////  컴퓨터 시간 업데이트
[root@localhost cron.monthly]# rdate -s time.bora.net

예약

[root@localhost cron.monthly]# at 4:00 am tomorrow
at> yum - y update
at> reboot
at> <EOT>
at> 
at> <EOT>
job 1 at Mon Mar  6 04:00:00 2017   (컨트롤 + D)종료

예약 확인
[root@localhost cron.monthly]# at -l
1    Mon Mar  6 04:00:00 2017 a root

예약 삭제( atrm + 번호)
[root@localhost cron.monthly]# atrm 1


 

 

 

 

 

 

 

about author

PHRASE

Level 60  머나먼나라

성격은 우리의 행위의 결과이다. -아리스토텔레스

댓글 ( 4)

댓글 남기기

작성
  •    
  •    
  •