# 우분투 초기 세팅

ubuntu 20.04

## 기본

{% tabs %}
{% tab title="init.sh" %}

```bash
sudo apt update
sudo apt install build-essential -y
sudo apt install curl vim git net-tools cmake -y
# ubuntu 20.04 에 python3 는 내장되어있으므로 설치하지 않아도 됨
```

{% endtab %}

{% tab title="build-essential ?" %}

```
binutils
bzip2
cpp
cpp-5
dpkg-dev
fakeroot
g++
g++-5
gcc
gcc-5
ifupdown
iproute2
isc-dhcp-client
isc-dhcp-common
libalgorithm-diff-perl
libalgorithm-diff-xs-perl
libalgorithm-merge-perl
libasan2
libatm1
libatomic1
libc-dev-bin
libc6-dev
libcc1-0
libcilkrts5
libdns-export162
libdpkg-perl
libfakeroot
libfile-fcntllock-perl
libgcc-5-dev
libgdbm3
libisc-export160
libisl15
libitm1
liblsan0
libmnl0
libmpc3
libmpfr4
libmpx0
libperl5.22
libquadmath0
libstdc++-5-dev
libtsan0
libubsan0
libxtables11
linux-libc-dev
make
manpages
manpages-dev
netbase
patch
perl
perl-modules-5.22
rename
```

{% endtab %}
{% endtabs %}

## zsh 세팅

{% tabs %}
{% tab title="설치" %}

```bash
sudo apt install zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="테마 변경" %}

```bash
sed 's/ZSH_THEME="robbyrussell"/ZSH_THEME="agnoster"/' ~/.zshrc > .TMP; mv .TMP ~/.zshrc
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="폰트 변경" %}

```bash
mkdir utils; cd utils
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
# 쉘 Preferences 에서 `Noto Mono for Powerline Regular 11` 로 폰트 변경
cd ..; rm -rf fonts

# apt install fonts-powerline <- 이것도 가능한듯
```

{% endtab %}
{% endtabs %}

![](https://2654940563-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOnbA8vSHqWi_tWvoTv%2F-MOoPLjVgWLJAOigk95_%2F-MOoW6NN-amRWERz3ZWw%2Fimage.png?alt=media\&token=a42dcadb-e16f-45c7-97e5-83591de56f27)

{% tabs %}
{% tab title="프롬프트를 2줄로 만들기" %}

```bash
prompt_newline() {
  if [[ -n $CURRENT_BG ]]; then
    echo -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR
%{%k%F{yellow}%}❯❯"
  else
    echo -n "%{%k%}"
  fi

  echo -n "%{%f%}"
  CURRENT_BG=''
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="유저네임 간소화" %}

```bash
sed -i'.bak' 's/%n@%m/%n/' ~/.oh-my-zsh/themes/agnoster.zsh-theme
# agnoster.zsh-theme.bak 백업파일이 생성
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="하이라이팅" %}

```bash
sudo apt install zsh-syntax-highlighting
echo source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh >> ~/.zshrc
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="alias 설정" %}

```bash
vi ~/.zshrc

# 아래의 코드를 추가
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

echo alias c='clear'\\nalias python='python3' >> ~/.bash_aliases

# 추가 설정
echo \\nalias pkg='/lib/command-not-found' >> ~/.bash_aliases
```

{% endtab %}
{% endtabs %}

위의 세팅을 모두 마친 뒤에, `ctrl+atl+t` 했을 때 `bash` 가 뜬다면 `reboot` 을 해주자

![세팅끝](https://2654940563-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOnbA8vSHqWi_tWvoTv%2F-MOoqa8Zy9WABwWv4YX5%2F-MOoqySs3rPaHyvj-o6-%2Fimage.png?alt=media\&token=028484b4-03b3-4354-9a23-a03998a04648)

#### 레퍼런스

{% embed url="<https://koharinn.tistory.com/262?category=826585>" %}

## gdb 설정

```bash
cd ~/utils
git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh

# for check
gdb -q
```

![](https://2654940563-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOnbA8vSHqWi_tWvoTv%2F-MOotjI2MNbp90Ddcr5c%2F-MOotnhdvYXg-oyIfY4U%2Fimage.png?alt=media\&token=0c634703-6005-4dbb-a344-937ef71fa3fa)

## vscode 설치

```bash
sudo sh -c 'curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg'
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt install code -y

# for check
code utils # or whatever file/dir you want
```

![이쁜 테마들](https://2654940563-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOnbA8vSHqWi_tWvoTv%2F-MOotq7hPuS6DYpgTLvX%2F-MOoxIZZ6DOCCyRxmn1i%2Fimage.png?alt=media\&token=57277817-8605-48b8-a95c-0e28ee9caa09)

![느슨해진 코딩에 긴장감을 주고 싶다면?](https://2654940563-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOnbA8vSHqWi_tWvoTv%2F-MOotq7hPuS6DYpgTLvX%2F-MOoxQYD_JcYjxiGuzzB%2Fimage.png?alt=media\&token=28ed5243-c842-48a8-88fa-fb5a90b2ecba)

## vim 설정

```bash
set nocompatible              " be iMproved, required
filetype off                  " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin),
"Plugin 'file:///home/jjeaby/Dev/tools/vim-plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
Plugin 'vim-airline/vim-airline'
Plugin 'scrooloose/nerdtree'
Plugin 'airblade/vim-gitgutter'
Plugin 'scrooloose/syntastic'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'nanotech/jellybeans.vim'
call vundle#end()            " required
"filetype plugin indent on    " required
"NERDTree ON 단축키를 "\nt"로 설정
map <Leader>nt <ESC>:NERDTree<CR>
let NERDTreeShowHidden=1
" let NERDTreeQuitOnOpen=1
let g:ctrlp_custom_ignore = {
  \ 'dir':  '\.git$\|vendor$',
    \ 'file': '\v\.(exe|so|dll)$'
\ }
color jellybeans
" Tag List 환경설정
filetype on                                 "vim filetype on
"Source Explorer 환경설정
nmap <F8> :SrcExplToggle<CR>                "F8 Key = SrcExpl Toggling
nmap <C-H> <C-W>h                           "왼쪽 창으로 이동
nmap <C-J> <C-W>j                           "아래 창으로 이동
nmap <C-K> <C-W>k                           "윗 창으로 이동
nmap <C-L> <C-W>l                           "오른쪽 창으로 이동
" 세부 정보 출력
"set nu
set title
set showmatch
set ruler
" 구문 강조 사용
if has("syntax")
 syntax on
endif
" 색깔 설정
set t_Co=256
" 들여쓰기 설정
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab
set expandtab
" 붙여넣기 설정
set paste
set mouse-=a
" 한글 입력 설정
set encoding=utf-8
set termencoding=utf-8
" 커서가 있는 줄을 강조함
set cursorline
" 상태바 표시를 항상한다
set laststatus=2 
set statusline=\ %<%l:%v\ [%P]%=%a\ %h%m%r\ %F\
" 검색 설정
set ignorecase
" 마지막으로 수정된 곳에 커서를 위치함
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "norm g`\"" |
\ endif
" Markdown 문법 설정 (Git 에서 사용)
augroup markdown
    " remove previous autocmds
    autocmd!
    " set every new or read *.md buffer to use the markdown filetype
    autocmd BufRead,BufNew *.md setf markdown
augroup END

```

esc 로 입력모드를 마친 뒤에, `:PluginInstall`

{% tabs %}
{% tab title="jellybeans 테마 다운로드" %}

```bash
mkdir -p ~/.vim/colors
cd ~/.vim/colors
curl -O https://raw.githubusercontent.com/nanotech/jellybeans.vim/master/colors/jellybeans.vim
```

{% endtab %}
{% endtabs %}

#### 파일트리 기능

* `\nt` 로 파일트리
* `ctrl + w w` 로 파일트리 <-> 편집기
* `:sp` 로 새탭을 띄우고, `ctrl + h/j/k/l` 로 이동가능

#### 레퍼런스

{% embed url="<https://vlee.kr/1211>" %}

{% embed url="<https://jjeaby.medium.com/vim-%EC%9D%84-ide-%EC%B2%98%EB%9F%BC-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-plugin-%EC%84%A4%EC%A0%95-87b40c5bfc14>" %}

## Tmux 설정

```bash
sudo apt install tmux
vi ~/.tmux_conf
```

```bash
# change key binding from C-b to Emacs style C-x
set-option -g prefix C-x
unbind-key C-b
bind-key C-x send-prefix

# interface
#------------
# pane
#------------
# set -g mouse-select-pane on
# set -g pane-border-fg black
# set -g pane-active-border-fg blue

#------------
# tabs
#------------
setw -g window-status-format "#[fg=white]#[bg=blue] #I #[bg=blue]#[fg=white] #W "
setw -g window-status-current-format "#[bg=brightmagenta]#[fg=white] *#I #[fg=white,bold]#[bg=cyan] [#W] "
# setw -g window-status-content-attr bold,blink,reverse

#------------
# status bar
#------------
# set-option -g status-position top
set -g status-fg white
set -g status-bg blue
set -g status-left ''
set -g status-right-length 60
set -g status-right '♪♪ #(exec amixer get Master | egrep -o "[0-9]+%" | egrep -o "[0-9]*") | ♥#(acpi | cut -d ',' -f 2) | %a %m-%d %H:%M '


#set -g terminal-overrides 'xterm*:smcup@:rmcup@'
#set -g mouse on
set-option -g mouse on
#set-option -s set-clipboard off
#bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -se c -i"
#bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"

```

* `ctrl+b` 를`ctrl+x` 로 변환&#x20;

## Pwntool - python3

```python
apt update
apt install python3 python3-dev python3-pip git
pip3 install --upgrade git+https://github.com/arthaud/python3-pwntools.git
```
