728x90
반응형

****************************
특정 문자열이 포함된 파일의 이름 찾기

 

grep 명령을 이용하면 특정한 문자열을 포함하고 있는 파일들을 찾을 수 있다.

 

사용법

 

# [옵션]을 적용하여 [파일]의 내용을 검색, [문자열]을 찾음

grep [옵션] [문자열] [파일]

 

 

아래는 my_memo.txt 파일에서 abcd 문자열이 포함되어 있는지 검색하고 파일명과 함께 문자열이 포함된 행을 찾아 출력하는 것이다.
-H 옵션을 주면 찾은 문자열뿐만 아니라 해당 파일명을 같이 출력해 준다.
파일명과 문자열은 콜론(:)으로 구분된다.

 

grep -H abcd my_memo.txt

my_memo.txt:abcdef

 

 

문자열은 필요 없고 파일명만 확인하고 싶다면 아래와 같이 -l 옵션을 추가.

 

grep -Hl abcd my_memo.txt

my_memo.txt

 

 

-r 을 사용하면 하위 디렉토리까지 찾아준다.

 

grep -Hlr abcd ./log

 

 

만약 특정 파일만 골라서 확인하고 싶다면 --include 옵션을 추가한다.
아래는 확장자가 txt인 파일만 대상으로 검색하는 경우이다.

 

 grep -Hlr --include=*.txt abcd ./log

 

 

파일 중에 v로 시작되는 파일은 제외하고 검색하려면 여기에 --exclude 옵션을 추가.

 

 grep -Hlr --include=*.txt --exclude=v* abcd ./log

 

****************************

 

 

728x90
SMALL
Posted by gromet
728x90
반응형

**************************************
MySQL 프로시저(procedure), 함수(function) 생성/실행 권한 주기



 MySQL 일반 User로서는 프로시저와 함수를 만들거나 실행할 수 없는 것이 기본 설정이다.
필요에 따라 가능하게 바꾸어 주자.

1. 프로시저 및 함수 생성 권한 확인

SHOW VARIABLES LIKE '%log_bin_trust_function_creators%';

#기본값은 "OFF"



2, 프로시저 및 함수 생성 권한 주기

SET GLOBAL log_bin_trust_function_creators = 1;


3. 확인

SELECT * FROM information_schema.ROUTINES;


4. 실행 권한 부여

grant execute on function `db명`.`함수명` to '사용자명'@'localhost';
flush privileges;

 

728x90
SMALL
Posted by gromet
728x90
반응형

***************************
네임서버, DNS 변경 후 적용 여부 확인

 

필요에 따라 네임서버나 DNS 레코드 변경 후 보통은 바로, 일반적으로는 48시간 정도 지나야 적용이 된다고 통용되고 있다.
적용되었는지 확인하고 싶은데
보통은 nslookup으로 다 확인해야 하고 네임서버 별로 다 쿼리를 해 봐야 한다.

 

오늘은 간단하게 적용여부를 확인할 수 있는 사이트를 소개 하려고 한다.

 

https://dnschecker.org/

dnschecker.org

 

기본 화면은 전세계 네임서버를 대상으로 내가 확인하고 싶은 도메인의 적용 여부를 확인할 수 있다.
만약 한국내에서의 적용 여부를 확인하고 싶다면 지도 밑에 Countries  부분을 확인하면 된다.

 

국가별 선택

 

그러면 아래와 같이 목록이 줄어든다.

국가별 선택 (South Korea)

 

 

728x90
SMALL
Posted by gromet
728x90
반응형

****************************
Apache 2.2 인증서 없이 443포트 운영

 

요즘 브라우저나 포탈에서 사이트로 이동할 때 443 포트가 운영중이지 않음에도 https로 링크를 제공하고 있다.
인증서가 전혀 필요하지 않은 사이트임에도 불구하고.
그래서 인증서 없이 443 포트 운영이 가능한지 확인해 보았다.

 

인증서 없이 443 포트를 지정하고 Apache를 시작시키면 아래와 같은 에러가 발생한다.

[Tue Dec 25 16:02:45 20xx] [error] Server should be SSL-aware but has no certificate configured [Hint: SSLCertificateFile] (/path/to/www.site.org.conf:20)

 

이런 경우  Listen을 다음과 같이 변경하면 된다.

Listen 443 http

 

728x90
SMALL
Posted by gromet
728x90
반응형

*************************
Postfix 국가도메인(TLD) 차단 방법

 

xxx.ne.jp에서 피싱 / 스팸 메일이 많이 들어와서 국가도메인을 차단하는 방법을 찾아봤다.
아래 2가지 중에 하나만 적용하면 된다.

1. header_checks

/etc/postfix/main.cf

	header_checks = regexp:/etc/postfix/header_checks
    
/etc/postfix/header_checks

	# Some TLD rejections. Kill entire countries.

	/^Received: ..gt .$/ REJECT Sorry, too much spam from Guatemala
	/^Received: ..tw .$/ REJECT Sorry, too much spam from Taiwan
	/^Received: ..kr .$/ REJECT Sorry, too much spam from Korea
	/^Received: ..cr .$/ REJECT Sorry, too much spam from Costa Rica
	/^Received: ..cn .$/ REJECT Sorry, too much spam from China
	/^Received: ..ru .$/ REJECT Sorry, too much spam from RU
	/^Received: ..br .$/ REJECT Sorry, too much spam from Brazil
	/^Received: ..th .$/ REJECT Sorry, too much spam from Thailand
	/^Received: ..tr .$/ REJECT Sorry, too much spam from Turkey

	# Kill known spamming ISPs
	/^Received: ..dynamic.hinet.net .$/ REJECT Sorry, too much spam from HINET

 

2. check_sender_access

/etc/postfix/main.cf

	smtpd_recipient_restrictions = permit_mynetworks,
	permit_sasl_authenticated,
	reject_unauth_pipelining,
	reject_non_fqdn_recipient,
	reject_unauth_destination,
	check_sender_access hash:/etc/postfix/sender_access,
	reject_rbl_client zen.spamhaus.org

/etc/postfix/sender_access

	/.*\.icu$/ REJECT
	/.*\.cn$/ REJECT
728x90
SMALL
Posted by gromet
728x90
반응형

*****************************
POSTFIX 특정 도메인만 SPF check 하기

 

# /etc/postfix/main.cf:

smtpd_recipient_restrictions =
    reject_unlisted_recipient
    ...
    reject_unauth_destination 
    check_sender_access hash:/etc/postfix/sender_access
    ...
smtpd_restriction_classes = spfcheck
spfcheck = check_policy_service unix:private/spfcheck

# /etc/postfix/sender_access:
    aol.com     spfcheck
    hotmail.com spfcheck
    bigfoot.com spfcheck
    ... etcetera ...

 

 

https://serverfault.com/questions/726471/how-to-setup-postfix-to-check-spf-record-only-for-domains-that-i-want-to-check

 

How to setup postfix to check SPF record only for domains that i want to check

I have working postfix server. It configured with amavis and uses pretty good SMTP headers control. But sometimes my users receive spam from spammers with well known mail service providers addresses.

serverfault.com

 

728x90
SMALL
Posted by gromet

블로그 이미지
나는 운이 좋은 사람이다 나는 나날이 점점 더 좋아진다 내가 하는 선택과 행동은 반드시 성공으로 이어진다 내게는 인내력과 지속력이 있다 네게는 좋은것들만 모여든다
gromet

공지사항

Yesterday
Today
Total
반응형

달력

 « |  » 2024.6
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

160x600