๐Ÿ’ป Programming/Linux (20)

์˜ค๋žœ๋งŒ์— ํฌ์ŠคํŒ…์„ ํ•ฉ๋‹ˆ๋‹ค.


๋ญ, ๊ทธ๋ƒฅ ์ข…์ข… ์‚ฌ์šฉํ•˜๋Š” ๊ฑด๋ฐ ๋งจ๋‚  ๊นŒ๋จน์–ด์„œ ๊ณ„์† ๊ตฌ๊ธ€๋งํ•˜๊ฒŒ ๋งŒ๋“œ๋Š” vi์—์„œ ๋ฌธ์ž์—ด ์น˜ํ™˜ํ•˜๊ธฐ์— ๋Œ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.


*nix ํ™˜๊ฒฝ์—์„œ ์ž‘์—…์„ ํ•˜๊ฒŒ๋˜๋ฉด ์„ค์ • ํŒŒ์ผ์„ ์ˆ˜์ •ํ•  ์ผ์ด ๋งŽ์ด ์ƒ๊น๋‹ˆ๋‹ค.


์ด๋•Œ ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ ๊ฒฝ๋กœ๋‚˜, ์ด๋Ÿฐ ์ €๋Ÿฐ ๊ฒฝ๋กœ๋“ค์„ config ํŒŒ์ผ ์•ˆ์— ์„ค์ •ํ•ด๋†“๊ณ  ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•˜๋Š”๋ฐ, ์ด๋•Œ ๊ฒฝ๋กœ ๊ฐœ์ˆ˜๊ฐ€ ๋งŽ๊ณ  ์•ž๋ถ€๋ถ„์˜ ๊ฒฝ๋กœ๋Š” ๋™์ผํ•œ ๊ฒƒ๋“ค์ด ๋งŽ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


์˜ˆ๋ฅผ๋“ค์–ด, /aaa/bbb/myapp/conf/config.properties ํŒŒ์ผ์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‚ด์šฉ๋“ค์ด ์žˆ์„ ์ˆ˜ ์žˆ์ฃ .


.

.

myapp.root=/aaa/bbb/myapp

myapp.log=/aaa/bbb/myapp/log

myapp.modules=/aaa/bbb/myapp/modules

.

.


์ €๋Ÿฐ์‹์œผ๋กœ ๊ฒฝ๋กœ๊ฐ€ ์ €์žฅ์ด ๋˜์–ด์žˆ๋Š”๋ฐ, ์•ž๋ถ€๋ถ„์˜ ์ ˆ๋Œ€๊ฒฝ๋กœ๋ฅผ ๋‹ค๋ฅธ ๊ฒฝ๋กœ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ๊ณ  ์‹ถ์„ ๋•Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ํŒŒ์ผ ์‚ฌ์ด์ฆˆ๊ฐ€ ์ž‘๊ณ  4~5๊ฐœ ์ •๋„๋ฉด ํ•˜๋‚˜ํ•˜๋‚˜ ์ˆ˜์ •์„ ํ•ด์ค˜๋„ ๋˜๊ฒ ์ง€๋งŒ, ํŒŒ์ผ ์‚ฌ์ด์ฆˆ๊ฐ€ ํฌ๊ณ  ๊ฒฝ๋กœ ์„ค์ •ํ•˜๋Š” ๋ถ€๋ถ„์ด ์—ฌ๊ธฐ์ €๊ธฐ ํฉ์–ด์ ธ ์žˆ์œผ๋ฉด ์ผ์ผ์ด ์ฐพ์•„์„œ ์ˆ˜์ •ํ•˜๊ธฐ๊ฐ€ ์‰ฝ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.


์ด๋Ÿด ๋•Œ ์‚ฌ์šฉํ•˜๋ผ๊ณ  vi์—์„œ๋Š” ๊ฐ•๋ ฅํ•œ ์น˜ํ™˜ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๊ณ ์žˆ์Šต๋‹ˆ๋‹ค.


%s/์น˜ํ™˜ํ•˜๋ ค๋Š”๋ฌธ์ž์—ด์ •๊ทœ์‹/๊ฒฐ๊ณผ๋ฌธ์ž์—ด์ •๊ทœ์‹/์˜ต์…˜


vi๋กœ ๋ฌธ์„œ๋ฅผ ์—ด์–ด๋†“์€ ์ƒํƒœ์—์„œ :์„ ์ž…๋ ฅํ•˜์—ฌ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ ๋’ค ์œ„ ํ˜•์‹์— ๋งž๊ฒŒ ๋ฌธ์ž์—ด ๋ฐ ์˜ต์…˜์„ ์ž…๋ ฅํ•ด์ฃผ๋ฉด ํŒŒ์ผ ์ „์ฒด์—์„œ ํŠน์ • ๋ฌธ์ž์—ด์„ ์ฐพ์•„์„œ ๊ฒฐ๊ณผ๋ฌธ์ž์—ด๋กœ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


์œ„ ์˜ˆ๋ฅผ๋“ค์–ด /aaa/bbb/myapp์„ /ccc/ddd/app ์œผ๋กœ ๋ณ€๊ฒฝ์„ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด


%s/\/aaa\/bbb\/myapp/\/ccc\/ddd\/app/g


๋ผ๊ณ  ์ž…๋ ฅํ•ด์ฃผ๋ฉด ์ „์ฒด ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ๊ฒ€์ƒ‰ํ•˜์—ฌ /aaa/bbb/myapp ๋ฌธ์ž์—ด์„ ์ฐพ์€ ๋’ค /ccc/ddd/app ์œผ๋กœ ์น˜ํ™˜ํ•ด์ค๋‹ˆ๋‹ค.


๋ช…๋ น์–ด๋ฅผ ์‚ดํŽด๋ณด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.


%s : ๋ฌธ์„œ ์ „์ฒด

g : ํ•œ์ค„์— ๋™์ผ ํŒจํ„ด์ด ์—ฌ๋Ÿฌ๊ฐœ ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ ๋ชจ๋‘ ์ ์šฉ

i : ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ ์•ˆํ•จ




์ด์ƒ์œผ๋กœ ๊ฐ„๋งŒ์˜ ํฌ์ŠคํŒ…์„ ๋งˆ์นฉ๋‹ˆ๋‹ค~

์•ˆ๋…•ํ•˜์„ธ์š”, ์ผ€์ด์น˜์ž…๋‹ˆ๋‹ค.


์˜ค๋Š˜์€ ๋ฆฌ๋ˆ…์Šค ์„œ๋ฒ„์˜ ์žฌ๋ถ€ํŒ…/์žฌ๊ธฐ๋™ ๋˜๋Š” ์–ธ์ œ shutdown์ด ๋์—ˆ๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์› ์Šต๋‹ˆ๋‹ค.


๊ทธ๋‹ค์ง€ ๋งŽ์ด ์“ธ ์ผ์€ ์—†๋Š” ๋ช…๋ น์–ด์ด๊ธด ํ•œ๋ฐ ์›น์‚ฌ์ดํŠธ์— ์ ‘์†์ด ์•ˆ๋˜์„œ ํ™•์ธํ•ด๋ณด๋‹ค๊ฐ€ ์•Œ๊ฒŒ๋˜์—ˆ๋„ค์š”.


์šฐ์„  ์›น์„œ๋ฒ„๋กœ ์ ‘์†์„ ํ•˜๋Š”๋ฐ ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฉ”์‹œ์ง€๊ฐ€ ๋–ด์Šต๋‹ˆ๋‹ค.

Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.


๋ญ”์†Œ๋ฆฐ๊ฐ€ ๋ดค๋”๋‹ˆ ์ ๊ฒ€ ์ค‘์ด๊ฑฐ๋‚˜ ์šฉ๋Ÿ‰๋ฌธ์ œ๋กœ ์ธํ•ด์„œ ์ ‘์†ํ•  ์ˆ˜ ์—†๋‹ค๋ผ๋Š” ๋ง์ด๋„ค์š”.


๊ทธ๋ž˜์„œ ์„œ๋ฒ„์— ์ ‘์†ํ•ด์„œ ํ˜น์‹œ ๋””๋ ‰ํ† ๋ฆฌ ์šฉ๋Ÿ‰์ด ๋ถ€์กฑํ•œ๊ฐ€ ๋ดค๋Š”๋ฐ ์•„๋‹ˆ์—ˆ์Šต๋‹ˆ๋‹ค.


๊ทธ๋Ÿผ ์™œ ์•ˆ๋˜๋Š”์ง€ ์—๋Ÿฌ๋กœ๊ทธ๋ถ€ํ„ฐ ํ™•์ธํ•ด์•ผ๊ฒ ์ฃ .


์›น์„œ๋ฒ„์˜ ์—๋Ÿฌ๋กœ๊ทธ๋ฅผ ๋ดค๋Š”๋ฐ ์—๋Ÿฌ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค ใ„ทใ„ท;;;;; ๋ญ์ง€ ์ด๊ฑด;;;


์ด์ œ ์‹ค์ œ ์›น์•ฑ์ด ์˜ฌ๋ผ๊ฐ€์žˆ๋Š” WAS ๊ธฐ๋™์ƒํƒœ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.


๋‘๋‘ฅ!!!! WAS๊ฐ€ ์ฃฝ์—ˆ๋„ค์š” ใ…œใ…œ


๋ญ์ง€ ๋‚œ ์ฃฝ์ธ์ ์ด ์—†๋Š”๋ฐ....๊ทธ๋ž˜์„œ ๋‹ค์‹œ WAS์˜ ์—๋Ÿฌ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•˜๋Š”๋ฐ ํ—;;;; ์—ฌ๊ธฐ๋„ ์—๋Ÿฌ๋กœ๊ทธ๋Š” ์—†์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰๊นŒ์ง€ ์—ด์‹ฌํžˆ ์‚ฌ๋žŒ๋“ค์˜ ์š”์ฒญ์— ๋ถ€์‘ํ•œ ํ”์ ๋ฐ–์— ์—†๋„ค์š”.


๋ญ์ง€? ์„œ๋ฒ„๊ฐ€ ์žฌ๋ถ€ํŒ… ๋๋‚˜? ์–ด๋–ป๊ฒŒ ํ™•์ธํ•˜์ง€?


๋ฆฌ๋ˆ…์Šค ์„œ๋ฒ„์˜ ์žฌ๊ธฐ๋™ ์ƒํƒœ๋ฅผ ํ™•์ธํ•˜๋Š” ๋ช…๋ น์–ด๋Š” ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.


์ฒซ์งธ, last ๋ช…๋ น์–ด.

๋‘˜์งธ, who ๋ช…๋ น์–ด.


[keichee@server1 ~]$ last reboot

reboot   system boot  3.10.0-514.16.1. Thu Jun 22 17:13 - 11:32 (140+18:19)

reboot   system boot  3.10.0-327.36.3. Wed Jan  4 22:14 - 17:11 (168+18:57)

reboot   system boot  3.10.0-327.36.3. Thu Nov 17 14:41 - 17:11 (217+02:30)

reboot   system boot  3.10.0-327.36.3. Thu Nov 17 15:06 - 17:11 (217+02:04)

reboot   system boot  3.10.0-327.36.3. Thu Nov 17 11:01 - 17:11 (217+06:09)


last reboot ๋ช…๋ น์–ด๋Š” ๋งˆ์ง€๋ง‰์œผ๋กœ ์žฌ๊ธฐ๋™ํ•œ ์‹œ๊ฐ„์ด ์–ธ์ œ์ธ์ง€๋ฅผ desc ์ •๋ ฌํ•˜์—ฌ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, ์ œ์ผ ์œ„์— ์žˆ๋Š”๊ฒŒ ๊ฐ€์žฅ ์ตœ๊ทผ์— ์žฌ๊ธฐ๋™ํ•œ ์‹œ๊ฐ„์„ ๋งํ•ฉ๋‹ˆ๋‹ค.


last reboot ๋ง๊ณ ๋„ last shutdown ๋ช…๋ น์–ด๋กœ ์–ธ์ œ ์…ง๋‹ค์šด๋์—ˆ๋Š”์ง€ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. 


last -x ๋Š” ์–ด๋–ค ์‚ฌ์šฉ์ž๊ฐ€ ์„œ๋ฒ„์— ์ ‘์†ํ•ด์„œ ์–ผ๋งˆ๋‚˜ ์žˆ์—ˆ๋Š”์ง€ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. run level์ด ์–ด๋–ป๊ฒŒ ๋ฐ”๋€Œ์—ˆ๋Š”์ง€๋„ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•˜์ฃ .


[keichee@server1 ~]$ last -x

keichee    pts/0        210.145.229.14   Fri Nov 10 11:09   still logged in

keichee    pts/0        210.145.229.14   Tue Nov  7 09:17 - 14:14  (04:57)

keichee    pts/0        210.145.229.143   Mon Nov  6 09:19 - 18:27  (09:07)

keichee    pts/2        204.130.143.176  Thu Nov  2 22:04 - 00:26  (02:21)

keichee    pts/1        103.170.103.116  Thu Nov  2 22:04 - 00:26  (02:22)

runlevel (to lvl 3)   3.10.0-514.16.1. Thu Jun 22 17:13 - 11:35 (140+18:22)
reboot   system boot  3.10.0-514.16.1. Thu Jun 22 17:13 - 11:35 (140+18:22)
shutdown system down  3.10.0-327.36.3. Thu Jun 22 17:11 - 17:13  (00:01)


๊ทธ๋Ÿผ ๋‘ ๋ฒˆ์งธ ๋ช…๋ น์–ด์˜€๋˜ who๋Š” ์–ด๋–ป๊ฒŒ ์“ธ๊นŒ์š”?


๊ธฐ๋ณธ์ ์œผ๋กœ who๋ฅผ ์“ธ ๋•Œ๋Š” ํ˜„์žฌ ๋‚ด๊ฐ€ ์–ด๋–ค ์‚ฌ์šฉ์ž๋กœ ์ ‘์†์„ ํ–ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์ฃ .


[keichee@server1 ~]$ who

keichee    pts/0        2017-11-10 11:09 (118.145.269.124)


help ์˜ต์…˜์œผ๋กœ ์–ด๋–ค ์˜ต์…˜์„ ์ถ”๊ฐ€๋กœ ์ค„ ์ˆ˜ ์žˆ๋Š”์ง€ ํ•œ๋ฒˆ ๋ณผ๊นŒ์š”?


[keichee@server1 ~]$ who  --help

Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]

Print information about users who are currently logged in.


  -a, --all         same as -b -d --login -p -r -t -T -u

  -b, --boot        time of last system boot

  -d, --dead        print dead processes

  -H, --heading     print line of column headings

  -l, --login       print system login processes

      --lookup      attempt to canonicalize hostnames via DNS

  -m                only hostname and user associated with stdin

  -p, --process     print active processes spawned by init

  -q, --count       all login names and number of users logged on

  -r, --runlevel    print current runlevel

  -s, --short       print only name, line, and time (default)

  -t, --time        print last system clock change

  -T, -w, --mesg    add user's message status as +, - or ?

  -u, --users       list users logged in

      --message     same as -T

      --writable    same as -T

      --help     display this help and exit

      --version  output version information and exit


์˜ต์…˜ ์ค‘์— -b ์˜ต์…˜์ด ๋งˆ์ง€๋ง‰ ์‹œ์Šคํ…œ ๋ถ€ํŒ… ์‹œ๊ฐ„์„ ์ถœ๋ ฅํ•œ๋‹ค๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๊ทธ๋Ÿผ ํ•œ ๋ฒˆ ์จ๋ณด์ฃ .

[keichee@server1 ~]$ who -b

         system boot  2017-06-22 17:13

17๋…„ 6์›” 22์ผ 17์‹œ 13๋ถ„์— ์‹œ์Šคํ…œ์ด ๊ธฐ๋™๋์Œ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


์ด์ƒ์ž…๋‹ˆ๋‹ค.


์˜ค๋Š˜์€ ์—ฌ๊ธฐ๊นŒ์ง€~ 

๋ฆฌ๋ˆ…์Šค ํ™˜๊ฒฝ์— ๋ฐฐํฌํ•œ WAR ๋˜๋Š” JAR ํŒŒ์ผ์— ์ƒˆ๋กœ์šด ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ๊ธฐ์กด ํŒŒ์ผ์„ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๋ฐฉ๋ฒ•


์•ˆ๋…•ํ•˜์„ธ์š”, ์ผ€์ด์น˜์ž…๋‹ˆ๋‹ค. 


์˜ค๋Š˜์€ ๋ฆฌ๋ˆ…์Šค ํ™˜๊ฒฝ์— ๋ฐฐํฌํ•œ WAR ๋˜๋Š” JAR ํŒŒ์ผ์— ์ƒˆ๋กœ์šด ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ๊ธฐ์กด ํŒŒ์ผ์„ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ๋ ค๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ทธ๋‹ฅ ์ด๋ ‡๊ฒŒ ํ•  ์ผ์ด ์—†๋‹ค๋ณด๋‹ˆ ํ•  ๋•Œ๋งˆ๋‹ค ๊ณ„์† ๊นŒ๋จน์–ด์„œ ๊ทธ๋ƒฅ ํ˜ผ์ž ๋„์ ์ผ๊ฒธ ์ ์–ด๋ด…๋‹ˆ๋‹ค.


์šฐ์„  /mydir/myapp.war ํŒŒ์ผ์ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.


์šฐ์„  ์ด ํŒŒ์ผ์•ˆ์— ์–ด๋–ค ํŒŒ์ผ์ด ์žˆ๋Š”์ง€๋ถ€ํ„ฐ ํ™•์ธํ•ด๋ณด์ฃ .


$ cd /mydir

$ ll    (๋˜๋Š” ls -l)

-rw-rw-r--. 1 keichee keichee 63378 Nov  6 11:37 myapp.war


$ unzip -l myapp.war


Archive:  myapp.war

  Length      Date    Time    Name

---------  ----------   -----    ----

        0  11-06-2017 11:28   META-INF/

     128  11-06-2017 11:28   META-INF/MANIFEST.MF

        0  11-06-2017 11:28   css/

        0  11-06-2017 11:28   images/

        0  11-06-2017 11:28   WEB-INF/

        0  11-06-2017 11:28   WEB-INF/classes/

        0  11-06-2017 11:28   WEB-INF/classes/com/

        0  11-06-2017 11:28   WEB-INF/classes/com/my/

.
.....์ค‘๋žต.....
.
  85308  08-14-2017 17:37   WEB-INF/lib/spring-oxm-4.3.0.RELEASE.jar
 587278  08-14-2017 17:37   WEB-INF/lib/spring-test-4.3.0.RELEASE.jar
 266993  08-14-2017 17:37   WEB-INF/lib/spring-tx-4.3.0.RELEASE.jar
 808847  08-14-2017 17:37   WEB-INF/lib/spring-web-4.3.0.RELEASE.jar
 905320  08-14-2017 17:37   WEB-INF/lib/spring-webmvc-4.3.0.RELEASE.jar
---------                           -------
 44109477                        393 files

WARํŒŒ์ผ์•ˆ์— ์–ด๋–ค ํŒŒ์ผ๋“ค์ด ๋“ค์–ด๊ฐ€์žˆ๋Š”์ง€ ๋””๋ ‰ํ† ๋ฆฌ ๊ฒฝ๋กœ๊นŒ์ง€ ์ „๋ถ€ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


์ด์ œ ํŒŒ์ผ ํ•˜๋‚˜๋ฅผ ์ถ”์ถœํ•ด๋ณด๋„๋ก ํ•˜์ฃ .


์ถ”์ถœํ•  ๋Œ€์ƒ์€ /META-INF/MANIFEST.MF ์ž…๋‹ˆ๋‹ค. ์‚ฌ์ด์ฆˆ๊ฐ€ 128์ด๊ตฐ์š”.


$ unzip myapp.war META-INF/MANIFEST.MF

Archive:  myapp.war

  inflating: META-INF/MANIFEST.MF

$ ll   (๋˜๋Š” ls -l )

-rw-rw-r--. 1 keichee keichee 44109477 Nov  6 11:37 myapp.war

drwxrwxr-x. 3 keichee keichee       17 Nov  9 14:42 META-INF

META-INF ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์ƒ์„ฑ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


$ cd META-INF

$ ls -l

-rw-rw-r--. 1 keichee keichee 128 Nov  6 11:28 MANIFEST.MF


ํŒŒ์ผ์ด ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์ด์ฆˆ๊ฐ€ 128๋กœ ์œ„์—์„œ ์กฐํšŒํ•œ ๊ฒƒ๊ณผ ๋™์ผํ•˜๋„ค์š”.


๊ทธ๋Ÿผ ํŒŒ์ผ์„ ์ˆ˜์ •ํ•ด๋ณผ๊นŒ์š”?


$ vi MANIFEST.MF


๋งˆ์Œ๋Œ€๋กœ ๋‚ด์šฉ์„ ์ˆ˜์ •ํ•ด์„œ ํŒŒ์ผ ์‚ฌ์ด์ฆˆ๊ฐ€ ๋‹ฌ๋ผ์ง€๋„๋ก ํ•ด์ฃผ์„ธ์š”.


$ ls -l

-rw-rw-r--. 1 keichee keichee 145 Nov  9 13:38 MANIFEST.MF


ํŒŒ์ผ์˜ ์‚ฌ์ด์ฆˆ์™€ ์‹œ๊ฐ„์ด ๋ณ€๊ฒฝ๋˜์—ˆ๋„ค์š”. 128 -> 145


๊ทธ๋Ÿผ ์ด ํŒŒ์ผ์„ ์ด์ œ ๋‹ค์‹œ WAR ํŒŒ์ผ์•ˆ์œผ๋กœ ์—…๋ฐ์ดํŠธํ•ด์„œ ๋„ฃ์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.


$ jar uvf myapp.war META-INF/MANIFEST.MF

adding: META-INF/MANIFEST.MF(in = 145) (out= 120)(deflated 17%)


ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•œ๋‹ค๊ณ  ๋‚˜์˜ค๋ฉด์„œ ์••์ถ•์ด ์–ผ๋งˆ๋‚˜ ๋๋Š”์ง€๊ฐ€ ๋‚˜์˜ค๋„ค์š”. 17%๊ฐ€ ์••์ถ•๋์Šต๋‹ˆ๋‹ค. ์ฐธ๊ณ ๋กœ ์—ฌ๊ธฐ์„œ in์€ ์‹ค์ œ ํŒŒ์ผ ์‚ฌ์ด์ฆˆ๊ณ  out์€ ์••์ถ•๋œ ํŒŒ์ผ์‚ฌ์ด์ฆˆ ์ž…๋‹ˆ๋‹ค.


๋งŒ์•ฝ jar ๋ช…๋ น์–ด๊ฐ€ ์—†์„ ๊ฒฝ์šฐ์—๋Š” zip ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

$ zip -r myapp.war META-INF/MANIFEST.MF

adding: META-INF/MANIFEST.MF(in = 145) (out= 120)(deflated 17%)



์ด์ œ ๋‹ค์‹œ myapp.war ํŒŒ์ผ์— ์–ด๋–ค ํŒŒ์ผ๋“ค์ด ์žˆ๋Š”์ง€ ์กฐํšŒํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.


$ unzip -l myapp.war


Archive:  myapp.war

  Length      Date    Time    Name

---------  ----------   -----    ----

        0  11-06-2017 11:28   META-INF/

     145  11-09-2017 13:38   META-INF/MANIFEST.MF

        0  11-06-2017 11:28   css/

        0  11-06-2017 11:28   images/

        0  11-06-2017 11:28   WEB-INF/

        0  11-06-2017 11:28   WEB-INF/classes/

        0  11-06-2017 11:28   WEB-INF/classes/com/

        0  11-06-2017 11:28   WEB-INF/classes/com/my/

.
.....์ค‘๋žต.....
.
  85308  08-14-2017 17:37   WEB-INF/lib/spring-oxm-4.3.0.RELEASE.jar
 587278  08-14-2017 17:37   WEB-INF/lib/spring-test-4.3.0.RELEASE.jar
 266993  08-14-2017 17:37   WEB-INF/lib/spring-tx-4.3.0.RELEASE.jar
 808847  08-14-2017 17:37   WEB-INF/lib/spring-web-4.3.0.RELEASE.jar
 905320  08-14-2017 17:37   WEB-INF/lib/spring-webmvc-4.3.0.RELEASE.jar
---------                           -------
 44109494                        393 files


ํŒŒ์ผ ์‚ฌ์ด์ฆˆ์™€ ๋‚ ์งœ๊ฐ€ ๋ณ€๊ฒฝ์ด ๋˜์—ˆ๋„ค์š”.

์ฐธ๊ณ ๋กœ ์—ฌ๊ธฐ์— ์กฐํšŒ๋˜๋Š” ํŒŒ์ผ์‚ฌ์ด์ฆˆ๋Š” ์••์ถ•๋˜๊ธฐ ์ „์˜ ํŒŒ์ผ ์‚ฌ์ด์ฆˆ์ž…๋‹ˆ๋‹ค.


๋ฆฌ๋ˆ…์Šค์—์„œ ๋ช…๋ น์–ด ํžˆ์Šคํ† ๋ฆฌ ์กฐํšŒ ํ•  ๋•Œ ๋‚ ์งœ ๋ฐ ์‹œ๊ฐ„ ํ•จ๊ป˜ ํ‘œ์‹œํ•˜๊ธฐ



๋ฆฌ๋ˆ…์Šค ํ™˜๊ฒฝ์—์„œ ์–ด๋–ค ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๊ทธ ๋ช…๋ น์–ด ๋ชฉ๋ก์ด history์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค. 


๊ทธ๋Ÿฐ๋ฐ ๊ทธ ๋ชฉ๋ก์ด ๋‹จ์ˆœํžˆ ๋ช…๋ น์–ด ๋ชฉ๋ก๋งŒ ์ˆœ์„œ๋Œ€๋กœ ๋‚˜์˜ฌ ๋ฟ ์ด๊ฒŒ ์–ธ์ œ ์‹คํ–‰์ด ๋˜์—ˆ๋Š”์ง€๋Š” ์•Œ ์ˆ˜๊ฐ€ ์—†์ฃ .


์ผ๋ฐ˜์ ์œผ๋กœ history๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค.



  421  ls -l

  422  ./listAlgorithms.sh

  423  cat ./listAlgorithms.sh

  424  cd ..

  425  ls -l

  426  cd lib

  427  ls -l

  428  ../bin/listAlgorithms.sh

  429  history


์—ฌ๊ธฐ์„œ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ–ˆ๋˜ ๋ช…๋ น์–ด๋ฅผ ์กฐํšŒํ• ๋•Œ ์–ธ์ œ์‹คํ–‰ ํ–ˆ๋Š”์ง€๋ฅผ ์•Œ์•„์•ผ ํ•  ๋•Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.


  ๊ทธ๋Ÿด ๊ฒฝ์šฐ ์‚ฌ์šฉ์ž ๊ณ„์ •์˜ ~/.bash_profile ํŒŒ์ผ์ด๋‚˜ /etc/profile์— HISTTIMEFORMAT ๋ณ€์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•ด ์ฃผ๋ฉด history๋ฅผ ์กฐํšŒํ•  ๋•Œ ๊ฐ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•œ ๋‚ ์งœ์™€ ์‹œ๊ฐ„์ด ํ‘œ์‹œ ๋ฉ๋‹ˆ๋‹ค.


1. ~/.bash_profile์ด๋‚˜ /etc/profile์— ์•„๋ž˜ ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.


  $ vi /etc/profile

.

.  

HISTTIMEFORMAT="%F %T - "

export HISTTIMEFORMAT

.

.



2. ์ ์šฉ


  $ . /etc/profile

๋˜๋Š”

  $ source /etc/profile


3. ํ™•์ธ


  $ history

  421  2017-11-02 18:48:16 - vi /etc/profile
  422  2017-11-02 18:48:22 - . /etc/profile
  423  2017-11-02 18:48:25 - history


์—ฌ๊ธฐ์„œ %F๋Š” ๋…„์›”์ผ์„ ํ‘œ์‹œํ•˜๋Š” ๊ฑฐ๊ณ  %T๋Š” ์‹œ๊ฐ„์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.


์ด ์™ธ์—๋„ history ๋ชฉ๋ก ๊ฐœ์ˆ˜๋ฅผ ์ง€์ •ํ•˜๊ฑฐ๋‚˜ history๋ฅผ ์ €์žฅํ•  ํŒŒ์ผ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ๋„ ์žˆ์Šต๋‹ˆ๋‹ค.


์—ญ์‹œ .bash_profile ์„ ์ˆ˜์ •ํ•ด์„œ ์•„๋ž˜ ๋‚ด์šฉ์„ ๋„ฃ์–ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๋ฌผ๋ก  ์ ์šฉ๋„ ์‹œ์ผœ์ค˜์•ผ๊ฒ ์ฃ .

export HISTSIZE=450      -> ํžˆ์Šคํ† ๋ฆฌ ๋ช…๋ น์–ด๋กœ ์กฐํšŒ์‹œ ๋ชฉ๋ก์— ์กฐํšŒ๋  ๊ฐœ์ˆ˜ export HISTFILESIZE=450    -> ํžˆ์Šคํ† ๋ฆฌ ํŒŒ์ผ์— ์ €์žฅํ•  ๋ชฉ๋ก ๊ฐœ์ˆ˜ export HISTFILE=~/history    -> ํžˆ์Šคํ† ๋ฆฌ๋ฅผ ์ €์žฅํ•  ํŒŒ์ผ

ํžˆ์Šคํ† ๋ฆฌ ๋ชฉ๋ก์—์„œ ์—ฐ์†์œผ๋กœ ์ž…๋ ฅํ•œ ๋™์ผํ•œ ๋ช…๋ น์–ด๋Š” ์ €์žฅํ•˜์ง€ ์•Š๋Š” ๊ธฐ๋Šฅ๋„ ์žˆ์Šต๋‹ˆ๋‹ค. 

export HISTCONTROL=ignoredups


- ํ˜„์žฌ ๋””๋ ‰ํ† ๋ฆฌ ํ•˜์œ„์˜ ๋ชจ๋“  file ํƒ€์ž… ๊ฐœ์ˆ˜ ๊ตฌํ•˜๊ธฐ

find . -type f|wc -l




- ํ˜„์žฌ ๋””๋ ‰ํ† ๋ฆฌ ํ•˜์œ„์˜ ๋ชจ๋“  ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ํŒŒ์ผ ํ™•์žฅ์ž๊ฐ€ class์ธ ํŒŒ์ผ ๊ฐœ์ˆ˜ ๊ตฌํ•˜๊ธฐ
find . -name '*.class' | wc -l

1. ํƒ€์ž…์ด ํŒŒ์ผ์ธ ๊ฒƒ๋“ค ์ค‘ ํŠน์ • ์ •๊ทœ์‹์— ํ•ด๋‹น๋˜๋Š” ํŒŒ์ผ ์กฐํšŒํ•˜๊ธฐ

find . -type f -regex '/ex/'



2. ํƒ€์ž…์ด ํŒŒ์ผ์ธ ๊ฒƒ๋“ค ์ค‘์—์„œ ํŠน์ • ์ •๊ทœ์‹์— ํ•ด๋‹น๋˜๋Š” ํŒŒ์ผ์„ ์‚ญ์ œํ•˜๊ธฐ

find . -type f -regex '/ex/' -exec rm {} \;



3. ํ™•์žฅ์ž๊ฐ€ class๊ฐ€ ์•„๋‹Œ ํŒŒ์ผํƒ€์ž… ์‚ญ์ œํ•˜๊ธฐ

find . -type f ! -name '*.class' -exec rm {} \;



4. ํ™•์žฅ์ž๊ฐ€ class๊ฐ€ ์•„๋‹ˆ๊ณ  java๋„ ์•„๋‹Œ ํŒŒ์ผ ํƒ€์ž… ์‚ญ์ œํ•˜๊ธฐ

find ./online/ -type f ! -name '*.class' ! -name '*.java' -exec rm {} \;



๊น”๋”ํ•˜๊ฒŒ ์ •๋ฆฌ๋˜์–ด์žˆ๋Š” ์ž๋ฃŒ๊ฐ€ ์žˆ์–ด์„œ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.


top ๋ช…๋ น ์‹คํ–‰์‹œ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋Š” ์˜ต์…˜

    * (top) -d [sec]: ์„ค์ •๋œ ์ดˆ๋‹จ์œ„๋กœ Refresh
    * (top) -c      : command๋’ค์— ์ธ์ž๊ฐ’ ํ‘œ์‹œ

top ๋ช…๋ น ์‹คํ–‰ ํ›„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์˜ต์…˜

    * shift + t     : ์‹คํ–‰๋œ ์‹œ๊ฐ„์ด ํฐ ์ˆœ์„œ๋กœ ์ •๋ ฌ
    * shift + m     : ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰์ด ํฐ ์ˆœ์„œ๋กœ ์ •๋ ฌ
    * shift + p     : cpu ์‚ฌ์šฉ๋Ÿ‰์ด ํฐ ์ˆœ์„œ๋กœ ์ •๋ ฌ
    * k             : Process ์ข…๋ฃŒ
       o k ์ž…๋ ฅ ํ›„ ์ข…๋ฃŒํ•  PID๋ฅผ ์ž…๋ ฅํ•œ๋‹ค
       o signal์„ ์ž…๋ ฅํ•˜๋ผ ํ‘œ์‹œ๋˜๋ฉด 9๋ฅผ ๋„ฃ์–ด์ค€๋‹ค
    * c             : ๋ช…๋ น ์ธ์ž ํ‘œ์‹œ / ๋น„ํ‘œ์‹œ
    * l(์†Œ ๋ฌธ์ž์—˜)   : uptime line(์ฒซ๋ฒˆ์งธ ํ–‰)์„ ํ‘œ์‹œ / ๋น„ํ‘œ์‹œ
    * space bar     : Refresh
    * u             : ์ž…๋ ฅํ•œ ์œ ์ € ์†Œ์œ ์˜ Process๋งŒ ํ‘œ์‹œ
       o which user: ์™€ ๊ฐ™์ด ์œ ์ €๋ฅผ ์ž…๋ ฅํ•˜๋ผ ํ‘œ์‹œ๋ ๋•Œ User๋ฅผ ์ž…๋ ฅ
       o blank(๊ณต๋ฐฑ) ์ž…๋ ฅ์‹œ ๋ชจ๋‘ ํ‘œ์‹œ
    * shift + b     : ์ƒ๋‹จ์˜ uptime ๋ฐ ๊ธฐํƒ€ ์ •๋ณด๊ฐ’์„ ๋ธ”๋ฝ์„ ํƒํ•ด ํ‘œ์‹œ
    * f             : ํ™”๋ฉด์— ํ‘œ์‹œ๋  ํ”„๋กœ์„ธ์Šค ๊ด€๋ จ ํ•ญ๋ชฉ ์„ค์ •


top ๋ช…๋ น ์‹คํ–‰ ํ›„ ํ™”๋ฉด

 top.PNG


์„ธ๋ถ€ ์ •๋ณด ํ•„๋“œ๋ณ„ ํ•ญ๋ชฉ


  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

    * PID : ํ”„๋กœ์„ธ์Šค ID (PID)
    * USER : ํ”„๋กœ์„ธ์Šค๋ฅผ ์‹คํ–‰์‹œํ‚จ ์‚ฌ์šฉ์ž ID
    * PRI : ํ”„๋กœ์„ธ์Šค์˜ ์šฐ์„ ์ˆœ์œ„ (priority)
    * NI : NICE ๊ฐ’. ์ผ์˜ nice value๊ฐ’์ด๋‹ค. ๋งˆ์ด๋„ˆ์Šค๋ฅผ ๊ฐ€์ง€๋Š” nice value๋Š” ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’์Œ.
    * VIRT : ๊ฐ€์ƒ ๋ฉ”๋ชจ๋ฆฌ์˜ ์‚ฌ์šฉ๋Ÿ‰(SWAP+RES)
    * RES : ํ˜„์žฌ ํŽ˜์ด์ง€๊ฐ€ ์ƒ์ฃผํ•˜๊ณ  ์žˆ๋Š” ํฌ๊ธฐ(Resident Size)
    * SHR : ๋ถ„ํ• ๋œ ํŽ˜์ด์ง€, ํ”„๋กœ์„ธ์Šค์— ์˜ํ•ด ์‚ฌ์šฉ๋œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋‚˜๋ˆˆ ๋ฉ”๋ชจ๋ฆฌ์˜ ์ดํ•ฉ.
    * S : ํ”„๋กœ์„ธ์Šค์˜ ์ƒํƒœ [ S(sleeping), R(running), W(swapped out process), Z(zombies) ]
    * %CPU : ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” CPU์˜ ์‚ฌ์šฉ์œจ
    * %MEM : ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ์˜ ์‚ฌ์šฉ์œจ
    * COMMAND : ์‹คํ–‰๋œ ๋ช…๋ น์–ด




์ถœ์ฒ˜ : http://faq.hostway.co.kr/?mid=Linux_ETC&page=7&document_srl=1441


CentOS 6๋ฅผ ์ฒ˜์Œ ์„ค์น˜ํ•˜๋ฉด Open JDK๊ฐ€ ๊ธฐ๋ณธ์ ์œผ๋กœ ์„ค์ •๋˜์–ด์žˆ๋‹ค. ํ•˜์ง€๋งŒ ๊ฐœ๋ฐœ์ž๋“ค์ด ์“ฐ๊ธฐ์—๋Š” ๊ทธ๋‹ฅ ์ ํ•ฉํ•˜์ง€ ์•Š์€๊ฒƒ ๊ฐ™๋‹ค. ์ด๋Ÿฐ์ €๋Ÿฐ ๋ฌธ์ œ๋„ ์ข€ ์žˆ๋Š”๊ฒƒ ๊ฐ™๊ณ . ๊ทธ๋ž˜์„œ ์ฐพ์•„๋ณด๋‹ค๊ฐ€ alternatives์— ๋Œ€ํ•ด์„œ ๋ณด๊ฒŒ๋˜์—ˆ๋‹ค.


[root@mycom ~]# alternatives


๋Œ€์ฒด ๋ฒ„์ „ 1.3.49.3 - Copyright (C) 2001 Red Hat, Inc.
GNU Public Licenseํ•˜์—์„œ ์ด ํ”„๋กœ๊ทธ๋žจ์„
์ž์œ ๋กญ๊ฒŒ ์žฌ๋ฐฐํฌ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์‚ฌ์šฉ๋ฒ•: alternatives --install <๋งํฌ> <์ด๋ฆ„> <๊ฒฝ๋กœ> <์šฐ์„ ์ˆœ์œ„>
                    [--initscript <์„œ๋น„์Šค>]
                    [--slave <๋งํฌ> <์ด๋ฆ„> <๊ฒฝ๋กœ>]*
       alternatives --remove <์ด๋ฆ„> <๊ฒฝ๋กœ>
       alternatives --auto <์ด๋ฆ„>
       alternatives --config <์ด๋ฆ„>
       alternatives --display <์ด๋ฆ„>
       alternatives --set <์ด๋ฆ„> <๊ฒฝ๋กœ>

์ผ๋ฐ˜ ์˜ต์…˜: --verbose --test --help --usage --version
                --altdir <๋””๋ ‰ํ† ๋ฆฌ> --admindir <๋””๋ ‰ํ† ๋ฆฌ>


์—ฌ๊ธฐ์„œ ์ € alternatives๋ผ๋Š” ์‹คํ–‰ํŒŒ์ผ์˜ ์‹ค์ œ๊ฒฝ๋กœ๋Š” /usr/sbin/alternatives ์ด๋‹ค.


์š”๋†ˆ์ด ๋ฌด์Šจ ์ผ์„ ํ•˜๋Š๋ƒํ•˜๋ฉด ๋งํฌ๋ฅผ ์ƒ์„ฑํ•˜๋Š”๋ฐ ์ด ๋งํฌ์˜ ๋Œ€์ƒ์ด ๋˜๋Š” ๋…€์„๋“ค์„ ์˜ต์…˜์œผ๋กœ ์—ฌ๋Ÿฌ๊ฐœ๋ฅผ ์ €์žฅ์„ ํ•ด๋†“์•˜๋‹ค๊ฐ€ ํ•„์š”ํ•  ๋•Œ ๋งˆ๋‹ค ๋ฐ”๊ฟ”๊ฐ€๋ฉฐ ์“ธ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.


๊ทธ๋Ÿผ ์ง€๊ธˆ ๋‚ด ์ปดํ“จํ„ฐ์—๋Š” java๋ช…๋ น์–ด์™€ ์—ฐ๊ฒฐ๋˜์–ด์žˆ๋Š” ์‹คํ–‰ํŒŒ์ผ๋“ค์ด ๋ช‡๊ฐœ๋‚˜ ๋˜๋Š”์ง€ ํ•œ๋ฒˆ ๋ณผ๊นŒ?


[root@mycom ~]$ /usr/sbin/alternatives --config java

1 ๊ฐœ์˜ ํ”„๋กœ๊ทธ๋žจ์ด 'java'๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

  ์„ ํƒ    ๋ช…๋ น
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

ํ˜„์žฌ ์„ ํƒ[+]์„ ์œ ์ง€ํ•˜๋ ค๋ฉด ์—”ํ„ฐํ‚ค๋ฅผ ๋ˆ„๋ฅด๊ณ , ์•„๋‹ˆ๋ฉด ์„ ํƒ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค:


์ž, ์ด๋Ÿฐ์‹์œผ๋กœ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ์˜ต์…˜์ด ๋‚˜์˜จ๋‹ค.


์ด์ œ ์„ ํƒ์˜ต์…˜์„ ํ•˜๋‚˜ ๋” ์ถ”๊ฐ€ํ•ด๋ณด์ž.


[root@Emerald ~]# alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_45/bin/java 2

[root@Emerald ~]# alternatives --config java

2 ๊ฐœ์˜ ํ”„๋กœ๊ทธ๋žจ์ด 'java'๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

  ์„ ํƒ    ๋ช…๋ น
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   2           /usr/java/jdk1.6.0_45/bin/java

ํ˜„์žฌ ์„ ํƒ[+]์„ ์œ ์ง€ํ•˜๋ ค๋ฉด ์—”ํ„ฐํ‚ค๋ฅผ ๋ˆ„๋ฅด๊ณ , ์•„๋‹ˆ๋ฉด ์„ ํƒ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค:2


alternatives --install ๋ช…๋ น์„ ์ด์šฉํ•˜์—ฌ /usr/bin/java ๋งํฌ์— /usr/java/jdk1.6.0_45/bin/java๋ฅผ java๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์—ฐ๊ฒฐ์„ ์‹œ์ผฐ๊ณ  ์šฐ์„ ์ˆœ์œ„๋ฅผ 2๋กœ ์ฃผ์—ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  alternatives --config ๋ช…๋ น์„ ์ด์šฉํ•ด์„œ ์„ ํƒ์„ 2๋ฒˆ์œผ๋กœ ๋ณ€๊ฒฝํ–ˆ๋‹ค.


์ด๋ ‡๊ฒŒ ์˜ต์…˜์œผ๋กœ ๋ช…๋ น์–ด์˜ ๋งํฌ๋ฅผ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋‚˜๋ฆ„ ์œ ์šฉํ•œ ํŒ์ด ์•„๋‹๊นŒ ์‹ถ๋‹ค.


๋” ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๊ตฌ๊ธ€๋ง์ด๋‚˜ manํŽ˜์ด์ง€๋ฅผ ์ฝ์–ด๋ณด์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค~~~









๋ฆฌ๋ˆ…์Šค ์„œ๋ฒ„์— ์›น์„œ๋ฒ„๋ฅผ ์„ค์น˜ํ•œ๋‹ค๋˜๊ฐ€ ํ•  ๋•Œ์— ํ”Œ๋žซํผ์— ๋งž์ถฐ์„œ ์„ค์น˜๋ฅผ ํ•ด์•ผํ•˜๋Š”๋ฐ ์ด๋•Œ ํ”Œ๋žซํผ์ด ๋ญ”์ง€ ๊นŒ๋จน๊ฑฐ๋‚˜ ๋‚ด๊ฐ€ ๋งŒ์ง€๋Š” ์„œ๋ฒ„๊ฐ€ ์•„๋‹ˆ๋ฉด ๋ชจ๋ฅผ ์ˆ˜ ๋ฐ–์— ์—†์ฃ . ๊ทธ๋Ÿด ๋•Œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.


# uname -a


์ด๋ ‡๊ฒŒ ํ–ˆ์„ ๋•Œ ๋‘๊ฐ€์ง€ ํ˜•ํƒœ๋กœ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ต๋‹ˆ๋‹ค.


1) x86  ( 32bit )

2) x86_64 ( 64bit )


๊ฐ„๋‹จํ•˜์ฃ ?

vi backup.sh

 

---------------------------------

#!/bin/sh
USER_ID=myId
PWD=myPwd

FILE_NAME=`ls -lrt /backup/*.gz|tail -1|cut -d ' ' -f 8`                // ํŒŒ์ผ๋ช…์€ ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด์„œ ์ž˜๋ผ๋‚ธ๋‹ค.

ftp -n 192.168.0.100 << SCRIPT
user $USER_ID $PWD
binary

cd /Backup           // ์›๊ฒฉ์ง€์˜ ๋ฐฑ์—…ํด๋” ๊ฒฝ๋กœ
put $FILE_NAME

quit

SCRIPT 

--------------------------------- 

:wq

 

์ด๋ ‡๊ฒŒ ๋ฐฑ์—…์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑ ํ•œ ๋’ค ์Šค์ผ€์ฅด๋Ÿฌ๋ฅผ ์ด์šฉํ•ด์„œ ์ด ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋งค๋‹ฌ, ๋งค์ฃผ, ํ˜น์€ ๋งค์ผ ๋ฐฑ์—…ํ•˜๋„๋ก ํ•˜๋ฉด ๋œ๋‹ค.

 

์Šค์ผ€์ฅด๋Ÿฌ๋Š” crond๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. 


๐Ÿ’ป Programming/Linux

vim ๋ช…๋ น์–ด ( vi commands )

< The list of Vim commands >

Working with files
Vim commandAction
:e filenameOpen a new file. You can use the Tab key for automatic file name completion, just like at the shell command prompt.
:w filenameSave changes to a file. If you don't specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name.
:qQuit Vim. If you have unsaved changes, Vim refuses to exit.
:q!Exit Vim without saving changes.
:wqWrite the file and exit.
:xAlmost the same as :wq, write the file and exit if you've made changes to the file. If you haven't made any changes to the file, Vim exits without writing the file.
These Vim commands and keys work both in command mode and visual mode.
Vim commandAction
j or Up ArrowMove the cursor up one line.
k or Down ArrowDown one line.
h or Left ArrowLeft one character.
l or Right ArrowRight one character.
eTo the end of a word.
ETo the end of a whitespace-delimited word.
bTo the beginning of a word.
BTo the beginning of a whitespace-delimited word.
0To the beginning of a line.
^To the first non-whitespace character of a line.
$To the end of a line.
HTo the first line of the screen.
MTo the middle line of the screen.
LTo the the last line of the screen.
:nJump to line number n. For example, to jump to line 42, you'd type :42
Inserting and overwriting text
Vim commandAction
iInsert before cursor.
IInsert to the start of the current line.
aAppend after cursor.
AAppend to the end of the current line.
oOpen a new line below and insert.
OOpen a new line above and insert.
CChange the rest of the current line.
rOverwrite one character. After overwriting the single character, go back to command mode.
REnter insert mode but replace characters rather than inserting.
The ESC keyExit insert/overwrite mode and go back to command mode.
Deleting text
Vim commandAction
xDelete characters under the cursor.
XDelete characters before the cursor.
dd or :dDelete the current line.
Entering visual mode
Vim commandAction
vStart highlighting characters. Use the normal movement keys and commands to select text for highlighting.
VStart highlighting lines.
The ESC keyExit visual mode and return to command mode.
Editing blocks of text
Note: the Vim commands marked with (V) work in visual mode, when you've selected some text. The other commands work in the command mode, when you haven't selected any text.
Vim commandAction
~Change the case of characters. This works both in visual and command mode. In visual mode, change the case of highlighted characters. In command mode, change the case of the character uder cursor.
> (V)Shift right (indent).
< (V)Shift left (de-indent).
c (V)Change the highlighted text.
y (V)Yank the highlighted text. In Windows terms, "copy the selected text to clipboard."
d (V)Delete the highlighted text. In Windows terms, "cut the selected text to clipboard."
yy or :y or YYank the current line. You don't need to highlight it first.
dd or :dDelete the current line. Again, you don't need to highlight it first.
pPut the text you yanked or deleted. In Windows terms, "paste the contents of the clipboard". Put characters after the cursor. Put lines below the current line.
PPut characters before the cursor. Put lines above the current line.
Undo and redo
Vim commandAction
uUndo the last action.
UUndo all the latest changes that were made to the current line.
Ctrl + rRedo.
Vim commandAction
/patternSearch the file for pattern.
nScan for next search match in the same direction.
NScan for next search match but opposite direction.
Replace
Vim commandAction
:rs/foo/bar/aSubstitute foo with bar. r determines the range and a determines the arguments.
The range (r) can be
nothingWork on current line only.
numberWork on the line whose number you give.
%The whole file.
Arguments (a) can be
gReplace all occurrences in the line. Without this, Vim replaces only the first occurrences in each line.
iIgnore case for the search pattern.
IDon't ignore case.
cConfirm each substitution. You can type y to substitute this match, n to skip this match, a to substitute this and all the remaining matches ("Yes to all"), and q to quit substitution.
Examples
:452s/foo/bar/Replace the first occurrence of the word foo with bar on line number 452.
:s/foo/bar/gReplace every occurrence of the word foo with bar on current line.
:%s/foo/bar/gReplace every occurrence of the word foo with bar in the whole file.
:%s/foo/bar/giThe same as above, but ignore the case of the pattern you want to substitute. This replaces foo, FOO, Foo, and so on.
:%s/foo/bar/gcConfirm every substitution.
:%s/foo/bar/cFor each line on the file, replace the first occurrence of foo with bar and confirm every substitution.

 

 

 

 

Reference:

http://www.tuxfiles.org/linuxhelp/vimcheat.html 


.bashrc๋Š” bash์ด ์‹คํ–‰๋  ๋•Œ๋งˆ๋‹ค ์ˆ˜ํ–‰๋˜๊ณ , .bash_profile์€ bash์ด login shell๋กœ ์“ฐ์ผ ๋•Œ(์ฆ‰ ์ฒ˜์Œ loginํ•  ๋•Œ)์— ์ˆ˜ํ–‰๋ฉ๋‹ˆ๋‹ค.

 

์ถœ์ฒ˜ : https://kldp.org/node/38265

Login Shell vs Non-login Shell

๋จผ์ € 'Login Shell'๊ณผ 'Non-login Shellโ€™ ์„ ๊ตฌ๋ถ„ํ•ด์•ผ ํ•˜๋Š”๋ฐ, ๋กœ๊ทธ์ธ์€ ๊ณ„์ •๊ณผ ์•”ํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์„œ Shell์„ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ssh๋กœ ์ ‘์†ํ•˜๊ฑฐ๋‚˜ ๋กœ์ปฌ์—์„œ GUI์—์„œ ๋กœ๊ทธ์ธํ•œ๋‹ค๋Š” ์˜๋ฏธ๋‹ค.

โ€˜.profileโ€™, โ€˜.bash_profile'์ด Loginํ•  ๋•Œ ๋กœ๋“œ๋˜๋Š”(source) ํŒŒ์ผ์ด๋‹ค. โ€™.profile'์€ ๊ผญ bash๊ฐ€ ์•„๋‹ˆ๋”๋ผ๋„ ๋กœ๊ทธ์ธํ•˜๋ฉด ๋กœ๋“œ๋˜๊ณ  โ€˜.bash_profile'์€ ๊ผญ Bash๋กœ Loginํ•  ๋•Œ ๋กœ๋“œ๋œ๋‹ค.

๊ทธ๋ฆฌ๊ณ  'Non-login Shell'์€ ๋กœ๊ทธ์ธ ์—†์ด ์‹คํ–‰ํ•˜๋Š” Shell์„ ๋งํ•œ๋‹ค. ssh๋กœ ์ ‘์†ํ•˜๊ณ  ๋‚˜์„œ ๋‹ค์‹œ bash๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๊ฒฝ์šฐ๋‚˜. GUI ์„ธ์…˜์—์„œ ํ„ฐ๋ฏธ๋„์„ ๋„์šฐ๋Š” ๊ฒƒ์ด ์ดํ•ด ํ•ด๋‹นํ•œ๋‹ค. 'sudo bash'๋‚˜ 'suโ€™ ๊ฐ™์€ ๊ฒƒ๋„ ์ด์— ํ•ด๋‹นํ•œ๋‹ค.

โ€˜.bashrc'๋Š” ๋กœ๊ทธ์ธ ์—†์ด Bash๊ฐ€ ์‹คํ–‰๋  ๋•Œ ๋กœ๋“œ๋œ๋‹ค. 'sudo bash'๋‚˜ 'su'๋กœ root ๊ถŒํ•œ์„ ์–ป์œผ๋ ค bash๋ฅผ ์‹คํ–‰ํ•  ๋•Œ๋„ ์ด ํŒŒ์ผ์ด ๋กœ๋“œ๋œ๋‹ค.

์ •๋ฆฌ:

  • โ€™.profile' - ๋กœ๊ทธ์ธํ•  ๋•Œ ๋กœ๋“œ๋œ๋‹ค. PATH์ฒ˜๋Ÿผ ๋กœ๊ทธ์ธํ•  ๋•Œ ๋กœ๋“œํ•ด์•ผ ํ•˜๋Š”๋ฐ bash์™€ ์ƒ๊ด€์—†๋Š” ๊ฒƒ๋“ค์„ ์—ฌ๊ธฐ์— ๋„ฃ๋Š”๋‹ค.
  • โ€˜.bash_profileโ€™ - ๋กœ๊ทธ์ธํ•  ๋•Œ ๋กœ๋“œ๋œ๋‹ค. โ€˜bash completion'์ด๋‚˜ 'nvm'๊ฐ™์ด ๋กœ๊ทธ์ธํ•  ๋•Œ ๋กœ๋“œํ•ด์•ผ ํ•˜๋Š”๋ฐ Bash์™€ ๊ด€๋ จ๋œ ๊ฒƒ์ด๋ฉด ์—ฌ๊ธฐ์— ๋„ฃ๋Š”๋‹ค.
  • โ€™.bashrc' - ๋กœ๊ทธ์ธํ•˜์ง€ ์•Š๊ณ  Bash๊ฐ€ ์‹คํ–‰๋  ๋•Œ๋งˆ๋‹ค ๋กœ๋“œ๋œ๋‹ค.

 

์ถœ์ฒ˜ : http://dogfeet.github.io/articles/2012/bash-profile.html


su์™€ su - ๋ชจ๋‘ root์˜ ๊ถŒํ•œ์œผ๋กœ ๋ณ€๊ฒฝ๋œ๋‹ค. ํ•˜์ง€๋งŒ ํ™˜๊ฒฝ๋ณ€์ˆ˜์—์„œ ์ฐจ์ด๊ฐ€ ์žˆ๋‹ค. 

su๋กœ root๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด root์˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ผ ๋‚ด ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

๋ฐ˜๋ฉด์— su - ๋กœ root๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด ๋‚ด ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ์•„๋‹Œ root์˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ๋‹ค.

 

์˜ˆ๋ฅผ ๋“ค์–ด ๋‚ด๊ฐ€ aaa๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธ์„ ํ•˜๋ฉด ๋‚˜๋Š” /home/aaa ๋‚ด์˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •ํŒŒ์ผ(.bashrc๋‚˜ .profile, .bash_profile๋“ฑ)์— ์„ค์ •๋˜์–ด์žˆ๋Š” ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ  ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ๋‹ค. ์ด๋•Œ su๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•˜์—ฌ root๊ฐ€ ๋˜์—ˆ๋‹ค๊ณ  ์น˜์ž. ๋‚˜๋Š” root๊ถŒํ•œ์„ ๊ฐ€์ง€๊ธฐ๋Š” ํ–ˆ์ง€๋งŒ ๋‚ด๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ํ™˜๊ฒฝ๋ณ€์ˆ˜๋“ค์€ aaa์˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋“ค์ด๋‹ค. ๋งˆ์น˜ root์˜ ๊ฐ€๋ฉด์„ ์“ด ๊ฒƒ๊ณผ ๊ฐ™์€๊ฒƒ์ด๋‹ค. root์™€ aaa์˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •์ด ๋™์ผํ•˜๋‹ค๋ฉด ๋ฌธ์ œ๋  ๊ฒƒ์ด ์—†๊ฒ ์ง€๋งŒ ์ผ๋ฐ˜์ ์œผ๋กœ ๊ทธ๋Ÿด์ผ์€ ๋ณ„๋กœ ์—†์„ ๊ฒƒ์ด๋‹ค. ๋ฐ˜๋ฉด์— su - ๋ช…๋ น์–ด๋กœ root๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด ๋‚˜๋Š” ์™„์ „ํžˆ root๋กœ ๋ณ€์‹ ํ•œ ๊ฒƒ๊ณผ ๊ฐ™๋‹ค. ํ™˜๊ฒฝ๋ณ€์ˆ˜๊นŒ์ง€ ๋ชจ๋‘ root์˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ์ด์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

 

๋ฌด์Šจ ๋ง์„ ํ•˜๋Š”์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ๋‹ค๊ณ ?? ์•„๋ž˜ ์˜ˆ์ œ๋ฅผ ๋ณด์ž.

 

 

kihyunhwang๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•ด์„œ echo๋ช…๋ น์–ด๋กœ PATHํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ์ถœ๋ ฅํ•ด๋ณด๊ณ , su๋กœ root๊ฐ€ ๋œ ๋’ค ๋˜ ์ถœ๋ ฅํ•ด๋ณด๊ณ , su -๋กœ root๊ฐ€ ๋˜์–ด ๋˜ ์ถœ๋ ฅํ•ด ๋ณด์•˜๋‹ค.

๊ฒฐ๊ณผ๋ฅผ ์ž˜ ๋ณด๋ฉด ์ฒซ๋ฒˆ์งธ ๋‘๋ฒˆ์งธ๋Š” PATH๋ณ€์ˆ˜์˜ ๊ฐ’์ด ๋™์ผํ–ˆ๋‹ค. ํ•˜์ง€๋งŒ ์„ธ๋ฒˆ์งธ PATH๋ณ€์ˆ˜ ๊ฐ’์€ ๋‹ค๋ฅด๋‹ค๋Š”๊ฒŒ ๋ณด์ผ๊ฒƒ์ด๋‹ค.

 

 

ํ•˜์ง€๋งŒ ์•„์ง ํ™•์‹ ์ด ์•ˆ์„œ๋Š” ๊ฒƒ์€ ๋ชจ๋“  ํ™˜๊ฒฝ๋ณ€์ˆ˜๊ฐ€ ๋ฐ”๋€Œ๋ƒ ์•ˆ๋ฐ”๋€Œ๋ƒ์ด๋‹ค. ํŠน์ • ํŒŒ์ผ์— ์žˆ๋Š” ๋ณ€์ˆ˜๋“ค๋งŒ ๋ฐ”๋€Œ๋Š” ๊ฑด์ง€ ์•„์ง ํ™•์ธ์„ ๋ชปํ•ด๋ณด์•˜๋‹ค. ์‹œ๊ฐ„์žˆ๋Š” ๋ถ„๋“ค์ด ํ™•์ธํ•ด์„œ ๋Œ“๊ธ€ ๋‹ฌ์•„์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌ ๊ฐ์‚ฌ!!

 

์ปค๋งจ๋“œ ๋ผ์ธ์—์„œ vi backup.sh๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•˜์—ฌ ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  ์•„๋ž˜์™€ ๊ฐ™์€ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋„ฃ๋Š”๋‹ค.

์•„๋ž˜ ์ปค๋งจ๋“œ๋Š” ์ž์‹ ์ด ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ํ™˜๊ฒฝ์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ ธ์•ผ ํ•œ๋‹ค๋Š” ์ ์€ ๋‹น์—ฐํžˆ ์•Œ๊ณ  ์žˆ๋Š” ๋ถ„๋“ค์ด ์ด ๊ธ€์„ ์ฝ์„ ๊ฒƒ์ด๋ผ ๋ณด๊ณ  ์ž์„ธํ•œ ์„ค๋ช…์€ ์ƒ๋žต.

(๋‚˜๋Š” backupํŒŒ์ผ์„ crond์— ๋“ฑ๋กํ•˜์—ฌ ๋งค๋‹ฌ 1์ผ์— NAS์„œ๋ฒ„๋กœ ๋ฐฑ์—…ํ•˜๋„๋ก ์„ค์ •ํ•˜์˜€๋‹ค.) 

====================================================================================== 

#!/bin/sh
USER_ID=yourid
PWD=yourpassword

FILE_NAME=`ls -lrt *.gz|tail -1|cut -d ' ' -f 8` 


CURR_DATE=`date +%Y%m%d%H%M`
FILE_NAME2=$CURR_DATE'_trac_backup.tar'

 

ftp -n 192.168.0.100 << SCRIPT
user $USER_ID $PWD
binary

cd /Backup
put $FILE_NAME
put $FILE_NAME2

quit

SCRIPT

 

rm $FILE_NAME 


๋ฆฌ๋ˆ…์Šค์—์„œ ์ž๋ฐ” ํ™ˆ ์„ค์ •ํ•˜๊ธฐ์ž…๋‹ˆ๋‹ค. 

 

๊ฐœ์ธ ๊ณ„์ •์—์„œ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ๋ชจ๋“  ๊ณ„์ •์„ ์œ„ํ•œ ์„ค์ •๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

(์ž๋ฐ”๋Š” ์ด๋ฏธ ์„ค์น˜๊ฐ€ ๋˜์–ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.)

Set JAVA_HOME / PATH for a single user

 

์ž์‹ ์˜ ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•ฉ๋‹ˆ๋‹ค.


$ vi ~/.bash_profile 

(์ƒ๋žต)
export JAVA_HOME=/usr/java/jdk1.6.0_45
export PATH=$PATH:/usr/java/jdk1.6.0_45/bin

(์ƒ๋žต)

 

์ด์ œ ์ €์žฅํ•˜๊ณ  vi์—์„œ ๋‚˜์™€์„œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค. 


$ source ~/.bash_profile
OR
$ . ~/.bash_profile

 

๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ์ ์šฉ์ด ๋๋Š”์ง€ ํ™•์ธํ•ฉ์‹œ๋‹ค.


$ echo $JAVA_HOME
$ echo $PATH


$ which java

 

Set JAVA_HOME / PATH for all user

์ด๊ฑด ๋ฌผ๋ก  root๊ถŒํ•œ์ด ์žˆ์–ด์•ผ ๊ฒ ์ฃ ? 

์ˆ˜์ •ํ•  ํŒŒ์ผ๋งŒ ๋ฐ”๋€” ๋ฟ ์‚ฝ์ž…ํ•˜๋Š” ๋‚ด์šฉ์€ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.


# vi /etc/profile
(์ƒ๋žต)

export JAVA_HOME=/usr/java/jdk1.6.0_45
export PATH=$PATH:/usr/java/jdk1.6.0_45/bin
(์ƒ๋žต)


์ €์žฅํ•˜๊ณ  ๋‚˜์™€์„œ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.


# source /etc/profile
OR
# . /etc/profille


๊ฐ‘์ž๊ธฐ ์„œ๋ฒ„์˜ ๋ฌผ๋ฆฌ์  ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์ด์ฆˆ๊ฐ€ ๊ถ๊ธˆํ•ด์กŒ๋‹ค.

 

๋ณดํ†ต ๋ฌผ๋ฆฌ์  ๋ฉ”๋ชจ๋ฆฌ์˜ ์‚ฌ์ด์ฆˆ๋Š” ๋ถ€ํŒ…ํ•  ๋•Œ ํ‘œ์‹œ๊ฐ€ ๋œ๋‹ค.

 

๊ทธ๋Ÿฐ๋ฐ ๋ง๊ทธ๋Œ€๋กœ ์„œ๋ฒ„์ด๋‹ˆ ๋งˆ์Œ๋Œ€๋กœ ๋‚ด๋ ธ๋‹ค๊ฐ€ ์˜ฌ๋ฆฌ๊ณ  ํ•  ์ˆ˜๋„ ์—†๋Š” ๋…ธ๋ฆ‡์ด๊ณ   

 

๋”ธ๋ž‘ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์ด์ฆˆ๋ณด์ž๊ณ  ์žฌ๋ถ€ํŒ…ํ•œ๋‹ค๋Š”๊ฑด ์–ด์ฒ˜๊ตฌ๋‹ˆ ์—†๋Š” ์ผ์ด๋‹ค.

 

๊ทธ๋ž˜์„œ ๊ตฌ๊ธ€๋ง์„ ํ•ด๋ณด์•˜๋‹ค.

 

๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด ์ค‘์— dmidecode๋ผ๋Š” ๋ช…๋ น์–ด๊ฐ€ ์žˆ๋‹ค.

 

์ด ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด์„œ ๋ฉ”๋ชจ๋ฆฌ์˜ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.

 

ํ•ด๋‹น ๋ช…๋ น์–ด์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์ง์ ‘ ๊ตฌ๊ธ€๋งํ•ด๋ณด์‹œ๊ธฐ๋กœ ํ•˜๊ณ  ์—ฌ๊ธฐ์„œ๋Š” ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ๋ช‡๊ฐœ๊ฐ€ ๋“ค์–ด๊ฐ€ ์žˆ๋Š”์ง€ ์‚ฌ์ด์ฆˆ๋Š” ์–ผ๋งŒ์ธ์ง€ ์•Œ ์ˆ˜ ์žˆ๋Š” ํ•„ํ„ฐ๋ง๋งŒ ์ œ๊ณต์„ ํ•˜๊ฒ ๋‹ค.

 

~]# dmidecode | grep 'Size.*MB'

 

์œ„ ๋ช…๋ น์–ด๋Š” ๋ฌผ๋ฆฌ์ ์ธ ๋ฉ”๋ชจ๋ฆฌ์— ๋Œ€ํ•œ ์‚ฌ์ด์ฆˆ ์ •๋ณด๋งŒ ๋ณด์—ฌ์ค€๋‹ค. ํ•˜์ง€๋งŒ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ๋กœ ๋‚˜๋‰˜์–ด์ ธ ์žˆ์„ ๊ฒฝ์šฐ ์—ฌ๋Ÿฌ ์ค„์ด ๋‚˜์˜ฌ ๊ฒƒ์ด๋‹ค.

์˜ˆ๋ฅผ๋“ค์–ด ์„œ๋ฒ„์˜ ์ด ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ 8GB์ธ๋ฐ 4GB x 2๊ฐœ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค๊ณ  ํ•˜๋ฉด ํ™”๋ฉด์—๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ๋‚˜์˜ฌ ๊ฒƒ์ด๋‹ค.

 

 Size: 4096 MB
 Size: 4096 MB

 

๋ช‡์ค„์ด ๋‚˜์˜ค๋ƒ๋Š” ๋ฌผ๋ฆฌ์  ๋ฉ”๋ชจ๋ฆฌ์˜ ๊ฐœ์ˆ˜๋ฅผ ๋‚˜ํƒ€๋‚ด๊ณ  ์‚ฌ์ด์ฆˆ๋Š” ๋‹ค ํ•ฉ์นœ๊ฒŒ ์ด ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์ด์ฆˆ๊ฐ€ ๋˜๋Š” ๊ฒƒ์ด๋‹ค.

 

๋˜ ๋‹ค๋ฅธ ๋ช…๋ น์–ด๋กœ๋„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ์•„๋งˆ ์ด๊ฒŒ ๋ณด๊ธฐ๋Š” ๋” ํŽธํ•  ๊ฒƒ์ด๋‹ค.

 

~]# cat /proc/meminfo

 

๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•˜๋ฉด ๋ฉ”๋ชจ๋ฆฌ์™€ ๊ด€๋ จ๋œ ๋ชฉ๋ก์ด ์ฃผ๋ฃจ๋ฃจ๋ฃจ~~~~~ใ„ฑ ๋‚˜์˜จ๋‹ค. ์ œ์ผ ์œ„์— ๋‚˜์˜ค๋Š” ๊ฒƒ์ด MemTotal์ธ๋ฐ kb๋‹จ์œ„๋กœ ๋‚˜์˜จ๋‹ค.


You need to use tar command as follows (syntax of tar command):
tar -zcvf [ํŒŒ์ผ๋ช….tar.gz] [์••์ถ•ํ•˜๊ณ ์žํ•˜๋Š”ํŒŒ์ผ/๋””๋ ‰ํ† ๋ฆฌ ๋ช…]
Where,

  • -z: Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name

For example, you have directory called /home/jerry/prog and you would like to compress this directory then you can type tar command as follows:

/home/jerry/prog ํด๋” ๋ฐ ํ•˜์œ„ ํด๋”์— ์žˆ๋Š” ๋ชจ๋“  ํŒŒ์ผ์„ prog.tar.gz ๋กœ ์••์ถ•
$ tar -zcvf prog.tar.gz /home/jerry/prog

Above command will create an archive file called prog-1-jan-2005.tar.gz in current directory. If you wish to restore your archive then you need to use following command (it will extract all files in current directory):

ํ˜„์žฌ ์œ„์น˜์—์„œ ์••์ถ•์„ ํ’€๊ณ ์ž ํ•  ๋•Œ
$ tar -zxvf prog-1-jan-2005.tar.gz

Where,

  • -x: Extract files

If you wish to extract files in particular directory, for example in /tmp then you need to use following command:

์›ํ•˜๋Š” ์œ„์น˜์— ์••์ถ•์„ ํ’€๊ณ ์ž ํ•  ๋•Œ
$ tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
$ cd /tmp
$ ls -

 

 

 

์ถœ์ฒ˜ : http://www.cyberciti.biz/faq/how-do-i-compress-a-whole-linux-or-unix-directory/

1. ์—…๋ฐ์ดํŠธํ•  ๋ชฉ๋ก์„ ๋ณด๋ ค๋ฉด?
# yum list updates


2. ์—…๋ฐ์ดํŠธ ๋ชฉ๋ก์„ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ , ์—…๋ฐ์ดํŠธ๋ฅผ ์„ค์น˜ํ•˜๋ ค๋ฉด?
# yum update -y


3. ์„ค์น˜๋œ rpm ํŒจํ‚ค์ง€ ๋ชฉ๋ก์„ ๋ณด๋ ค๋ฉด?
# rpm -qa
๋˜๋Š”
# yum list installed

4. gcc ํŒจํ‚ค์ง€๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ ํ•˜๋ ค๋ฉด?
# rpm -qa | grep gcc
๋˜๋Š”
# yum list installed gcc


5. gcc ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๋ ค๋ฉด?
# yum install gcc gcc-c++

6. gcc ํŒจํ‚ค์ง€๋ฅผ ์—…๋ฐ์ดํŠธ ํ•˜๋ ค๋ฉด?
# yum update gcc gcc-c++


7. ํŒจํ‚ค์ง€ ์ด๋ฆ„์œผ๋กœ ๊ฒ€์ƒ‰ํ•˜๋ ค๋ฉด?
# yum list ํŒจํ‚ค์ง€๋ช…
# yum list ์ •๊ทœ์‹
# yum list gcc
# yum list gcc*

8. ์—ฌ๋Ÿฌ๊ฐœ์˜ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๋ ค๋ฉด?
# yum install gcc gcc-c++


9. ํŒจํ‚ค์ง€๋ฅผ ์‚ญ์ œํ•˜๋ ค๋ฉด?
# yum remove gcc gcc-c++

10. ์„ค์น˜๊ฐ€ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ํŒจํ‚ค์ง€๋ฅผ ๋ณด๋ ค๋ฉด?
# yum list all

11. ํŒจํ‚ค์ง€ ๊ทธ๋ฃน์„ ๋ณด๋ ค๋ฉด?
# yum grouplist

12. ๊ทธ๋ฃน ํŒจํ‚ค์ง€๋ฅผ ๋ชจ๋‘ ์„ค์น˜ํ•˜๋ ค๋ฉด?
# yum groupinstall "Development Tools"

13. ๊ทธ๋ฃน ํŒจํ‚ค์ง€๋ฅผ ์—…๋ฐ์ดํŠธ ํ•˜๋ ค๋ฉด?
# yum groupupdate "Development Tools"

14. ๊ทธ๋ฃน ํŒจํ‚ค์ง€๋ฅผ ์‚ญ์ œํ•˜๋ ค๋ฉด?
# yum groupremove "Development Tools"

15. ์•„ํ‚คํ…์ฒ˜๋ฅผ ์ง€์ •ํ•˜์—ฌ ์„ค์น˜ํ•˜๋ ค๋ฉด?
# yum install mysql.i386

16. ํŒŒ์ผ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํŒจํ‚ค์ง€๋ช…์„ ์•Œ๋ ค๋ฉด?
# rpm -qf /etc/passwd
๋˜๋Š”
# yum whatprovides /etc/passwd

17. ๋งจํŽ˜์ด์ง€๋ฅผ ๋ณด๋ ค๋ฉด?
# man yum

์œ ๋‹‰์Šค ํ™˜๊ฒฝ์—์„œ ์ž๋™๋ฐฑ์—… ์‰˜ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋งŒ๋“ค๋‹ค๊ฐ€ ์–ป์€ ์ง€์‹์„ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.

 

๋ฐฑ์—…ํŒŒ์ผ์„ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•˜๋„๋ก ์Šค์ผ€์ฅด๋ง์„ ๊ฑธ์–ด๋†“์€ ์ƒํƒœ์—์„œ ๊ฐ€์žฅ ์ตœ์‹  ๋ฐฑ์—…ํŒŒ์ผ์„ ๊ณจ๋ผ์„œ ๋‹ค๋ฅธ ์›๊ฒฉ์„œ๋ฒ„๋กœ ftp๋ฅผ ์ด์šฉํ•ด์„œ ์ „์†กํ•˜๋ ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๋•Œ ๊ฐ€์žฅ ์ตœ์‹  ํŒŒ์ผ๋ช…์„ ์•Œ์•„์•ผ FTP๋ฅผ ์ด์šฉํ•ด์„œ ์ „์†ก์„ ํ•˜๊ฒ ์ฃ ?

 

๊ทธ๋ž˜์„œ ์ตœ์‹ ํŒŒ์ผ๋ช…๋งŒ ์–ป์–ด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด๋ฅผ ํ•œ๋ฒˆ ๋งŒ๋“ค์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

์šฐ์„  1์ฐจ๋กœ ๋งŒ๋“ค์–ด๋ณธ ๊ฒƒ์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

# ls -lrt *.gz|tail -1|cut -d ' ' -f 8

 

ํ•˜์ง€๋งŒ ์œ„ ์ฒ˜๋Ÿผ ํ•  ๊ฒฝ์šฐ ๋งŒ์•ฝ ์ŠคํŽ˜์ด์Šค๊ฐ€ ๋‘๊ฐœ ์ด์ƒ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ํŒŒ์ผ๋ช…์ด ์•„๋‹Œ ํŒŒ์ผ์ƒ์„ฑ ์‹œ๊ฐ„ ๊ฐ’์„ ์–ป์–ด์˜ค๊ฒŒ๋˜๋Š” ์—‰๋šฑํ•œ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ฌ ๋•Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ...

 

# ls -lrt *.gz|tail -1|tr -s ' '|cut -d ' ' -f 8

 

์ด๋ ‡๊ฒŒ tr ๋ช…๋ น์–ด๋ฅผ ์ค‘๊ฐ„์— ๋ผ์›Œ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค.

 

์ด ๋ช…๋ น์–ด์™€ ๋™์ผํ•œ ๊ฒฐ๊ณผ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋Š”๊ฒŒ ํ•˜๋‚˜ ๋” ์žˆ๋Š”๋ฐ ๊ทธ๊ฑด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

# ls -lrt *.gz|tail -1|awk '{print $8}`

 

์ด๋ ‡๊ฒŒํ•˜๋ฉด ์ข€ ๋” ์งง๊ณ  ๊ฐ„๋‹จํ•˜๊ฒŒ ํŒŒ์ผ๋ช…์„ ์–ป์–ด์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์„œ๋ฒ„์‹œ๊ฐ„์ด ๋กœ์ปฌ์‹œ๊ฐ„๊ณผ 10๋ถ„๊ฐ€๋Ÿ‰ ์ฐจ์ด๊ฐ€๋‚˜์„œ ํ†ต๊ณ„ ์ˆ˜์ง‘์‹œ ํ™•์ธํ•  ๋•Œ๋งˆ๋‹ค ํ—ท๊ฐˆ๋ ค์„œ ์‹œ๊ฐ„ ๋ณ€๊ฒฝ์„ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ•˜๋Š”์ง€ ์•Œ์•„๋ณด๋‹ค๊ฐ€ ์ฐพ์€ ์ •๋ณด์ž…๋‹ˆ๋‹ค.

Below information is from here

-----------------------------------------------------------------------------

Changing the timezone, date, and time

Setting your time zone

In /etc the file, localtime, is a link to or copy of a file containing information about your time zone. Zone information files are usually in /usr/share/zoneinfo but this depends on your distribution. So if your localtime file points to a zone info file that is not your time zone you can change it by browsing the directories in /usr/share/zoneinfo to find your country, then find your city or a city in the same time zone and link localtime to it.
    $ ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
Some applications may use the configuration file /etc/sysconfig/clock to determine the current time zone so it's a good idea to set the ZONE entry (e.g. "America/Los_Angeles").

Changing the date and time

Changing the date and time requires two steps. First, Linux's date and time must be changed and then the new time has to be written to the hardware clock.
The date command can be used for both viewing and changing the date and time.
To change the time use date followed by the month, day, hour, minute, and year all numeric and no spaces. So, to set the date and time to November 2nd, 2003 12:57
The hardware clock can be updated in UTC (coordinated universal time) or your local time. It is standard practice to update it in UTC.
To update it to your local time leave off the --utc or add --localtime and leave off the --utc.

Alternatively

The date and time can be changed directly to the hardware clock and then used to update the system clock.

Using NTP (Network Time Protocol)

NTP will connect to a server to get the atomic time. It can be downloaded from www.ntp.org/downloads.html To get started with NTP simply download it, install it, use the ntpdate command followed by a public time server, and update your hardware clock.
    $ ntpdate "server DNS name or IP address"
    4 Nov 22:31:28 ntpdate[26157]: step time server 209.81.9.7 offset 22317290.440932 sec
    $ hwclock --systohc
A public time server can be found at http://support.ntp.org/bin/view/Servers/WebHome

To keep your time accurate you can create a cron job that executes:
(the -w option is the same as --systohc)
    ntpdate "server name" && hwclock -w

To stay independent of a particiluar server you can use 0.pool.ntp.org (0, 1, or 2) for the server name. This domain uses DNS round robin to choose different time servers every so often. This keeps certain nameservers from having high loads. The only disadvantage is the increased potential of updating time from a nameserver who is in the pool but has an incorrect time settings.

These are volunteer public servers so be polite, do not constantly access the public servers, use only public servers (not private), and if you have multiple machines, set up a ntp server and have your other machines retrieve the time from your local server. Check http://www.eecis.udel.edu/~mills/ntp/servers.html for detailed rules.


์ถœ์ฒ˜ : http://www.hypexr.org/linux_date_time_help.php