2009년 7월 28일 화요일

find 명령어 활용하기

1. 중요옵션

-atime n : n 일 전에 마지막으로 억세스된 파일
-mtime n : n 일 전에 마지막으로 수정된 파일
-newer file : file 보다 최근에 수정된 파일
-size n : n*512 바이트의 길이를 갖는 파일
-type c : 파일의 종류 c값이 f=file d=directory
-fstype typ : 파일시스템 종류 기술
-name nam : 이름이 nam 인 파일
-perm p : 파일의 접근모드가 p인 파일
-user usr : 사용자 usr 에 속하는 파일
-group grp : 그룹 grp에 속하는 파일
-nouser : 파일소유자가 패스워드파일에 있지 않은 파일
-nogroup : 파일의 소유그룹이름이 그룹파일에 있지않은 파일


2. 사용예

find . -mtime +7  : 7일 이상 이전에 마지막으로 수정한 파일찾기
find . -atime -2  : 2일 전에 마지막으로 수정한 파일
find . -size +100 : 50K(100*512byet) 보다 큰 파일 찾기

find /temp -size +100 -exec rm -f {} \;
-> 50K 보다큰 파일 삭제

find / -type f \( -perm -2000 -o -perm -4000 \) -print
-> 보안을 위해 SUID와 SGID 권한을 갖는 모든파일들의 목록을 출력한다.

find /home /aux1 -type f -atime +30 -size +1000 -ls
-> /home /aux1 디렉토리안에 있는 500보다 크고 30일 이상
   억세스되지 않는 파일을 찾는다. -ls옵션은 자세하게 출력시 사용

find /chem -name '*.c' -exec mv {} /chem1/src \;
-> /chem 디렉토리에 있는 모든 C소스파일을 /chem1/src 로 이동

find /home/chavez -exec chown chavez {} \; -exec chgrp physis {} \;
-> /home/chavez 에 있는 모든파일들의 소유권을 chavez과 physis로 변경

SSH포트 변경하기

기본 SSH 포트인 22번을 사용할 경우 포트 공격은 안봐도 뻔하다.

 

포트 변경방법

 

ssh_config file : 클라이언트 툴의 접근에 대한 설정 파일

 

sshd_config file : ssh 데몬 설정을 위한 설정 파일

 

예) 포트를 2211 포트로 변경

 

# vi /etc/ssh/ssh_config 

Port 2211 <-- 변경

 

# vi /etc/ssh/sshd_config

Port 22002 <--  변경

 

ListenAddress xx.xxx.xx.xx <-- 0.0.0.0 server ip 변경

 

sshd 데몬 재실행 합니다.

1) standalone 일때

    # /etc/init.d/sshd restart

 

2) init 일때

    # /etc/init.d/xinetd restart

 

수정된 포트확인을 합니다.

 

# netstat -na|grep :2211

tcp 0 0 xx.xxx.xx.xx:2211 0.0.0.0:* LISTEN

 

방화벽(iptables)가 설정되어 있다면, 열어준 해당 포트를 열어 주어야 합니다.

(tcp, udp 둘 다 2211를 열어 줍니다.)

 

외부 접근시..

 

> ssh test@xx.xxx.xx.xx -p 2211

Password:

Last login: Mon Feb 15 21:18:56 2006 from xx.xxx.xx.xx

Hi Welcome!! Jinho's...

>

 

 

ps_) 재시작후 sshd 241 error 보일시엔 /etc/ssh/sshd_config 에서 ListenAddress 지정해준다.

 

-->sshd[241]:error:Bind to port 22002 on : failed: address already in use

 

 

알려진 서비스 포트 설정하기

# vi /etc/services

FTP 계정 사용자의 상위 디렉토리로의 이동 제한 sulinux 1.5

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
# anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command "SIZE /big/file" in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
chroot_local_user=YES

# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES

pam_service_name=vsftpd
userlist_enable=YES
#enable for standalone mode
listen=YES
tcp_wrappers=YES

mysql root 패스워드 강제 변경


1. 실행중인 MySQL을 종료한다.

killall mysqld

2. "./mysqld_safe --skip-grant-table &" 로 사용자 인증과정 없이 MySQL를 실행한다.

/usr/local/mysql/bin/mysqld_safe --skip-grant-table &

3. 패스워드 없이 MySQL root 계정으로 MySQL에 접속한다.

/usr/local/mysql/bin/mysql -u root mysql

4. update문으로 MySQL 데이터베이스의 user 테이블에 있는 MySQL root사용자의 패스워드를 변경한다.

update user set password=password('tnghkrl') where user = 'root';

5. "flush privileges" 명령어로 변경된 MySQL 권한테이블(db, user 테이블들)들에 변경된 권한설정들을 적용한다.

flush privileges;

6. MySQL을 빠져나와서 실행했던 MySQL을 종료한다.

exit

killall mysqld

7. 일반적인 방법으로 MySQL을 실행한다.

/usr/local/mysql/bin/mysqld_safe &

8. 정상적인 방법으로 패스워드를 사용하여 MySQL의 root계정으로 접속하여 확인한다.

/usr/local/mysql/bin/mysql -u root -p mysql

/etc/init.d/mysqld stop
/etc/init.d/mysqld start


SuLinux 수리눅스 1.5 설치 후 반드시 실행

# 전체업데이트 실행 (2시간정도 소요)
yum update -y

# APM툴스 설치
/root/bin/apmtools

# 젠드설치
wget http://downloads.phpchina.com/zend/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
tar xvfz ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-i386
./install.sh
cd ..
rm -Rf ZendOptimizer-3.3.3-linux-glibc23-i386*

# SSU 실행
vi /conf/su_util.cfg
# home_dirs = /home /usr /var /etc /lib
# web_dir = /home/ssu/system_check

useradd ssu
passwd ssu
chmod 707 /home/ssu

system_check_init --all
system_check

#서버시간동기화
crontab -e
00 01 * * * rdate -s time.bora.net && clock -w
00 03 * * * su - root -c '/root/bin/su_backup --local' >& /dev/null
00 07 * * * su - root -c '/root/bin/system_check' >& /dev/null
*/5 * * * * su - root -c '/root/bin/system_test >& /dev/null'
/etc/init.d/crond restart

#아파치설정 변경
vi /etc/httpd.conf

# ServerName 211.203.170.86
# UserDir /home/*
<Directory /home/*>
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews SymLinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>
# NameVirtualHost 211.203.170.86
<VirtualHost 211.203.170.86>
    DocumentRoot /home
    ServerName *
</VirtualHost>
/etc/init.d/httpd restart

#vsftp설정
/etc/vsftpd/vsftpd.conf
# chroot_local_user=YES
/etc/init.d/vsftpd restart

위의 내용은 지극히 개인적이나 업데이트 부분을 해주는게 좋다.

네이버 나눔글꼴 적용하기

네이버 나눔글꼴을 적용하기 위해서 나눔글꼴이 필요하다. 첨부파일로 올린다.

정확하게 라이센스가 어떻게 되는지 알 수 없지만 나눔글꼴을 여러분야에서 사용했으면 한다면

웹에서도 마찬가지로 사용해야 하지 않을까??

네이버쪽에서 어떻게 나올지는 모르겠군...


@font-face {font-family:nanum ; src:url(/css/nanum.eof);}

body{font-family:nanum,돋움,Dotum,AppleGothic,sans-serif; text-align:center; margin:0; padding:0;}

위와 같이 정의해서 사용하면 된다.

웹표준에 따른 HTML 태그 정의

1. 모든 태그는 < />로 닫아야 한다.
- 예) <font> 문자열 </font>
        <br />

2. form을 사용할때는 <table> 밖에 위치해야 한다.
- 예)
기존방식
<table>
<form>
<tr>
<td></td>
</tr>
</form>
</table>

웹표준
form { margin: 0; }

<form style="margin:0px;">
<table>
<tr>
<td></td>
</tr>
</table>
</form>
표준방식으로 하게 되면 폼의 마진으로 인해 빈줄이 생기게 된다. 그러므로 css에 정의하면 된다.



3. alt 태그 대신에 title 태그를

4. input태그에는 tabindex를 이용해서 키보드 만으로 이동할 수 있게
예)   <INPUT TYPE="text" NAME="name" tabindex="1">첫번째
  <INPUT TYPE="text" NAME="name" tabindex="3">세번째
  <INPUT TYPE="text" NAME="name" tabindex="2">두번째

위의 내용이 태그를 사용하면서 무심히 지나가는 표준이었다.
웹표준은 어찌 보면 정말 쓸데없는 짓이기는 하다. 거대기업이 배포한 웹브라우저에 길들어져 버린
우리에겐 웹표준은 의미가 없을 수 도 있다.

하지만 어쩌면 그 반대편에 서 있거나 소외되버린 사람들에게는 웹표준은 하나의 희망이 될 수 있지
알을까?
쉬운 것부터 하자 코딩습관만 바꿔도 좋겠다.
첨부파일로 웹표준에 관한 자료를 올려둔다. 많은 참고 바란다.