분류 전체보기 (356)

설치를 하지않고 사용할 수 있는 포터블 버전의 크롬 브라우저를 다운로드 하는 방법입니다.



1. 아래 링크를 통해서 크롬 포터블 다운로드 페이지로 이동합니다.


http://portableapps.com/apps/internet/google_chrome_portable



2. 이동한 페이지에서 아래와 같은 다운로드 버튼을 찾아서 클릭하고 exe파일을 다운로드합니다.


3. 다운로드받은 설치파일을 실행시키면 마치 인스톨러를 실행시킨것처럼 창이 뜨지만 실제로 설치하는것이 아니라 그냥 크롬 포터블 버전을 다운로드하는 것입니다. 그러니 안심하시고 "다음"을 누르시면 됩니다.



4. 다운로드받은 크롬 포터블 버전을 실행시켜보세요 ^^




Tip. 크롬내에서 이런 저런 설정을 변경하시고 사용하시다가 업데이트 하시는 경우에는 data폴더의 profile폴더내의 파일들을 백업했다가 새 버전의 크롬 포터블을 다운로드 받은 뒤에 덮어쓰기를 하시면 기존에 사용하시던 설정 환경을 그대로 재사용하실 수 있습니다.


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 


💻 Programming/Linux

.bashrc 와 .bash_profile의 차이점

.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변수 값은 다르다는게 보일것이다.

 

 

하지만 아직 확신이 안서는 것은 모든 환경변수가 바뀌냐 안바뀌냐이다. 특정 파일에 있는 변수들만 바뀌는 건지 아직 확인을 못해보았다. 시간있는 분들이 확인해서 댓글 달아주시면 감사 감사!!

 

💻 Programming/Linux

FTP를 이용한 binary 데이타 백업

커맨드 라인에서 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/

💻 Programming/Linux

[ Linux / CentOS 6.6 ] yum 명령어 사용하기

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

특정 테이블의 제약사항( not null, fk 과 같은 )의 이름, 테이블명, 소유자의 목록을 보여줍니다.

Below query command queries constraints'(not null, fk) name , owner, table name, column name, and position of the column.


SQL > select * from user_cons_columns where table_name='table_name';

테이블 백업을 할때에 export / import 를 이용할 수도 있지만 단순하게 rename 명령어를 이용할 수도 있습니다. 또한 create ~ as select ~ 를 이용할 수도 있습니다.

하지만 오늘은 테이블 명을 변경하고 새로 테이블을 생성함으로써 백업을 할 수 있는 방법을 소개하도록 하겠습니다. 참고로 이 방법은 blob데이타가 많은 경우에 상당히 유용합니다.


Step by Step

1) Query table name and index names linked to the table you want to backup

2) Rename table name

3) Rename indexes' name ( if specified explicitly when it is created )

4) Rename constraints' name ( if specified explicitly when it is created )

4) Use the same DDL used to create the renamed table


※ This way is very simple and fast then using "create table ~ as select * from ~" statement when the table has a huge blob data.



1) 변경하고자하는 테이블에 어떤 인덱스들이 있는지 조회합니다.

SQL > select index_name, table_name from user_indexes;


2) 테이블명을 변경합니다.

SQL > rename old_table to new_table;


3) 인덱스명을 변경합니다. ( 인덱스명이 자동생성된 것이 아닌 경우에만 )

SQL > alter index pk_old_table rename to pk_new_table;


4) 제약사항명을 변경합니다. ( 제약사항명이 자동생성된 것이 아닌 경우에만 )

SQL > select * from user_cons_columns where table_name='{table_name};

SQL > alter table {table name} rename constraint {constraint name} to {new constraint name}


5) 기존 테이블을 생성했던 DDL을 사용하여 테이블을 새로 생성합니다.

SQL > create table .........



오늘은 테이블 명 변경하는 법에 대해서 알아보도록 하겠습니다.


테이블 명을 변경할 때는 아래처럼 rename 명령어를 사용합니다.

Use rename command to rename a table to a new one.


SQL > rename {old table name} to {new table name}

Table renamed.


변경이 완료되었는지 아래쿼리를 이용해서 확인해보세요.

Check if renaming was successful using below query. Below statement queries the table names owned by you.


SQL > select table_name from user_tables;


You would see renamed table name if it was successful.





💻 Programming/Oracle 11g

인덱스 목록 조회 ( Querying Index List )

일반유저로 내가 가지고 있는 인덱스 목록을 조회하려면 아래 쿼리를 사용합니다.

Querying index list owned by me.


SQL > select * from user_indexes;

Better to use below query to know which index is from which table because there are so many information on the user_indexes table.

위 쿼리를 실행하면 상당히 많은 양의 정보가 나오게 됩니다. 어느 테이블에 어느 인덱스가 있는지가 궁금하다면 아래 쿼리를 이용하시면 됩니다.

SQL > select index_name, table_name from user_indexes;