history 설정

history 의 기본 설정값에  날짜정보 함께 출력하기.


/etc/profile 하단에 내용 추가



 vim  /etc/profile


 #Add timestamp  to  .bash_history

 HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S -- "

 export  HISTTIMEFORMAT

 declare -r HISTFILE 



설정 적용하기


 source /etc/profile




1. 시간대 설정 -  시간대를 KST 으로 맞춘다.


 # ln -sf  /usr/share/zoneinfo/Asia/Seoul     /etc/localtime




2. [date] 명령으로 시스템 시간을 맞춘다.



# date -s "2018-05-28 11:14:22"  


    * rdate -s time.bora.net  이라는 편리한 명령이  있으나....  부득이하게  수동 세팅이 필요할 경우  date -s 으로 설정할 수 있다.




3. hwclock 까지 맞춘다.


 # hwclock  --systohc   ( 또는 -w )     # O/S 의 시간을   H/W에 덮어쓴다. ( 반대는  hwclock --hctosys  또는 -s )

 # date

 Sat Oct 19 18:02:11 KST 2019

 # hwclock

 Sat 19 Oct 2019 06:04:49 PM KST  -0.724847 seconds


1. 메일 큐 전체 비우기

# postfix flush   또는 postfix -f


2. 현재 쌓인 메일 확인

# mailq


3. 메일큐 전체 삭제

# postsuper -d ALL


4. 메일큐에서 deferred 된 메일만 삭제

# postsuper -d ALL deferred

리눅스의 openssl 을 사용하여  자체 서명 인증서를 만들어 보자....

자체 인증서는 웹브라우저에서는 신뢰할 수 없는 사이트라고 나오지만, SSL 보안 기능은 잘 동작한다.



1. openssl 의 설치 여부를 확인하자...


[root@smtp tls]# rpm -qa openssl

openssl-1.0.2k-8.el7.x86_64




2. 개인키 생성


[root@smtp tmp]# openssl genrsa -des3 -out private.key 2048

Generating RSA private key, 2048 bit long modulus

....................................................+++

................+++

e is 65537 (0x10001)

Enter pass phrase for private.key:                ------------>  비밀번호 입력.

Verifying - Enter pass phrase for private.key:      -----------> 비밀번호 확인 입력.

[root@smtp tmp]#


private.key 라는  개인키가 생성된다.



3. 인증 요청서 생성 ( CSR - Certificate  Signing  Request )


[root@smtp tmp]# openssl req -new -key private.key  -out server.csr

Enter pass phrase for private.key:   --------------> 개인키 비밀번호 입력.


You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [XX] KR

State or Province Name (full name) []:Daejeon
Locality Name (eg, city) [Default City]:Seogu
Organization Name (eg, company) [Default Company Ltd]:NETRA
Organizational Unit Name (eg, section) []:Service
Common Name (eg, your name or your server's hostname) []:mail.weschool.kr
Email Address []:master@weschool.kr

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:    --------------> 그냥 패스~.
An optional company name []:    --------------> 패스 ~.
[root@smtp tmp]# 



4. 개인키 패스워드 제거.

   

   key에 패스워드가 들어 있으면 웹데몬 구동시 마다 물어본다. 패스워드를 제거하더라도 SSL 암호화 통신에는 문제가 없다.

 

[root@smtp tmp]# cp -a private.key  private.key_org

[root@smtp tmp]# openssl rsa -in private.key_org  -out private.key

Enter pass phrase for private.key_org:  --------------> 개인키 비밀번호 입력.   

writing RSA key

[root@smtp tmp]# ls

private.key  private.key_org  server.csr

[root@smtp tmp]#





5. 인증서 생성

   

   개인키와 인증요청서를 가지고 인증서를 생성한다.

 

[root@smtp tmp]# openssl x509 -req -days 365 -in server.csr -signkey private.key -out server.crt

Signature ok

subject=/C=KR/ST=Daejeon/L=Seogu/O=NETRA/OU=Service/CN=mail.weschool.kr/emailAddress=master@weschool.kr

Getting Private key

[root@smtp tmp]# 




6. 확인

   

   생성된  사설인증서(crt)를 확인해 보자

 

[root@smtp tmp]# more private.key | head -3

-----BEGIN RSA PRIVATE KEY-----

MIIEogIBAAKCAQEAx/+LzN+U5Xn2/sz9MQFY83WU4nma95zo9WvIPc0H7OlhI2hO

MKcWjbRnD7w3zPw1rYvt+2keZeRKp1B8lq+9HlZnCmS6DWNCajW6c9kcLbWI65I7

[root@smtp tmp]#

[root@smtp tmp]# more server.crt | head -3

-----BEGIN CERTIFICATE-----

MIIDnDCCAoQCCQDAlK1Edjlw/jANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMC

S1IxEDAOBgNVBAgMB0RhZWplb24xDjAMBgNVBAcMBVNlb2d1MQ4wDAYDVQQKDAVO

[root@smtp tmp]#




[root@mail ~]#cd /home/temp/   &&  bash copy.sh


 --> /home/temp 경로로 이동하여 거기에 있는 copy.sh 스크립트를 실행한다.

출력 결과 값의    대/소문자를 치환하는 명령...



(기본)

[root@mail logrotate.d]# uname -a 

Linux mail.weschool.kr 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux



(소문자로 치환)
[root@mail logrotate.d]# uname -a | tr '[A-Z]' '[a-z]'
linux mail.weschool.kr 3.10.0-693.el7.x86_64 #1 smp tue aug 22 21:09:27 utc 2017 x86_64 x86_64 x86_64 gnu/linux



(대문자로 치환)

[root@mail logrotate.d]# uname -a | tr '[a-z]' '[A-Z]'

LINUX MAIL.WESCHOOL.KR 3.10.0-693.EL7.X86_64 #1 SMP TUE AUG 22 21:09:27 UTC 2017 X86_64 X86_64 X86_64 GNU/LINUX



1. $ sed -e 's/aaaa/bbbb/g' < a.php > b.php 
하면 b.php 로 바뀐 파일이 나온다네요 

2. find 와 perl 의 조합으로 가능합니다. 
find / -name 'aaa.php' -type f -exec perl -pi -e 's/aaa/bbb/g' {} \; 

3. 하위 디렉토리까지 찾아서 파일 내의 특정한 내용을 바꾸는 명령입니다. 
find . -name *.html | awk '{ print "cat "$1" | sed \"s/바꾸고싶은말/바뀔말/g\" >"$1 }' | sh 

저는 이런식으로 하고 있습니다.. 
find . -name *.html -exec perl -pi -e 's/바뀌고/바뀔/g' {}\;  위에서 찾을때 '*.html' 식으로 해야할 수도 있다.

#find ./ -mtime +10 | awk ' { print "mv "$1" ./babo" } ' | sh 

---> find의 -mtime +10은 수정된지 10일 이상인 것만 찾는다. 이것을 이용해 나온 파일들을 ./babo 디렉토리 아래로 move

#. 설정파일

    /etc/vsftpd/vsftpd.conf


 

# 익명 접속 금지
    anonymous_enable=NO

# 로그 저장 파일 지정
    xferlog_file=/var/log/vsftpd.log

# 로그 형식을표준 xferlog 포멧으로 하지 않음
    xferlog_std_format=NO

# 대기 시간 지정(10분동안 유지)
    idle_session_timeout=600 

# 데이터 연결 해제 시간 지정 (2분)
    data_connection_timeout=120

# 아스키 형식 파일 전송 지원
    ascii_upload_enable=YES
    ascii_download_enable=YES

# 로그온시 배너 지정
    ftpd_banner=Welcome to FTP Server

# 상위 디렉토리 이동 금지
    local_root=public_html
    chroot_local_user=YES

# 패시브 모드 지정
    pasv_enable=YES
    pasv_min_port=30000
    pasv_max_port=30020

# 숨김 파일(. 으로 시작하는 파일) 무시
    force_dot_files=YES

# FTP 데몬이 표시하는 시간을 서버시간(NTP로 동기화된 시간)에 맞추기
    use_localtime=YES



특정 유저 접속 차단

   /etc/vsftpd/ftpusers, /etc/vsftpd/user_list 에 추가


[root@fedora root]# vi /etc/vsftpd/user_list 
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd.ftpusers
# for users that are denied.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

 








 

■ 상위 경로를 액세스 시키지 않는 설정  ----( 지정된 사용자만 접속이 안된다)


chroot_local_user=NO
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
allow_writeable_chroot=YES



【root@fedora root】# vi /etc/vsftpd/chroot_list
  user1

   --> user1 은 홈 패스보다 위를 보내지 않는다


'배워서 남주자 > Linux 명령' 카테고리의 다른 글

[find] 특정일 이상된 파일 찾기  (0) 2018.03.23
[vsftp] vsftp 기본 설정  (1) 2018.03.23
[tape 장비] Tape 백업  (0) 2018.03.23
[mkisofs] ISO 압축하기  (0) 2018.03.23
[ifconfig] 네트워크 설정  (0) 2018.03.23

+ Recent posts