botbotbot 's blog

Debian frist boot

Make user can use Sudo command

$ su # aceess to root  
$ apt-get install sudo  
$ adduser <username> sudo  
$ reboot # or logout  

Ref:

  1. How can I add a new user as sudoer using the command line?
  2. Sudo Configuration in Debian

Upgrade Debian to Unstable(Sid)

$ sudo vi /etc/apt/sources.list
# edit all 'squeeze' that's version codename 
# to 'sid' that's unstable codename
# ex. deb http://ftp.us.debian.org/debian squeeze main 
# to deb http://ftp.us.debian.org/debian sid main
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo reboot

Using Lastest Package on Debian (Testing Package)

$ sudo vim /etc/apt/sources.list
# add "deb     http://http.debian.net/debian testing         main"
$ sudo apt-get update
$ sudo apt-get install <your package>
# don't call sudo apt-get upgrade if your don't want to upgrade your all system to lastest packages

Check Version Debian

$ lsb_release -a #check debian version
$ uname -a #check linux version

How to switch between users on one terminal?

$ su - <user>

How To Find Fastest Mirror Lists With ‘Netselect-apt’ On Debian

# choose set your region to your local frist
$ sudo apt-get install netselect-apt
$ sudo netselect-apt

Debian Linux Install OpenSSH SSHD Server

# install
$ sudo apt-get update
$ sudo apt-get install openssh-server

# control ssh-server
$ sudo service ssh stop
$ sudo service ssh start
$ sudo service ssh restart
$ sudo service ssh status

Set Bash Color on SSH

# In your ssh server
$ echo "source your .bashrc" >> .bash_profile
# or you can try this [[ -f ~/.bashrc ]] && . ~/.bashrc

Extended monitor

$ xrandr --output VGA-1 --auto --primary --output DVI-I-1 --auto --left-of VGA-1

Install locals to support many languages

# debian
$ sudo apt-get install locales
$ sudo dpkg-reconfigure locales

Clean Uninstall

$ sudo apt-get remove --purge <packagename> # --purge delete all data and config
$ sudo apt-get autoremove --purge
$ sudo apt-get clean
$ locate <packagename> # manual delete

Show hidden file in GUI

Ctrl + H

keyboard shortcut for pasting on the Gnome Terminal

Ctrl+Shift+V - paste
Ctrl+Shift+C - copy

install and mount an exFAT partition

$ sudo apt-get install exfat-fuse exfat-utils

ETC.

OSX Backup

Time Machine Backups on External Hard Drive

  1. Use a Single External Hard Drive for Time Machine Backups and File Storage
  2. How to easily back up and restore your Mac with Time Machine on OS X Mavericks
  3. Mac Basics: Time Machine backs up your Mac

DevOps

Varany vs. Docker

Vagrant is a tool for managing virtual machines.
Docker is a tool for building and deploying applications by packaging them into lightweight containers.

Nginx ByPass Confixguration

bypass.conf

server {
    listen 80;

    location / {
        proxy_pass http://127.0.0.1:8000;
    }
}
# debian
$ sudo apt-get install nginx
$ sudo vim /etc/nginx/sites-available/<your>.conf
$ sudo rm /etc/ngin/sites-enabled/default.conf
$ suo ln -f /etc/nginx/sites-available/<your>.conf /etc/sites-enabled/
$ sudo services nginx reload

Nginx Allow File browser list

# debain
$ cd /usr/share/nginx/html
$ ln -s <path> <link_name>

edit your nginx.conf

    location /<url> {
      alias /usr/share/nginx/html/<link_name>
      autoindex on;
      autoindex_exact_size off;
      autoindex_localtime on;
      auth_basic "Restricted";                #For Basic Auth
      auth_basic_user_file <your .htpasswd>;  #For Basic Auth
    }

Useful command

Rsync

  1. How to Backup Linux? 15 rsync Command Examples
  2. How To Use Rsync to Sync Local and Remote Directories on a VPS

Ref::

  1. How to enable file browser mode in Nginx?
  2. How To Set Up HTTP Authentication With Nginx On Ubuntu 12.10
  3. วิธี setup Nginx ให้บริการ HTTPS
  4. DevOps for Developers (Nginx + Ruby)
  5. How To Use Fabric To Automate Administration Tasks And Deployments
  6. How to Deploy Python WSGI Apps Using Gunicorn HTTP Server Behind Nginx
  7. How To Create a SSL Certificate on nginx for Ubuntu 12.04
  8. Auto Reload Gunicorn On File Change Event
  9. 20 Linux System Monitoring Tools Every SysAdmin Should Know
  10. Awesome Sysadmin
  11. Server Admin for Programmers
  12. Ops School Curriculum
  13. serverspec automation testing your configured(Ruby)
  14. Building Microservices Nginx
  15. Ansible is a radically simple IT automation platform
  16. Vargrant GETTING STARTED
  17. LEARN CHEF

Git

Git Rebase

Michael Crichton said, “Great books aren’t written– they’re rewritten.”

fatal: CRLF would be replaced by LF in …

Because there is differenced end of line in dos and unix.

# open file that error in vim
:set noendofline binary
:wq

Global Ignore

# set where is global gitignore file
$ git config --global core.excludesfile ~/.gitignore_global
# write some ignore file in global gitignore
$ echo "tags" >> ~/.gitignore_global

Git stash

git stash
git stash pop
git revert

Git Alis

git config --global alias.tree "log --graph --decorate --oneline --abbrev-commit"
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"

Git Taggin

$ git tag -a <tag name> <commit id> -m “desc"
$ git push origin —tags
$ git pull --tags

Keep file in a Git repo, but don’t track changes

Should keep database.php.example and config.php.example in the repo. Then add config.php and database.php to the .gitignore file.

Remove sensitive files and their commits from Git history - GitHub answered exactly that question as an FAQ

pick out individual commits

cleaning up untracked files

http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html

Reference

  1. git replacing LF with CRLF
  2. Generating SSH Keys
  3. Anatomy Of A Good Commit Message
  4. Stop using git pull: A better workflow
  5. gitignore.io - Create Useful .gitignore Files For Your Project
  6. Git คืออะไร ? + พร้อมสอนใช้งาน Git และ Github
  7. Git Pro Book
  8. Git Ready Tips
  9. Keeping A GitHub Fork Updated
  10. Understanding the Git Workflow
The intended workflow is:

Create a private branch off a public branch.
Regularly commit your work to this private branch.
Once your code is perfect, clean up its history.
Merge the cleaned-up branch back into the public branch.
  1. Learn Git Branching
  2. Linux.conf.au 2013 - Git For Ages 4 And Up
  3. A Tale of Three Trees
  4. Try Git: Git Tutorial
  5. Git Commit Good Practice - OpenStack
  6. Becoming a Git Master
  7. Lesser known Git commands
  8. Git from the inside out
  9. Oh shit, git!

Smtp with gmail

Gmail Error 5.7.14

  1. Goto Google Less secure apps
  2. Selected “Enable”
  3. Done