2013년 10월 29일 화요일

VI 에디터 팁


vi에서 줄번호 표시

:set nu
 

vi에서 줄번호 표시 없애기

:set nonu
 

페이지 이동

ctrl-f : 다음 페이지
ctrl-b : 이전 페이지
gg : 파일 첫 번째 행으로 이동
G : 파일 끝 행으로 이동
:191 : 191행으로 이동

 

"단어" 검색

/검색할단어
 

"단어1/단어2" 검색

/단어1\/단어2
 

검색결과 탐색

n : 다음 검색 결과 보기
N : 이전 검색 결과 보기
:noh : 검색 결과 하이라이트 없애기
 

sample.txt 파일에서 "단어"를 포함한 문장 표시

grep "단어" sample.txt  

sample.txt 파일에서 "단어1/단어2"를 포함한 문장 표시

grep "단어1\/단어2" sample.txt
 

sample.txt 파일에서 "단어1" 또는 "단어2"를 포함한 문장 표시

grep "단어1\|단어2" sample.txt
 

sample.txt 파일에서 "단어1/단어2" 혹은 "단어1/단어3"를 포함한 문장 표시

grep "단어1\/단어2\|단어1\/단어3" sample.txt
 

sample.txt 파일에서 "단어1"을 포함한 문장만 검색해서 result.txt 파일에 저장

result.txt 파일이 없을 경우, 파일을 생성해서 저장
result.txt 파일이 존재할 경우, 기존 내용 삭제되고 저장.

grep "단어1" sample.txt > result.txt
 

sample.txt 파일에서 "단어1"을 포함한 문장만 검색해서 result.txt 파일 마지막에 붙여넣기

result.txt 파일이 없을 경우, 파일을 생성해서 저장

grep "단어1" sample.txt >> result.txt

  

sample.txt 파일에서 단어1/단어2", "단어1/단어3", "단어1/단어4"를 포함한 문장을 result.txt에 저장한 후 100번째가 무엇인지 확인

grep "단어1\/단어2\|단어1\/단어3\|단어1\/단어4" sample.txt > result.txt
vi result.txt
:100

 

sample.txt 파일에서 단어1/단어2", "단어1/단어3", "단어1/단어4"를 포함한 문장을 단어1/단어2, 단어1/단어3, 단어1/단어4 순서로 묶어서 result.txt에 저장한 후 100번 째가 무엇인지 확인

grep "단어1\/단어2"> sample.txt > result.txt
grep "단어1\/단어3"> sample.txt >> result.txt
grep "단어1\/단어4"> sample.txt >> result.txt
vi result.txt
:100

리눅스 오라클 간단 팁

1. 데이터베이스

$ ./sqlplus /nolog
SQL> connect /as sysdba
SQL> shutdown immediate
SQL> startup

$ ./sqlplus "/as sysdba"
SQL> shutdown immediate
SQL> startup


2. 리스너

$ ./lsnrctl start
$ ./lsnrctl stop
$ ./lsnrctl status


3. iSQL*Plus

$ ./isqlplusctl start
$ ./isqlplusctl stop


4. Enterprise Manager

$ ./emctl start dbconsole
$ ./emctl stop dbconsole



5. 서비스 자동 시작

# vi /etc/rc.d/rc.local
# for Oracle 10g
su - oracle -c '/home/oracle/product/10.2.0/db_1/bin/lsnrctl start
su - oracle -c '/home/oracle/product/10.2.0/db_1/bin/dbstart
su - oracle -c '/home/oracle/product/10.2.0/db_1/bin/isqlplusctl start
# vi /etc/oratab

orcl:/home/oracle/product/10.2.0/db_1:N 에서 끝에 N을 Y로 수정.



6. SID 확인

SQL> select name from v$database;


7. Instance 확인


SQL> select instance_name,status from v$instance;


8. User 확인

SQL> select username from ALL_USERS;


9. Character Set 확인

SQL> select * from nls_database-parameters;

(기본 : KO16MSWIN949, 유니코드 : AL16UTF-16)


10. Archive Log 확인

SQL> select * from v$recovery_file_dest;

Name       space_limit         space_used
==========================================

* Name : Archive Log가 쌓이는 UNIX directory
* Space_limit : Archive log 사이즈 할당
* Space_used : 사용하고 있는 사이즈
* Space_limit와 space_used가 비슷한 숫자를 보이면 이미 임계값에 도달하여 모든 서비스가 행이 걸림.


11. User 생성

SQL> create user "계정이름" identified by "암호" default tablespace USERS; → 사용자생성
SQL> grant connect,resource,dba to "계정이름"; → 권한부여
SQL> connect 계정이름/암호; → 사용자연결

ActiveMq 보안적용

웹 콘솔 보안 적용

activemq의 jetty.xml 에서 빈 아이디 'securityConstraint'의 'authenticate' 프로퍼티를 'true'로 설정하면 웹 콘솔에 시큐어리티를 적용할 수 있다.



ACTIVEMQ 통신 보안 설정

activemq의 {ACTIVEMQ_HOME}/conf/activemq-security.xml 파일에서 빈 아이디  'propertyConfigurer' 의 'location' 프로퍼티를 ' 아래와 같이 설정    

<property name="location" value="file:${activemq.conf}/credentials.properties"/>


simpleAuthenticationPlug 설정
<plugins>
    <!-- Configure authentication; Username, passwords and groups -->
    <simpleAuthenticationPlugin anonymousAccessAllowed="false">
        <users>
            <authenticationUser username="system" password="${activemq.password}" groups="users,admins"/>                             <authenticationUser username="admin" password="admin" groups="users,admins,publishers,consumers"/>                 </users>
    </simpleAuthenticationPlugin>


activemq 시작 시에 인증을 적용하려면 아래와 같이 실행한다.

$ nohup ./activemq start xbean:file:../conf/activemq-security.xml &

리눅스 Java 설치

1. OS 종류 확인

getconf LONG_BIT

2. JDK 다운로드

http://www.oracle.com

3. 디렉토리 이동 및 권한 변경

다운받은 JDK 설치 파일을 /usr/local 로 이동 후, 실행가능하도록 권한 변경

$ su
$ mv <설치파일> /usr/local
$ chod 755 <설치파일>

4. 설치작업 실행

$ ./ <설치파일>

5. 환경변수 설정

$ vi /etc/profile

export JAVA_HOME=/usr/local/jdk1.6.0_xx
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH="."


$ source /etc/profile


6. 시스템에서 사용할 자바 설정

$ /usr/sbin/alternatives --install /usr/bin/java java /usr/local/jdk1.6.0_xx/jre/bin/java 2
$ /usr/sbin/alternatives --config java


7. 변경 확인

$ /usr/sbin/alternatives --display java

8. 자바 버전 확인

$ java -version

리눅스 방화벽 설정

iptables 파일 수정

$ vi /etc/sysconfig/iptables

iptables 재시작

$ service /etc/rc.d/init.d/iptables restart

또는

$ service iptables restart

현재 규칙 저장

$ /etc/rc.d/init.d/iptables save

또는

$ service iptables save

ActiveMq JMX 모니터링 가능하도록 설정

ACTIVEMQ_HOME/conf/activemq.xml

<!--
<managementContext>
    <managementContext createConnector="false"/>
</managementContext>
-->

    
위의 부분을 아래와 같이 설정한다.     

<managementContext>
    <managementContext createConnector="true" connectorPort="1099" />

</managementContext>

라우터 아이피 주소 알아내는 사이트 주소

http://www.whatismyip.com

Mac에서 MySQL ssh 포트 포워딩

Mac에서 ssh 포트 포워딩을 이용하여 접속할 수 있도록 한다.

ssh -f root@210.112.127.51 -L 3305:localhost:3306 -N 

-f 는 백그라운드로 실행하라는 의미이다.

mysql에서는 다음과 같이 접속한다.

driver=org.gjt.mm.mysql.Driver
url=jdbc:mysql://localhost:3305/데이터베이스이름
username=계정아이디
password=계정암호

JBoss 7.1.0 AS startup / shutdown

JBoss AS 7.1.0 서버의 시작

$ cd JBOSS_HOME/bin 경로로 이동한다.
$ nohup ./standalone.sh &


JBoss AS 7.1.0 서버의 셧다운 

$ cd JBOSS_HOME/bin
$ ./jboss-admin.sh --connect command=:shutdown

또는

$ ./jboss-admin.sh --connect --controller=127.0.0.1:1999 command=:shutdown

JavaDoc 생성 시 unmapped UTF-8 오류 날 때

이클립스에서 JavaDoc 생성 시 VM Option 항목에 아래와 같이 기록한다.

-locale ko_KR -encoding UTF-8 -charset UTF-8 -docencoding UTF-8

iBatis Mapping a composite key

Composite Keys or Multiple Complex Parameters Properties

You might have noticed that in the above examples there is only a single key being used as specified in the resultMap by the column attribute. This would suggest that only a single column can be associated to a related mapped statement. However, there is an alternate syntax that allows multiple columns to be passed to the related mapped statement. This comes in handy for situations where a composite key relationship exists, or even if you simply want to use a parameter of some name other than #value#. The alternate syntax for the column attribute is simply {param1=column1, param2=column2, …, paramN=columnN}. Consider the example below where the PAYMENT table is keyed by both Customer ID and Order ID:


Example. Mapping a composite key

<resultMaps>  
    <resultMap id="select-order-result" class="order">    
        <result property="id" column="ORD_ID"/>    
        <result property="customerId" column="ORD_CST_ID"/>    
        …    
        <result property="payments" column="itemId=ORD_ID, custId=ORD_CST_ID"             select="selectOrderPayments"/>  
    </resultMap>
<resultMaps>

<statements>  
    <statement id="selectOrderPayments" resultMap="select-payment-result">    
    select 

        * 
    from 
        PAYMENT
    where
        PAY_ORD_ID = #itemId#
        and
        PAY_CST_ID = #custId#  
    </statement>
</statements>


JBoss AS 7 v7.1.0 사용자 등록

JBOSS_HOME/bin/add-user.sh

JBoss AS 7에서 URIEncoding 설정

참고 URL : http://jboss7-oracle.blogspot.com/




Old way: <Connector name="http" ... URIEncoding="UTF-8" useBodyEncodingForURI="true"/>
 This can be edited in standalone.xml file to take effect in old way

New Way:

In Jboss7 there are 2 methods by which you can add these:

Method 1:

Using the jboss-admin.sh adn updating the system-property like:

[standalone@amghost3.cup.com:9009 /] 
/system-property=org.apache.catalina.connector.URI_ENCODING:add(value="UTF-8")
{"outcome" => "success"}


[standalone@amghost3.cup.com:9009 /] 
/system-property=org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING:add(value="true")
{"outcome" => "success"}
[standalone@amghost3.cup.com:9009 /] 

Verify these property by:

[standalone@amghost3.cup.com:9009 /]  /system-property=org.apache.catalina.connector.URI_ENCODING:read-resource
{
    "outcome" => "success",
    "result" => {"value" => "UTF-8"}
}
[standalone@amghost3.cup.com:9009 /] 

[standalone@amghost3.cup.com:9009 /]  /system-property=org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING:read-resource
{
    "outcome" => "success",
    "result" => {"value" => "true"}
}
[standalone@amghost3.cup.com:9009 /] 


Method 2:

cd $JBOSS_HOME/standalone/configuration

vi standalone.xml   ad add the following lines just below the </extensions>

    <system-properties>
        <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
        <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="tru
e"/>
    </system-properties>

JBoss AS 7 외부 접속가능하게 설정

JBOSS_HOME/standalone/configuration/standalone.xml

<interface name="public">
    <inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>

부분을 아래와 같이 변경한다.

<interface name="public">
    <any-address/>
</interface>

JBoss AS 7 admin console

http://localhost:9990/console

JBoss AS 7 용 웹 애플리케이션 프로젝트의 jackson 라이브러리 호환 설정

JBoss-As-web-7.0.2.Final

- jackson-core-asl-1.6.2.jar
- jackson-mapper-asl-1.6.2.jar



JBoss-As-7.1.0.CR1b

- jackson-all-1.8.7.jar

Mac에서 NTFS 포맷의 외장하드 쓰기권한 설정방법

NTFS 포맷의 외장하드는  Mac에서 읽기모드만 지원한다.

Paragon NTFS for Mac OS X 를 설치하면 Mac에서 외장하드에 쓰기 권한이 생긴다.

Mac root 권한 설정

$ sudo passwd root

Changing password for root.
New password:
Retype new password:

Mac OSX의 Finder에서 히든 파일보기 설정

1. 모든 Finder 애플리케이션을 닫는다.

2. 터미널을 띄운다.

3. 터미널에서 아래의 명령어를 입력하고 실행한다.

> defaults write com.apple.finder AppleShowAllFiles -bool YES

> killall Finder

4. Finder 를 실행해보면 히든 파일이 보이는 것을 확인할 수 있다.


* 히든 파일을 다시 숨기려면

위의 명령에서 YES 대신 NO 로 변경하여 같은 작업을 수행하면 된다.

Mac OSX 단축키

Common

fn-left : page first
cmd-up : page first
fn-right : page last
cmd-dn : 
page last
fn-up : 
page up
fn-dn : 
page dn
opt-left : 
word left
opt-right : 
word right
cmd-q : quit app
cmd-w : 
quit window
cmd-left : home
cmd-right : end
opt-cmd- =, - : zoom in , out
opt-enter (한글입력 후) : 한자 입력
cmd-shift-3 : 전체 화면 캡쳐
cmd-shift-4 : 선택 화면 캡쳐
cmd-delete : 파일 삭제
cmd-shift-delete : 휴지통 비우기

eclipse


cmd-k : find next
opt-cmd- up , dn : duplicate line
opt-cmd-s : 
source
opt-space : content assist
cmd-/ : comment
opt-shift- right , left : select word
cmd-shift-o : import organization

browser 

opt-cmd-i : dev. console
ctrl-cmd-f : 
full screen
cmd-t : 
new tab
cmd-r : refresh



화면 캡쳐 

shift-cmd-3 : 전체화면 캡쳐
shift-cmd-4 : 부분화면 캡쳐
shift-cmd-4 --- 스페이스바 1회 클릭 --- 윈도우 선택클릭 : 선택윈도우캡쳐

화면 캡쳐 클립보드에 저장

shift-cmd-ctrl-3 : 전체화면클립보드에 복사
shift-cmd-4 --- ctrl-영역 드래그 : 선택영역클립보드에 복사
shift-cmd-4 --- 스페이스바 1회 클릭 --- ctrl-윈도우 선택클릭 : 선택 윈도우 캡쳐


Start up hot-keys (press key while booting)

X : Force Mac OS X startup
C : Start up from a bootable CD
N : Attempt to start up from a compatible network server (NetBoot)
T : Start up in FireWire Target Disk mode
Opt-Cmd-Shift-Delete : Seeks a different startup volume
Shift : Start up in Safe Boot mode
Cmd-V : Start up in Verbose mode
Cmd-S : Start up in Single-User mode
Cmd-Opt-Esc : Force Quit menu

Cmd-Opt-D : Show/hide the dock
Ctrl-Eject : Bring up Shutdown/Sleep/Logout Dialog
Ctrl-Cmd-Eject : Restart immediately


Clipboard

Cmd-C : Copy
Cmd-V : Paste
Cmd-X : Cut
Cmd-A : Select All


Finder Navigation

Cmd-N : New Finder window
Cmd-W : Close Window
Opt-Cmd-W : Close all Windows
Cmd-Down : Open File/Folder
Cmd-Up : Navigate to parent
Cmd-Right : Expand folder (in list view)
Cmd-Left : Collapse Folder (in list view)
Opt-Cmd-Right : Expand folder and its subfolders (in list view)
Opt-Cmd-Up : Open parent folder and close current window
Cmd-Shift-H : Jump to your Home folder
Cmd-Shift-A : Jump to your Applications folder
Cmd-Shift U : Jump to your Utilities folder
Cmd-Shift K : Jump to the Network browser
Cmd-Shift G : Goto Folder…
Cmd-1 : View as Icons
Cmd-2 : View as List
Cmd-3 : View as Columns
Cmd-Space : Open Spotlight (OS X 10.4)
Cmd-Delete : Move file/folder to trash
Cmd-Click window title : Display the file path



Menu Commands

Shift-Cmd-Q : Log out
Shift-Opt-Cmd-Q : Log out immediately
Shift-Cmd-Delete : Empty Trash
Opt-Shift-Cmd-Delete : Empty Trash without dialog
Cmd-H : Hide window
Opt-Cmd-H : Hide Others
Cmd-N : File New window
Shift-Cmd-N : New Folder
Cmd-O : Open
Cmd-S : Save
Shift-Cmd-S : Save as
Cmd-P : Print
Cmd-W : Close Window
Opt-Cmd-W : Close all Windows
Cmd-I : Get Info
Opt-Cmd-I : Show Attributes Inspector
Cmd-D : Duplicate
Cmd-L : Make Alias
Cmd-R : Show original
Cmd-T : Add to Favorites
Cmd-Delete : Move to Trash
Cmd-E : Eject
Cmd-F : Find
Cmd-Z : Undo
Cmd-B : Hide Toolbar
Cmd-J : Show View Opts
Cmd = [ : Go Back
Cmd = ] : Go Forward
Shift-Cmd-C : Go to Computer
Shift-Cmd-H : Go to your Home folder
Shift-Cmd-I : Go to iDisk
Shift-Cmd-A : Go to Applications folder
Shift-Cmd-G : Go to Go-To Folder
Cmd-K : Connect to Server
Cmd-M : Minimize Window
Cmd-? : Open Mac Help
Cmd-Space : Open Spotlight (OS X 10.4)


Screen capture

Cmd-Shift 3 : Capture the screen to a file
Cmd Ctrl Shift 3 : Capture the screen to the clipboard
Cmd-Shift 4 : Select an area to be captured to a file
Cmd Ctrl Shift 4 : Select an area to be captured to the clipboard
Cmd-Shift 4, then press Space = Capture entire window


Universal Access

Opt-Cmd-* (asterisk) : Turn on Zoom
Opt-Cmd-+ (plus) : Zoom in
Opt-Cmd– (minus) : Zoom out
Cmd-Opt-Ctrl-8 : Invert Screen colours


Window Management

Cmd-W : Close window
Cmd-Opt-W : Close all windows
Cmd-M : Minimise window
Cmd-Opt-M : Minimise all windows
Cmd-H : Hide Application
Cmd-~ : Cycle through windows for current application
Ctrl-F4 : Cycle through every open window
Cmd-Tab : Bring up the Application Switcher.
Cmd-Tab : Cycle Forwards
Cmd-~ : Cycle Backwards
Cmd-Shift-Tab : Cycle Backwards
Cmd-Q : Quit application


Expose

F9 : Show all open windows on the screen at once
F10 : Show all windows for the current application.
F11 : Shows Desktop
F12 : Activates Dashboard
F12 (hold) : ejects disk


Miscellaneous

Opt-Cmd-D : Show/Hide Dock
Ctrl-Up : Move up one page
Ctrl-Down : Move down one page
Opt-Drag : Copy to new location
Opt-Cmd-Drag : Make alias in new location
Cmd-Drag : Move to new location without copying
Opt-Cmd-Eject : Sleep
Cmd-click window toolbar button (upper right corner) : Cycle through toolbar views
Ctrl-Cmd-D and mouse over word in Cocoa applications : shows Dictionary description for that word