Setup read and write samba share in vagrant centos

Tested on vagrant centos 6.9
In your vagrant machine:

$ sudo yum install samba samba-common samba-client

Setup samba config, place this config at the bottom of the file:

$ sudo vim /etc/samba/smb.conf
...
...
[foobar]
browseable = yes
path = /srv/foobar
guest ok = yes
public = yes
read only = no
create mask = 0644
directory mask = 0755
force user = foobar
valid users = foobar
writable = yes
$ sudo /etc/init.d/smb restart

Setup your samba user password, this password will be used for mount the directory from your local machine:

$ sudo smbpasswd -a foobar

In your local machine:

Mount the foobar project directory, enter your samba password here:

$ sudo mount -t cifs -o username=foobar,uid=1003,gid=1003 //10.10.10.1/foobar /tmp/foobar

Explanations command line above:

1003 is the user local id, you can check it by type:

$ id
uid=1003(mylocaluser) gid=1003(mylocaluser)

10.10.10.1 is the vagrant ip address

tmp/foobar is a mounted folder from original directory in vagrant


How to download and convert video from youtube to MP3 in terminal

So, I needed to download songs from youtube but not as a video but only audio. Then I went to this website to convert these video as usual. The website that I used to convert video from youtube was popped out ads that I didn’t like. I started to thinking why the hell that I need those websites anyway? just use the terminal instead.

$ youtube-dl --extract-audio --audio-format mp3 <youtube-url>

Arcanist cheatsheet

$ arc patch D123
$ git add .
$ git commit -am "update"
$ arc diff --update D123
$ arc land --revision D123

Update diff to master

$ git checkout master
$ git merge arcpatch-D123
$ git push

Make a diff from current working branch

$ git add.
$ git commit -am "update"
$ arc diff --update D123

Push to working branch without land

$ git add .
$ git commit -am "update"
$ git push origin lol-branch

Make a diff from working branch from the first update

$ git checkout lol-branch
$ git add.
$ git commit -am "update"
$ arc diff master

SSH tunneling to your secured database/RDS through bastion/jump server with forwarded port

$ ssh -f -N -v -t -L 5433:target_host:5432 user@jump_server
  • target_host is the host/database_server/RDS that you want to access that only can be accessed from jump _server or bastion if you’re using AWS
  • jump_server is the host that accessible from you and the only host that can access target_host
  • 5432 is local port (postgresql default)
  • 5433 is the forwarded host/database_server/RDS port that you can access through localhost
    What’s next?

    Afterwards, you should be able to get postgresql open with forwarded port through localhost (5433).

    Test the forwarded port using telnet:

    $ telnet localhost 5433
    

    or using netcat:

    $ nc -vz localhost 5433
    

Create partition in Linux that size larger than 2TB

Install parted:

sudo apt-get install parted

Use parted to create partition:

parted /dev/sdb

Inside parted cli, follow these steps:

(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) unit GB
(parted) mkpart primary 0.0GB 3000GB
(parted) print

Format the filesystem we created, using mkfs and try to mount it to mount point:

mkfs.ext4 /dev/sdb1
mkdir /tes
mount /dev/sdb1 /tes