2014년 12월 24일 수요일

CentOS에서 sudo 명령어 사용

CentOS는 일반사용자가 루트권한을 일시적으로 획득하는 sudo 명령어가 비활성 상태이다.
/etc/sudoers 파일을 수정하면 CentOS에서도 sudo를 이용할 수 있다.


[root@cet dev]$ ls -al /etc/sudoers
-r--r----- 1 root root 3381  3월 11  2014 /etc/sudoers

[root@cet dev]$ chmod u+w /etc/sudoers

[root@cet dev]$ ls -al /etc/sudoers
-rw-r----- 1 root root 3381  3월 11  2014 /etc/sudoers


[root@cet dev]# tail /etc/sudoers
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

## Allows members of the users group to mount and unmount the
## cdrom as root
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

/etc/sudoers 파일에 설정 추가

[root@cet ~]$ vi /etc/sudoers

# 특정 사용자가 sudo를 사용할 수 있도록 설정.
dev   ALL=(ALL)       ALL

# 그룹내에 모든 사용자가 이용할 수 있도록 설정.
%wheel  ALL=(ALL)       ALL

# 비밀번호 없이 사용
%wheel  ALL=(ALL)       NOPASSWD: ALL
dev   ALL=(ALL)       NOPASSWD: ALL

/etc/sudoers 파일의 퍼미션은 440이어야 하며 퍼미션 조정이 되어 있지 않으면 아래와 같은 에러가 발생.
[dev@cet ~]$ sudo tail /etc/sudoers
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting

root 계정으로 로그인 후 퍼미션 조정
[dev@cet ~]$ su -
[root@cet ~]# chmod u-w /etc/sudoers

2014년 12월 14일 일요일

MacVim 관련 단축키



.vimrc에 직접 설정한 단축키

noremap <c-tab> :tabnext<cr> = vim의 탭이동 ( ctrl + tab )
noremap <c-n> :NERDTreeToggle<CR> = NERDTree 토글 단축키 (ctrl + n)


Vim command모드 단축키

i : insert모드로 변경(커서앞)
a : insert모드로 변경(커서뒤)
A : insert모드로 변경(라인마지막)
x : 커서에 있는 문자 삭제
dd : 한개 라인 삭제
yy : 라인 복제
p : 삭제했거나 복제한 라인 붙여넣기(커서뒤)
P : 삭제했거나 복제한 라인 붙여넣기(커서앞)

/ : /뒤에 오는 문자열 검색
G : 문서의 마지막 라인으로 이동
     1G : 문서의 첫라인으로 이동
     100G : 100번째 라인으로 이동
:wq : 저장하고 나가기
:q! : 저장안하고 바로 나가기


NERDTree

T - NERDTree에서 탭 생성 
t - NERDTree 화면이 없는 탭 생성
gT, gt - Tab 이동


ctrl + q + w - 열려있는 창 닫기
ctrl + ww / ctrl wh - 창 간의 이동



2014년 12월 13일 토요일

iTerm + MacVim + python-mode

django의 잦은 command line 이용때문에 eclipse pydev 에디팅 대신 MacVim을 이용하기로 했다.

환경은 iTerm + MacVim + python-mode + 기타 번들 인스토

현재까지 작성된 .vimrc

"한글깨짐 방지
set enc=UTF-8

set fileencodings=UTF-8

set nocompatible              " be iMproved, required

filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

call pathogen#infect()
call pathogen#helptags()

" alternatively, pass a path where Vundle should install bundles
"let path = '~/some/path/here'
"call vundle#rc(path)

" let Vundle manage Vundle, required
Bundle 'gmarik/vundle'

" The following are examples of different formats supported.
" Keep bundle commands between here and filetype plugin indent on.
" scripts on GitHub repos
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'tpope/vim-rails.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
" scripts from http://vim-scripts.org/vim/scripts.html
Bundle 'L9'
Bundle 'FuzzyFinder'
" scripts not on GitHub
Bundle 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" python lint
Bundle 'klen/python-mode'
" directory
Bundle 'scrooloose/nerdtree'
" powerline
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}


filetype plugin indent on     " required
syntax on

noremap <c-tab> :tabnext<cr>
noremap <c-n> :NERDTreeToggle<CR>

" Python-mode
" Activate rope
" Keys:
" K             Show python docs
" <Ctrl-Space>  Rope autocomplete
" <Ctrl-c>g     Rope goto definition
" <Ctrl-c>d     Rope show documentation
" <Ctrl-c>f     Rope find occurrences
" <Leader>b     Set, unset breakpoint (g:pymode_breakpoint enabled)
" [[            Jump on previous class or function (normal, visual, operator modes)
" ]]            Jump on next class or function (normal, visual, operator modes)
" [M            Jump on previous class or method (normal, visual, operator modes)
" ]M            Jump on next class or method (normal, visual, operator modes)
let g:pymode_rope = 1

" Documentation
let g:pymode_doc = 1
let g:pymode_doc_key = 'K'

"Linting
let g:pymode_lint = 1
let g:pymode_lint_checker = "pyflakes,pep8"
" Auto check on save
let g:pymode_lint_write = 1

" Support virtualenv
let g:pymode_virtualenv = 1

" Enable breakpoints plugin
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_key = '<leader>b'

" syntax highlighting
let g:pymode_syntax = 1
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all

" Don't autofold code
let g:pymode_folding = 0