Skip to content

Instantly share code, notes, and snippets.

@zillingen
Last active August 12, 2018 16:21
Show Gist options
  • Save zillingen/cb709c85d72d583f77dde53d11591fdd to your computer and use it in GitHub Desktop.
Save zillingen/cb709c85d72d583f77dde53d11591fdd to your computer and use it in GitHub Desktop.
Linux configuration and administration

Env configuration

# PS1 with red username (for root)
PS1='\e[0;31m\]\u\e[0m\]@\h:\w\$'

# PS1 with green username (for base user)
PS1='\e[0;32m\]\u\e[0m\]@\h:\w\$'

Vim

Plugins

Vundle: Install and configure Vundle

Vim-Twig Plugin: Install vim-twig and add Plugin 'bundle/vim-twig' to ~/.vimrc

TAB and encoding config

Add this to /etc/vim/vimrc or ~/.vimrc file

set fileencoding=utf-8
set encoding=utf-8
set termencoding=utf-8

" The width of a TAB is set to 4.
" Still it is a \t. It is just that
" Vim will interpret it to be having
" a width of 4.
set tabstop=2

" Indents will have a width of 4
set shiftwidth=2

" Sets the number of columns for a TAB
set softtabstop=2

" Expand TABs to spaces
set expandtab

" Show line numbers
set number
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE

File encryption with OpenSSL

# Encrypt passwd.txt
openssl enc -aes-256-cbc -in passwd.txt -out passwd.encrypted
# Decrypt passwd.encrypted
openssl enc -aes-256-cbc -d -in passwd.encrypted > passwd.txt

Mysql

Add user with grants

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost' WITH GRANT OPTION;
SHOW GRANTS FOR 'username'@'localhost';

Create user for mysqldump

CREATE USER 'backup_user'@'localhost' IDENTIFIED BY 'secret';
GRANT SELECT, SHOW VIEW, LOCK TABLES, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER ON *.* TO 'backup_user'@'localhost';

Nginx

Enable NCSA Combined Log Format with Virtual Host in Nginx

log_format vcombined '$host:$server_port '
        '$remote_addr - $remote_user [$time_local] '
        '"$request" $status $body_bytes_sent '
        '"$http_referer" "$http_user_agent"';

access_log /var/log/nginx/access.log vcombined;
error_log /var/log/nginx/error.log;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment