Centos7 에서 yum install maven 으로 maven 을 설치하면 3.0.5 버전이 설치가 된다.

이보다 높은 버전을 설치하고 싶다면 다음과 같이 수동으로 maven 을 설치해야한다.

Apache Maven 3.6.3 설치 예제

// 바이너리 다운로드
$ wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp

// /opt 폴더에 압축 해제
$ sudo tar -xzvf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt

// 소프트링크 생성
$ sudo ln -s /opt/apache-maven-3.6.3 /opt/maven

// 환경셋업 스크립트 생성
$ sudo vi /etc/profile.d/maven.sh
#JAVA 설정 되어있다면 무시
#export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

// 환경셋업 스크립트 실행
$ source /etc/profile.d/maven.sh

// Maven 버전 확인
$ mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/maven

참고: yallalabs.com/devops/how-to-install-apache-maven-centos-7-rhel-7/

Posted by leechwin
,

소개

Windows 환경에 python 환경 설정하는 법

 

다운로드

Python 다운로드 및 설치

Python 경로 확인

  • Windows key -> IDLE (Python xxx) 실행
  • IDLE 에서 File -> Open -> 현재경로를 저장해놓음
    • ex) C:\Users\leechwin\AppData\Local\Programs\Python\Python39

Windows 환경에 python 환경 설정하는 법

 

환경변수설정

시스템 속성 창열기

  1. 실행창 열기: Windows key + r  동시입력
  2. sysdm.cpl ,3 입력

고급 -> 환경변수 -> Path -> 편집

  • 위에서 저장해놓은 Python 경로를 입력

 

설정확인

명령프롬프트 내에서 pip 명령어 확인

  • Windows key -> r
  • cmd 입력
  • pip 입력시 help document 가 나오는것 확인

 

Posted by leechwin
,

Git 이용시 Terminal 에서 "git branch" 명령을 입력안해도 현재 Branch 가 보이도록 설정하는 방법

 

.bashrc 파일에 다음과 같이 입력.

  • $ vi ~/.bashrc
parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\] $"

 

적용되면 다음과 같이 나타난다.

// 적용전
leechwin@leechwin-linux:~/git/my-project $

// 적용후
leechwin@leechwin-linux:~/git/my-project (develop) $
Posted by leechwin
,

리눅스에 ssh 등으로 접속하다가 password 기간 만료로 새로 변경해야 되는 경우가 있다.

이때 임시로 password 를 변경하고, 다시 passwd 명령으로 변경하려면 다음과 같은 에러와 함께 변경이 안되는 경우가 있다.

(current) UNIX password: 
You must wait longer to change your password
passwd: Authentication token manipulation error

 

접속된 사용자가 passwd 명령에 대한 권한이 없는등 여러가지 문제가 있을 수 있는데,

chage 명령으로 사용자 password 등에 관련된 정보를 한번 확인해보면 문제를 파악 할 수 있는 경우가 있다.

Usage: chage [options] LOGIN

Options:
  -d, --lastday LAST_DAY        set date of last password change to LAST_DAY
  -E, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -h, --help                    display this help message and exit
  -I, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -l, --list                    show account aging information
  -m, --mindays MIN_DAYS        set minimum number of days before password
                                change to MIN_DAYS
  -M, --maxdays MAX_DAYS        set maximim number of days before password
                                change to MAX_DAYS
  -R, --root CHROOT_DIR         directory to chroot into
  -W, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS

 

자신의 계정 정보를 확인해본다.

chage -l leechwin
Last password change				        : 10월 10, 2019
Password expires					:  1월 08, 2020
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 7
Maximum number of days between password change		: 90
Number of days of warning before password expires	: 7

 

계정 정보에 Minimum number of days between password change 부분이 7로 되어있는데 passwd 로 password 를 바꾼뒤에 7일뒤에 다시 passwd 로 password 를 바꿀 수 있다는 의미이다.

passwd 로 password 를 무한정 바꾸고 싶다면 다음 명령어로 해당 정보를 0 으로 설정 하면 된다.(단 root 계정으로 변경 실행해야 한다.)

# chage -d 0 leechwin

 

혹은 "/etc/shadow" 파일에 user 정보를 직접 수정가능하다.

 

Reference

Posted by leechwin
,

리눅스에서 설정파일이나 스크립트 파일을 수정한 뒤에 재부팅을 하지않고, 수정내용을 바로 적용하려면 source 명령을 수행하면 된다.

source 명령은 bash 내부 명령으로 포함되어있다.


  • $ source <script file>


Posted by leechwin
,

리눅스에서는 로그파일을 실시간으로 확인하는 방법중에 하나로 tail 명령에 대해 알아보자.


  • Tail
    • $ tail -f <대상파일>
    • 위와 같이 실행하면 대상 파일의 마지막 10라인을 출력하며, 해당 파일에 추가되는 행을 계속 출력하여 준다.


  • 옵션
    • f: 파일의 마지막 10라인을 실시간으로 계속 해서 출력한다.
    • n: 기본 10라인이 아닌 n 만큼의 라인을 출력한다.
      • $ tail -n 20 <대상파일>


  • Help 문서

  •  Usage: tail [OPTION]... [FILE]...

     Print the last 10 lines of each FILE to standard output.

     With more than one FILE, precede each with a header giving the file name.


     With no FILE, or when FILE is -, read standard input.


     Mandatory arguments to long options are mandatory for short options too.

      -c, --bytes=[+]NUM       output the last NUM bytes; or use -c +NUM to

                                 output starting with byte NUM of each file

      -f, --follow[={name|descriptor}]

                               output appended data as the file grows;

                                 an absent option argument means 'descriptor'

      -F                       same as --follow=name --retry

      -n, --lines=[+]NUM       output the last NUM lines, instead of the last 10;

                                 or use -n +NUM to output starting with line NUM

          --max-unchanged-stats=N

                               with --follow=name, reopen a FILE which has not

                                 changed size after N (default 5) iterations

                                 to see if it has been unlinked or renamed

                                 (this is the usual case of rotated log files);

                                 with inotify, this option is rarely useful

          --pid=PID            with -f, terminate after process ID, PID dies

      -q, --quiet, --silent    never output headers giving file names

          --retry              keep trying to open a file if it is inaccessible

      -s, --sleep-interval=N   with -f, sleep for approximately N seconds

                                 (default 1.0) between iterations;

                                 with inotify and --pid=P, check process P at

                                 least once every N seconds

      -v, --verbose            always output headers giving file names

      -z, --zero-terminated    line delimiter is NUL, not newline

          --help     display this help and exit

          --version  output version information and exit



Posted by leechwin
,

리눅스에서는 파일이나 디렉토리를 연결하는 링크의 개념이 있는데, 이 링크를 'ln' 명령으로 만들 수 있다.

링크는 하드링크(hard link)와 심볼릭링크(symbolic link) 2개의 종류로 만들 수 있다.

  • 하드링크
    • 하드링크 생성
      • $ ln <source> <target>
    • 하드링크는 원본파일과 동일한 내용의 다른 파일이다.
    • 원본파일의 내용이 변경되면 하드링크된 파일의 내용도 자동으로 변경된다.
    • 디렉토리는 하드링크 할 수 없다.


  • 심볼릭링크
    • 심볼릭링크 생성
      • $ ln -s <source> <target>
    • 심볼릭링크는 기존 파일을 가리키도록 링크만 되어있는 특별한 유형의 파일로 '바로가기'와 비슷한 파일이다.
    • 디렉토리도 심볼릭링크 가능하다.
    • 심볼릭 링크가 가리키고있는 파일이 변경되거나 삭제되면, 제동작을 하지 못하고, 해당링크는 'dangling soft link' 라고 한다.

  • Help 문서

  •  Usage: ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)

      or:  ln [OPTION]... TARGET                  (2nd form)

      or:  ln [OPTION]... TARGET... DIRECTORY     (3rd form)

      or:  ln [OPTION]... -t DIRECTORY TARGET...  (4th form)

     In the 1st form, create a link to TARGET with the name LINK_NAME.

     In the 2nd form, create a link to TARGET in the current directory.

     In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.

     Create hard links by default, symbolic links with --symbolic.

     By default, each destination (name of new link) should not already exist.

     When creating hard links, each TARGET must exist.  Symbolic links

     can hold arbitrary text; if later resolved, a relative link is

     interpreted in relation to its parent directory.


     Mandatory arguments to long options are mandatory for short options too.

          --backup[=CONTROL]      make a backup of each existing destination file

      -b                          like --backup but does not accept an argument

      -d, -F, --directory         allow the superuser to attempt to hard link

                                    directories (note: will probably fail due to

                                    system restrictions, even for the superuser)

      -f, --force                 remove existing destination files

      -i, --interactive           prompt whether to remove destinations

      -L, --logical               dereference TARGETs that are symbolic links

      -n, --no-dereference        treat LINK_NAME as a normal file if

                                    it is a symbolic link to a directory

      -P, --physical              make hard links directly to symbolic links

      -r, --relative              create symbolic links relative to link location

      -s, --symbolic              make symbolic links instead of hard links

      -S, --suffix=SUFFIX         override the usual backup suffix

      -t, --target-directory=DIRECTORY  specify the DIRECTORY in which to create

                                    the links

      -T, --no-target-directory   treat LINK_NAME as a normal file always

      -v, --verbose               print name of each linked file

          --help     display this help and exit

          --version  output version information and exit

     



Posted by leechwin
,

Synergy 의 client 중에 하나가 Mac 일경우, Mac 스크린락이 동작하면 Synergy Host 에서 키가 동작하지 않아 난감한 상황이 닥치곤 한다.

이때에는 Mac 에서 다음과 같은 방법으로 설정하여 Mac의 자동실행 항목으로 Synergy 를 등록하면 Mac 에 스크린락이 동작하여도 Synergy Host 의 키입력이 동작한다.


Mac 에서 자동실행 항목 등록 방법

  1. 시스템 환경설정 클릭
  2. 현재 사용자의 로그인 항목 탭 클릭
  3. 하단에 '+' 버튼 클릭
  4. 응용 프로그램에서 Synergy 항목을 선택 후 추가
  5. 로그인할때 자동으로 실행됩니다. 목록에 Synergy 가 추가되었다면, 이후 스크린락이 동작하여도 Synergy 도 정상 동작한다.


Posted by leechwin
,

Ubuntu 에서 sudo 권한이 필요할때 특정 사용자와 특정 명령어에 대해 root password를 물어보지 않고 실행되게 할 수 있다.


다음 명령어를 수행하면 sudo 권한 파일을 수정 할 수 있다.

  • $ sudo visudo
  • $ sudo visudo

    # # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d # Allow member and tool # leechwin ALL=(ALL) NOPASSWD:ALL # leechwin ALL=(ALL) NOPASSWD: /usr/sbin/chroot, /bin/kill, /usr/bin/killall

  • visudo 수행 후 나오는 에디터 하단에 다음과 같은 형식으로 기술하면 된다.
    • {user} ALL=(ALL) NOPASSWD: {tool path}
  • leechwin 이라는 사용자에게 chroot, kill, killall 에대한 명령에 대해서 sudo 권한을 주어지게 할 경우 다음과 같이 기술 할수 있다.
    • leechwin ALL=(ALL) NOPASSWD: /usr/sbin/chroot, /bin/kill, /usr/bin/killall
  • command path 는 다음 명령으로 확인 가능하다.
    • $ which {tool name}

visudo 에서 수정된 파일은 다음 파일에 저장된다.

  • /etc/sudoers


'OS > Linux' 카테고리의 다른 글

[Ubuntu] tail 명령으로 로그 확인하기  (0) 2019.02.27
[Ubuntu] ln 명령으로 링크 만들기  (0) 2019.02.27
[Ubuntu] hostname 변경  (0) 2017.01.19
[Ubuntu] Word Count  (0) 2017.01.19
[Ubuntu] Memory 확인  (0) 2017.01.19
Posted by leechwin
,

[Ubuntu] hostname 변경

OS/Linux 2017. 1. 19. 16:00

Ubuntu에서 현재 컴퓨터의 이름인 hostname 을 변경하는 법에 대해 알아보자.


현재 hostname은 shell 에서 $ hostname 명령을 통하여 알 수 있다.


hostname을 수정하려면 다음 2개의 파일을 원하는 이름으로 수정하고 재부팅하면 hostname이 수정되어 반영된다. 

  • sudo vi /etc/hostname
  • sudo vi /etc/hosts

$ hostname

leechwin-linux $ cat /etc/hostname leechwin-linux $ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 leechwin-linux # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters



'OS > Linux' 카테고리의 다른 글

[Ubuntu] ln 명령으로 링크 만들기  (0) 2019.02.27
[Ubuntu] sudo 권한 등록  (0) 2017.08.09
[Ubuntu] Word Count  (0) 2017.01.19
[Ubuntu] Memory 확인  (0) 2017.01.19
[Ubuntu] Filesystem 용량 확인  (0) 2017.01.19
Posted by leechwin
,