Installing Gitolite 시스템 및 보안

Gitolite is an amazingly simple, self-hosting, git server, but it's not always easy to install.

Well I say that, but what I really mean to say is that the installation instructions on their site expect you to know a few things about *nix administration. It's easy enough to install, as their instructions state:

"If your Unix-fu and ssh-fu are good"

If you're not an every day linux user or a linux admin there are some implied steps that you're not going to know without doing some searching.

This article will hopefully be your replacement for those searches.

My Linux Setup

For this article I will be using a minimal install version CentOS 7, but these steps will work on most linux distros and FreeBSD. I've tested it on CentOS7 and Ubuntu 14.04.

My setup has the following packages installed:

  • epel-release (the repository for the latest Extra Packages for Enterprise Linux)
  • gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel git wxBase.x86_64 wget
  • esl-erlang
  • and Elixir

However, the only packages needed for this article are:

  • autoconf
  • git

If you'd like to setup a minimal install of CentOS 7 in VirtualBox on your own machine you can take a look at the following article for step-by-step instructions: 
Install CentOS 7 Minimal in VirtualBox

The Rundown

The rest of this article will provide step-by-step instructions for installing Gitolite on your machine.

For most of the steps you will need root privileges to install the necessary packages or run the necessary commands. I recommend using sudo or your OS's equivalent rather than using the root account.

Step 1 - Update

The first step to take, and this usually goes for any project you're working on, is to make sure the OS has the most up-to-date packages. Let's go ahead and run update.

[ ~]$ sudo yum -y update

I had roughly 68 out-of-date packages that needed to be updated when running yum -y update. That's not a bad amount of updates and the process only took a couple of minutes.

Yum Update

Step 2 - Add git user

The second step is to add the git user and give it a password.

[ ~]$  sudo adduser git[ ~]$  sudo passwd git

Add Git user

Step 3 - Install dependencies

If you haven't installed autoconf or git yet, go ahead and do so now. Those are the only two packages, missing from the minimal CentOS 7 install, actually required for Gitolite to work. There are a few dependencies that you'll see being installed, but all-in-all the install should only take roughly 45 seconds.

[ ~]$  sudo yum -y install autoconf git

Install Autoconf and Git

Step 4 - Get Gitolite

Now that our OS is up-to-date and has the necessary dependencies for Gitolite to operate let's go ahead and clone the gitolite repository from Github. We'll need to do this as the git user. We'll also need to make a bin directory in our $HOME directory so that we can create a symbolic link to gitolite after it's installed. Please take note that when we switch to the git user we need to change the working directory to the git user's home directory.

[ ~]$  su - git[ ~]$  cd ~

Next we make the ~/bin directory. Please take note of the ~ character when creating the directory. We use the ~ character here just in case we forgot to change directories into the git user's home directory.

[ ~]$ mkdir ~/bin

Now let's clone Gitolite's github repo.

[ ~]$ git clone git://

Clone the Gitolite github repo

Step 5 - Install Gitolite

This next operation didn't necessarily have to be separated into it's own step, but the title of my last step was Get Git, so it didn't really fit there. Installing Gitolite with this next commmand creates a symbolic link in our ~/bin folder.

For the install to work, we must be in the $Home directory of the git user and you must use the full path of the ~bin directory which in this case is just ~/bin. Using /bin or bin will NOT work.

[ ~]$ gitolite/install -ln ~/bin

Install Gitolite

That was pretty anti-climatic. You may or may not have noticed that we didn't get a confirmation or anything that the install was successful. Let's check our ~/bin directory now to see if the symbolic link was created.

[ ~]$ ls ~/bin

You should now see the link to gitolite in your ~/bin directory 
Symbolic Link

Step 6 - SSH Key Generation

Gitolite is now installed on our machine, but we aren't quite finished yet. We now have to setup Gitolite, and to do that we need an ssh key from an account other than the one we used to install it (our git user).

Let's create and send an ssh key from our local box and send it to our server.

On your local machine, or on an account other than git, create a new ssh key now (if you have one already skip this part).

Linux, FreeBSD, Mac OS X, and Windows users that have msysgit:

In your terminal

[ ~]$ ssh-keygen

SSH Key Generation

You'll notice that two keys have been generated for us. A public and private key. The public key is yours to share freely among sites that you will want to securely communicate with. The private key however, should be kept safe and sound in your .ssh directory and should never be shared.

Servers will encrypt data using their own private key and your public key and you will be able to unencrypt data using your private key and their public key, and vice versa. This keeps your data safe from man-in-the-middle attacks. A sniffer would have to know the private keys on both endpoints of the data flow in order to unencrypt any of the data they intercepted. They can have both public keys and never be able to unencrypt your data without those private keys.

Windows Users without msysgit:

Other Windows users will need to download PuTTY and follow the link below for directions to create a local ssh-key. Also it wouldn't hurt for Windows users to use WinSCP to transfer their public ssh key to the server.

Generate SSH Keys with PuTTYGen

Step 7 - Transferring our Public Key

Transferring our public key (notice I said public key) is by far the hardest part of getting Gitolite setup.

Now that our ssh keys have been generated we need to transfer the public key to our git user.

Linux, FreeBSD, Mac OS X, and Windows users that have msysgit:

In your terminal

First, from your $HOME directory, make a copy of your public ssh key (replace jeramy with the name of the account you are currently on):

[ ~]$ cp .ssh/

Copy ssh key

If you ssh in on the regular ssh port (22):

[ ~]$ scp :/home/git

If you ssh in on a port other than 22 like 2222:

[ ~]$ scp -P 2222 :/home/git

You will be prompted to input the git user's password and to add the git server to your list of known hosts. You'll want to input the password and select yes when that happens.


If the transfer was successful your git user's home directory should now contain your public key.

Git User's Home Directory After Key Transfer

Windows Users without msysgit:

Non-msysgit windows users will need to use WinSCP to transfer their public key over.

Step 8 - Refresh Bash and Finish Setup

We are almost done. The only steps left are to refresh the git user's .bash_profile and the final Gitolite setup command.

From the git user's home directory, as the git user, go ahead and refresh the .bash_profile now (Ubuntu users will need to refresh .profile instead.).

[ ~]$ source .bash_profile

You won't get any response back if the refresh was successful.

The final thing to do is setup Gitolite with our recently created ssh key.

[ ~]$ gitolite setup -pk

If you receive an error saying that the "gitolite" command cannot be found, make sure you refreshed your .bash_profile with source .bash_profile. This will add the symbolic link to gitolite, found in your ~/bin directory, to your path.

If all was successful you should see a couple of messages stating the initialization of empty Git repos, and maybe a couple of warnings about missing .ssh files. Don't worry, this is normal.

Setup Gitolite with Primary Key

Step 9 - Testing

Like any good developer or sysadmin we always want to test our work when it's done. Let's go ahead and do that now.

From within the account you created your public key, clone the gitolite-admin repository from your new Gitolite server.

[ ~]$ git clone :gitolite-admin

Your home directory should now contain the gitolite-admin folder and all its contents.

Gitolite Admin

Wrapping up

We now have a working remote git server (or local if that's what you're using it for). The setup really wasn't that hard at all, but we did fill in a few gaps left by the installation instructions on

I won't be going in to how to use Gitolite because there are a lot of great tutorials out there on how to use it. However, sometime in the near future I will be releasing a hobby project, using Elixir and the Phoenix Framework, that works with Gitolite, called Firebird.

Well, that's it for this article. Hopefully this helps out a few people that have been trying to get Gitolite installed.

오라클 - 테이블스페이스 정보보기 데이터베이스

테이블 스페이스의 데이터 파일과 테이블 스페이스의 크기 확인

DBA_DATA_FILES 데이터 사전을 이용 하면 됩니다. 


SELECT file_name, tablespace_name, bytes, status FROM DBA_DATA_FILES;

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

◎ FILE_NAME : DATAFILE의 물리적인 위치와 파일명을 알 수 있습니다. 
◎ TABLESPACE_NAME : 테이블 스페이스의 이름을 알 수 있습니다. 
◎ BYTES : 테이블 스페이스의 크기를 알수 있습니다. 
◎ STATUS : 테이블 스페이스의 이용 가능 여부를 알 수 있습니다. 

테이블 스페이스별 사용 가능한 공간의 확인 


SQL> SELECT tablespace_name, SUM(bytes), MAX(bytes)
GROUP BY tablespace_name

--------------- ---------- ----------
DRSYS 88268800 88268800
INDX 60809216 60809216
RBS 524279808 498589696
SYSTEM 65536 65536
TEMP 75489280 74244096
TOOLS 12574720 12574720
USERS 113238016 113238016

◎ SUM을 사용한 이유는하나의 테이블 스페이스에 분산되어 있는 여유공간을 합한 것이며,
◎ MAX를 사용한 이유는 여유 공간중 가장 큰 공간의 SIZE를 의미 합니다. 

데이타 화일에 대한 총 크기와 남아있는 공간, 사용한 용량, 남은 %율


SELECT b.file_name "FILE_NAME", -- DataFile Name
b.tablespace_name "TABLESPACE_NAME", -- TableSpace Name
b.bytes / 1024 "TOTAL SIZE(KB)", -- 총 Bytes
((b.bytes - sum(nvl(a.bytes,0)))) / 1024 "USED(KB)", -- 사용한 용량
(sum(nvl(a.bytes,0))) / 1024 "FREE SIZE(KB)", -- 남은 용량
(sum(nvl(a.bytes,0)) / (b.bytes)) * 100 "FREE %" -- 남은 %
WHERE a.file_id(+) = b.file_id 
GROUP BY b.tablespace_name, b.file_name, b.bytes
ORDER BY b.tablespace_name

------------------------------------- --------------- -------------- ------------- ------------- ----------
C:ORACLEORADATAORACLEDR01.DBF DRSYS 90112 3912 86200 95.6587358
C:ORACLEORADATAORACLERBS01.DBF RBS 532480 20488 511992 96.1523438

Ubuntu 16.04에 LAMP ( Apache2, Mysql 5.5, PHP5 ) 설치하는 방법 시스템 및 보안

Apache2 웹서버, Mysql DB서버, PHP를 설치하는 과정을 소개하고 마지막으로 php코드를 간단하게 작성하여 DB 서버로 데이터를 넣어보겠습니다.

Apache2 웹서버 설치

MYSQL DB 서버 설치

PHP 설치

phpMyAdmin 설치(옵션)

php를 이용하여 DB로 데이터 넣어보기

Apache2 웹서버 설치

$ sudo apt-get install apache2

별문제 없으면 웹브라우저에서 localhost 혹은로 접속시 다음과 같은 화면을 볼 수 있습니다.

MYSQL DB 서버 설치

$ sudo apt-get install mysql-server

설치 도중 아래와 같은 화면이 보이면 mysql 서버에 root 계정으로 로그인시 사용할 암호를 입력해 줍니다.

PHP 설치

PHP5와 PHP7을 같이 설치하는 방법을 설명합니다.

$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0 php5.6-mcrypt

설치 완료 후, 사용할 PHP 버전에 따라 다음 2가지 명령어들 중 하나를 입력합니다.

PHP5 디폴트 사용시

$ sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart
$ sudo update-alternatives --set php /usr/bin/php5.6

PHP7 디폴트 사용시

$ sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart
$ sudo update-alternatives --set php /usr/bin/php7.0

PHP가 정상적으로 설치되었는지 확인하기 위헤  /var/www/html경로에 info.php 파일을 편집기로 새로 열어서

$ sudo nano /var/www/html/info.php

다음 내용을 입력하고 저장해줍니다.


문제없이 설치가 되었다면 웹브라우저로 localhost/info.php 접속시 현재 디폴트로 설정된 PHP의 정보를 보여줍니다.

phpMyAdmin 설치(옵션)

웹 인터페이스로 mysql을 관리하기 위한 패키지입니다.

$ sudo apt-get install phpmyadmin

설치 도중 아래와 같은 화면이 보이면 스페이스바를 눌러 apache2를 선택하고 엔터를 누릅니다.

예를 선택하고 엔터를 누릅니다.

phpmyadmin에서 사용할 암호를 입력해줍니다.

이제 웹브라우저에서 localhost/phpmyadmin로 접속합니다.

사용자명에 root를 입력하고 암호에 mysql 서버의 root 계정 패스워드를 입력합니다.

실행을 클릭하면 로그인이 됩니다.

다음과 같은 화면을 볼 수 있습니다.

php를 이용하여 DB로 데이터 넣어보기

태스트를 위해 데이터베이스를 생성하고 간단한 테이블을 하나 생성합니다.  

정수형 데이터 하나만 저장할 것입니다.

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 86
Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database db;
Query OK, 1 row affected (0.00 sec)

mysql> use db;
Database changed
mysql> create table data ( num INT );
Query OK, 0 rows affected (0.02 sec)

mysql> exit

사용하는 PHP 버전에 따라 예제코드를 /var/www/html/insert.php 파일로 생성합니다.

PHP7용 코드

  $link = mysqli_connect("", "root", "패스워드", "db" );
  if ( !$link ){
     echo "Error: Unable to connect to MYSQL. ".PHP_EOL;
     echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
     echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;

  $num = $_GET["num"];
  $sql = "insert into data (num) values ($num)";
  $result = $link->query($sql);

     printf("Error: %s\n", $link->error);


PHP5 용 코드

if (mysqli_connect_errno($con))  
  echo "Failed to connect to MySQL: " . mysqli_connect_error();  

$sql="insert into data(num) values($num)";  
 echo 'success';  
 echo $sql;
 echo "<br />";
 echo 'failure';  

웹브라우저를 열어서 localhost/insert.php?num=100 으로 접속합니다.  

이렇게 하면 웹브라우저에서 php코드를 실행시 php  코드상에 있는 num 변수에 100을 넘겨주게 됩니다.  

php 에선 이 num에 입력된 값을 사용하여 값을 디비에 넣는 SQL문을 실행하게 됩니다.

이제 데이터베이스에서 값이 들어갔는지 확인해봅니다.

위에서 입력했던 값인 100이 테이블에 들어가 있는 것을 볼 수 있습니다.

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 125
Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from data;
| num  |
|  100 |
1 row in set (0.00 sec)

mysql> exit

Maven - .java파일과 함께 있는 resource 파일만 걸러내 classes 디렉토리에 복사하기 빌드자동화

Maven - .java파일과 함께 있는 resource 파일만 걸러내 classes 디렉토리에 복사하기


A Java deep clone (deep copy) example Java

While interviewing for computer programming positions in Boulder, Colorado, I found that most interviewers ask questions about Java serialization. After being asked about serialization for the third time recently, I suddenly remembered an old Java deep clonehack that takes advantage of serialization.

The basic idea is this:

  • You have a Java object, and you want to make a complete clone (copy) of it.
  • By marking your classes as being Serializable, you can write them out as an object stream, then read them back in as a different object.
  • When you read the object back in as a different object, you very quickly have a deep clone of your original object.

A Java deep clone method

Getting right to the answer, the following method will let you make a deep clone of a Java object:

/** * This method makes a "deep clone" of any Java object it is given. */ public static Object deepClone(Object object) {   try {     ByteArrayOutputStream baos = new ByteArrayOutputStream();     ObjectOutputStream oos = new ObjectOutputStream(baos);     oos.writeObject(object);     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());     ObjectInputStream ois = new ObjectInputStream(bais);     return ois.readObject();   }   catch (Exception e) {     e.printStackTrace();     return null;   } }

As you’ll see in the following example, you can call this method something like this:

// (1) create a Person object named AlAddress address = new Address("305 West Fern Avenue", "Palmer", "Alaska");Person al = new Person("Al", "Alexander", address);// (2) make a deep clone of AlPerson neighbor = (Person)deepClone(al);

In this code, the neighbor object is a deep clone of the al object.

1 2 3 4 5 6 7 8 9 10 다음