VIM get config and shorcut cheatset

clone vim config from https://github.com/julienschmidt/vim

cd ~
git clone https://github.com/julienschmidt/vim.git ~/.vim
ln -s ~/.vim/vimrc ~/.vimrc
cd ~/.vim
git submodule update --init
git submodule foreach git pull origin master

cheatset

split vertical
:vs filepath

split horizontal
:sp filepath

switch in windows buffer
Ctrl+w

switch from vertical to horizontal layout
Ctr+w H (or) :wincmd H

switch from horizontal to vertical layout
Ctrl+w J (or) :wincmd J

swap buffer but keep layout same 	 	
Ctrl+w r (or) :wincmd r

open file buffer
:e filepath

list all buffer 
:ls

buffer next
:bn

buffer prev
:bp

switch buffer in current windows
Ctrl+6

close buffer
:bd

close tab/file & remove from buffer
:bd!

search 
/

using command system in vim (ex: git)
:!git status

cut line
dd

paste line
p

select entire line and delete
Shift v then d

Advertisements

git(hub) – download all branch from repo

when your repo (github) have multiple branchs, using git clone command will only download “master” branch and other branch still not or remotely

this log when i download from https://github.com/GoesToEleven/golang-web-dev.git and get all his branch to locally

# mkdir for repo
$ mkdir golang-web-dev && cd golang-web-dev

# get download .git folder from repo
# git clone --bare <repository url goes here> .git
$ git clone --bare https://github.com/GoesToEleven/golang-web-dev.git .git

# doing some config
$ git config --bool core.bare false

# check status
$ git status


# reset to get deleted file & and show branch
$ git reset --hard && git branch

 

gitlab – colaboration with git

this secenario using two user first “g3n1k” second “sadik”
using gitlab comunity edition 9.5.4 in debian 8

g3n1k user: create, update, push master
$ git clone http://10.54.4.4:81/g3n1k/myproject.git
$ cd myproject
$ touch README.md
$ git add README.md
$ git commit -m "add README"
$ git push -u origin master

sadik user: fork, branc, change, push branch, send merge request 
# fork http://10.54.4.4:81/g3n1k/myproject.git
$ git clone http://10.54.4.4:81/sadik/myproject.git
$ cd myproject
# create and go to branch "sadik-menambah"
$ git checkout -b "sadik-menambah"
$ wget http://bit.ly/jqsource -O jquery.js
$ echo "Add the line to README.md" >> README.md
$ git add .
$ git commit -m "sadik menambah file"
# push branch "sadik-menambah"
$ git push origin sadik-menambah
# doing branch merge request

g3n1k user: see merge request, review change, merge n fix conflict, checkout master, doing merge, push to master
$ git fetch http://10.54.4.4:81/sadik/myproject.git sadik-menambah
$ git checkout -b sadik/myproject-sadik-menambah FETCH_HEAD
# review change local
# merge the brances and fix any conflicts thats come up
$ git checkout master
$ git merge --no-ff sadik/myproject-sadik-menambah
# push result of the merge to GitLab
$ git push origin master

sadik user: add remote original, remote update, doing update to master local, 
# check which branch are we
$ git status
# update master in fork at sadik user
$ git checkout master
# add remote user
$ git remote add g3n1k http://10.54.4.4:81/g3n1k/myproject.git
$ git remote 
# get pointing
$ git remote -v
$ git remote update
$ git merge g3n1k/master
# now your master is uptodate from g3n1k/master

reference: https://dev.acquia.com/blog/getting-started-collaborative-development-git

lvm – shrink lvm partition size

[root@rhelA ~]# findmnt
TARGET                       SOURCE                       FSTYPE      OPTIONS
/                            /dev/mapper/vg_rhela-lv_root ext4        rw,relatime,seclabel,barrier=1,data=ordered
├─/proc                      proc                         proc        rw,relatime
│ ├─/proc/bus/usb            /proc/bus/usb                usbfs       rw,relatime
│ └─/proc/sys/fs/binfmt_misc                              binfmt_misc rw,relatime
├─/sys                       sysfs                        sysfs       rw,relatime,seclabel
├─/selinux                                                selinuxfs   rw,relatime
├─/dev                       devtmpfs                     devtmpfs    rw,relatime,seclabel,size=946208k,nr_inodes=236552,mode=755
│ └─/dev                     devtmpfs                     devtmpfs    rw,relatime,seclabel,size=946208k,nr_inodes=236552,mode=755
│   ├─/dev/pts               devpts                       devpts      rw,relatime,seclabel,gid=5,mode=620,ptmxmode=000
│   └─/dev/shm               tmpfs                        tmpfs       rw,relatime,seclabel
├─/boot                      /dev/sda1                    ext4        rw,relatime,seclabel,barrier=1,data=ordered
├─/home                      /dev/mapper/vg_rhela-lv_home ext4        rw,relatime,seclabel,barrier=1,data=ordered
├─/misc                      /etc/auto.misc               autofs      rw,relatime,fd=7,pgrp=1649,timeout=300,minproto=5,maxproto=5,indirect
└─/net                       -hosts                       autofs      rw,relatime,fd=13,pgrp=1649,timeout=300,minproto=5,maxproto=5,indirect

[root@rhelA ~]# umount /home

[root@rhelA ~]# e2fsck -f /dev/mapper/vg_rhela-lv_home 
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg_rhela-lv_home: 656/4300800 files (17.8% non-contiguous), 4124861/17188864 blocks

[root@rhelA ~]# e2fsck -fy /dev/mapper/vg_rhela-lv_home 
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg_rhela-lv_home: 656/4300800 files (17.8% non-contiguous), 4124861/17188864 blocks

[root@rhelA ~]# resize2fs /dev/mapper/vg_rhela-lv_home 25G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_rhela-lv_home to 6553600 (4k) blocks.
The filesystem on /dev/mapper/vg_rhela-lv_home is now 6553600 blocks long.

[root@rhelA ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_rhela
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               119.51 GiB
  PE Size               4.00 MiB
  Total PE              30594
  Alloc PE / Size       30594 / 119.51 GiB
  Free  PE / Size       0 / 0   
  VG UUID               DOXFrI-vdc8-KjtT-qN4N-oGj3-Yf8K-suupSe

[root@rhelA ~]# lvreduce -L 25G /dev/vg_rhela/lv_home 
  WARNING: Reducing active logical volume to 25.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
  Size of logical volume vg_rhela/lv_home changed from 65.57 GiB (16786 extents) to 25.00 GiB (6400 extents).
  Logical volume lv_home successfully resized
[root@rhelA ~]# resize2fs /dev/mapper/vg_rhela-lv_home 
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 6553600 blocks long.  Nothing to do!

[root@rhelA ~]# mount /dev/mapper/vg_rhela-lv_home /home

[root@rhelA ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_rhela-lv_root
                       50G  4.2G   43G   9% /
tmpfs                 940M  296K  939M   1% /dev/shm
/dev/sda1             477M   42M  410M  10% /boot
/dev/mapper/vg_rhela-lv_home
                       25G   15G  8.7G  63% /home

[root@rhelA ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_rhela
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               119.51 GiB
  PE Size               4.00 MiB
  Total PE              30594
  Alloc PE / Size       20208 / 78.94 GiB
  Free  PE / Size       10386 / 40.57 GiB
  VG UUID               DOXFrI-vdc8-KjtT-qN4N-oGj3-Yf8K-suupSe

lvm – extend expand size

# show all after crate fdisk command -----------------------------------
[root@localhost ~]# pvdisplay
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rhel
  PV Size               31.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              8066
  Free PE               0
  Allocated PE          8066
  PV UUID               bdaYMp-UQB8-bSFf-UGk1-TYhP-mow6-SLNkuQ
   
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  --- Physical volume ---
  PV Name               unknown device
  VG Name               rhel
  PV Size               468.00 GiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              119807
  Free PE               119807
  Allocated PE          0
  PV UUID               Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD
   
  "/dev/sda3" is a new physical volume of "468.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda3
  VG Name               
  PV Size               468.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               3ycy21-P5OL-YKYu-zz4c-wnCB-hsx6-vYnaDt

[root@localhost ~]# vgdisplay
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  --- Volume group ---
  VG Name               rhel
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                1
  VG Size               499.50 GiB
  PE Size               4.00 MiB
  Total PE              127873
  Alloc PE / Size       8066 / 31.51 GiB
  Free  PE / Size       119807 / 468.00 GiB
  VG UUID               TRdEsL-YK5v-0iG7-fMvI-XPyy-Rzpb-LxFbgb
   
[root@localhost ~]# pvscan
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  PV /dev/sda2        VG rhel            lvm2 [31.51 GiB / 0    free]
  PV unknown device   VG rhel            lvm2 [468.00 GiB / 468.00 GiB free]
  PV /dev/sda3                           lvm2 [468.00 GiB]
  Total: 3 [967.50 GiB] / in use: 2 [499.50 GiB] / in no VG: 1 [468.00 GiB]

# remove missing from vg ------------------------------------------------
[root@localhost ~]# vgreduce --removemissing --force rhel
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  PV Rbyn39-R43F-9dIL-D598-ARv6-HN6C-UNsCzD not recognised. Is the device missing?
  Wrote out consistent volume group rhel

[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rhel
  PV Size               31.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              8066
  Free PE               0
  Allocated PE          8066
  PV UUID               bdaYMp-UQB8-bSFf-UGk1-TYhP-mow6-SLNkuQ
   
  "/dev/sda3" is a new physical volume of "468.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda3
  VG Name               
  PV Size               468.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               3ycy21-P5OL-YKYu-zz4c-wnCB-hsx6-vYnaDt
   
[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               rhel
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               31.51 GiB
  PE Size               4.00 MiB
  Total PE              8066
  Alloc PE / Size       8066 / 31.51 GiB
  Free  PE / Size       0 / 0   
  VG UUID               TRdEsL-YK5v-0iG7-fMvI-XPyy-Rzpb-LxFbgb

# create pv ------------------------------------------------------------
[root@localhost ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created

[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rhel
  PV Size               31.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              8066
  Free PE               0
  Allocated PE          8066
  PV UUID               bdaYMp-UQB8-bSFf-UGk1-TYhP-mow6-SLNkuQ
   
  "/dev/sda3" is a new physical volume of "468.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda3
  VG Name               
  PV Size               468.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               fl2Lhs-kIpW-9qH9-VS9Y-2xA0-uKr0-GUYZLm

# extend vg ------------------------------------------------------------
[root@localhost ~]# vgextend /dev/rhel /dev/sda3
  Volume group "rhel" successfully extended

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               rhel
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               499.50 GiB
  PE Size               4.00 MiB
  Total PE              127873
  Alloc PE / Size       8066 / 31.51 GiB
  Free  PE / Size       119807 / 468.00 GiB
  VG UUID               TRdEsL-YK5v-0iG7-fMvI-XPyy-Rzpb-LxFbgb

# show lv size ---------------------------------------------------------
[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/rhel/swap
  LV Name                swap
  VG Name                rhel
  LV UUID                X0Th3D-SZty-2rDO-JGm3-zuOw-ydoi-QXrzRG
  LV Write Access        read/write
  LV Creation host, time localhost, 2017-05-17 01:55:54 +0700
  LV Status              available
  # open                 2
  LV Size                3.02 GiB
  Current LE             772
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/rhel/root
  LV Name                root
  VG Name                rhel
  LV UUID                kWHVMz-X2Tl-b3vT-vNWG-NSSs-Ihq4-C4vxiD
  LV Write Access        read/write
  LV Creation host, time localhost, 2017-05-17 01:55:54 +0700
  LV Status              available
  # open                 1
  LV Size                28.49 GiB
  Current LE             7294
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

# extend lv size -------------------------------------------------------
[root@localhost ~]# lvextend /dev/rhel/root /dev/sda3
  Extending logical volume root to 496.49 GiB
  Logical volume root successfully resized

# show the new size ----------------------------------------------------
[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/rhel/swap
  LV Name                swap
  VG Name                rhel
  LV UUID                X0Th3D-SZty-2rDO-JGm3-zuOw-ydoi-QXrzRG
  LV Write Access        read/write
  LV Creation host, time localhost, 2017-05-17 01:55:54 +0700
  LV Status              available
  # open                 2
  LV Size                3.02 GiB
  Current LE             772
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/rhel/root
  LV Name                root
  VG Name                rhel
  LV UUID                kWHVMz-X2Tl-b3vT-vNWG-NSSs-Ihq4-C4vxiD
  LV Write Access        read/write
  LV Creation host, time localhost, 2017-05-17 01:55:54 +0700
  LV Status              available
  # open                 1
  LV Size                496.49 GiB
  Current LE             127101
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

# show with df ---------------------------------------------------------
[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   29G  5.2G   24G  19% /
devtmpfs               123G     0  123G   0% /dev
tmpfs                  123G  128K  123G   1% /dev/shm
tmpfs                  123G  8.9M  123G   1% /run
tmpfs                  123G     0  123G   0% /sys/fs/cgroup
/dev/sda1              497M  119M  379M  24% /boot
/dev/sr0               3.5G  3.5G     0 100% /run/media/exsys/RHEL-7.0 Server.x86_64

#the size only 29GB

# using resize2fs to make use of this space ----------------------------
[root@localhost ~]# resize2fs /dev/rhel/root 
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/rhel/root
Couldn't find valid filesystem superblock.

# ok error next using xfs_growfs to get free space ---------------------------
[root@localhost ~]# xfs_growfs /dev/rhel/root 
meta-data=/dev/mapper/rhel-root  isize=256    agcount=4, agsize=1867264 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=7469056, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=3647, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 7469056 to 130151424

# check lagi -----------------------------------------------------------
[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root  497G  5.2G  492G   2% /
devtmpfs               123G     0  123G   0% /dev
tmpfs                  123G  128K  123G   1% /dev/shm
tmpfs                  123G  8.9M  123G   1% /run
tmpfs                  123G     0  123G   0% /sys/fs/cgroup
/dev/sda1              497M  119M  379M  24% /boot
/dev/sr0               3.5G  3.5G     0 100% /run/media/exsys/RHEL-7.0 Server.x86_64

debian 9 – install mariadb 10.x

# apt-get install software-properties-common
# apt-get install dirmngr
# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
# add-apt-repository 'deb [arch=amd64] http://www.ftp.saix.net/DB/mariadb/repo/10.1/debian stretch main'
# apt-get update
# apt-get install mariadb-server
# systemctl start mariadb
# systemctl enable mariadb
# systemctl status mariadb