Last active
August 23, 2023 07:59
-
-
Save arnabdas/4f0a43300ce77820aa7f to your computer and use it in GitHub Desktop.
First configuration of Ubuntu 16.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filetype plugin indent on | |
" show existing tab with 4 spaces width | |
set tabstop=4 | |
" when indenting with '>', use 4 spaces width | |
set shiftwidth=4 | |
" On pressing tab, insert 4 spaces | |
set expandtab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#default | |
#PS1='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' | |
export NEWLINE=$'\n' | |
PS1='${NEWLINE} %D{%m.%f.%y} %*${NEWLINE}%{$fg[cyan]%}%d $(git_prompt_info)${NEWLINE}${ret_status} %{$reset_color%}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo blkid | |
sudo cgdisk /dev/sdb | |
sudo mkfs -t ext4 /dev/sdb1 | |
sudo mkdir /media/storage | |
blkid | |
mkdir /storage | |
vim /etc/fstab | |
# UUID="b4c93..." /storage ext4 defaults 0 0 | |
sudo mount -av |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
adduser arnabdas | |
usermod -aG sudo arnabdas | |
# login with new user | |
sudo -i | |
whoami # should out 'root' | |
ssh-keygen -t rsa -b 4096 -C "some-descriptor" | |
vim ~/.ssh/authorized_keys | |
chmod 600 ~/.ssh/authorized_keys | |
# edit /etc/ssh/sshd_config | |
# PasswordLogin no | |
# RootLogin no | |
# finally disable password login for root | |
passwd -l root | |
# http://jonmoore.duckdns.org/index.php/linux-articles/58-remove-sudo-password-prompt | |
visudo | |
<user> ALL=(ALL) NOPASSWD: ALL | |
sudo -k # clears password cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# start with basic system upgrade | |
apt-get update | |
apt-get upgrade | |
apt-get dist-upgrade | |
echo "PS1='\n\w\n-> '" >> .bashrc | |
apt-get install -y screen curl ufw htop build-essential p7zip-full libssl-dev software-properties-common python-software-properties | |
# locale | |
locale-gen "en_US.UTF-8" | |
dpkg-reconfigure locales | |
# install Java and git | |
add-apt-repository ppa:webupd8team/java | |
add-apt-repository ppa:jonathonf/vim | |
add-apt-repository ppa:git-core/ppa | |
add-apt-repository ppa:certbot/certbot | |
apt-get update | |
apt-get install -y oracle-java8-installer git vim python-certbot-nginx | |
# certbot --nginx -d example.com | |
# 0 */12 * * * /usr/bin/certbot renew | |
# Configure git for the default behaviours | |
git config --global push.default matching | |
git config --global diff.renames copies | |
# install gcc 6 toolchain | |
add-apt-repository ppa:ubuntu-toolchain-r/test -y | |
apt-get update | |
apt-get install gcc-snapshot -y | |
apt-get update | |
apt-get install gcc-6 g++-6 -y | |
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 | |
apt-get install gcc-4.8 g++-4.8 -y | |
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 | |
# update-alternatives --config gcc | |
# install google go | |
mkdir -p go/{bin,src,lib} | |
echo 'export GOROOT=/usr/local/go' >> .bashrc | |
echo 'export GOPATH=$HOME/go' >> .bashrc | |
echo 'export GOBIN=$GOPATH/bin' >> .bashrc | |
echo 'export PATH=$PATH:$GOROOT/bin:$GOBIN' >> .bashrc | |
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz | |
tar -C /usr/local -xzf go1.14.2.linux-amd64.tar.gz | |
go get github.com/exercism/cli/exercism | |
# install nodejs | |
curl https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash | |
source ~/.profile | |
nvm install 6.10.2 | |
nvm alias default 6.10.2 | |
nvm use default | |
npm install -g grunt-cli bower typings typescript | |
# install ruby and required gems | |
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | |
\curl -sSL https://get.rvm.io | bash -s stable --ruby --gems=sass,normalize-scss,susy | |
source /etc/profile.d/rvm.sh | |
rvm use 2.4 --default | |
# configure firewall | |
ufw default deny incoming | |
ufw default allow outgoing | |
ufw allow 993/tcp | |
ufw allow 80/tcp | |
ufw allow 443/tcp | |
ufw enable | |
# finally clear apt cache | |
apt-get clean | |
# tar xvzf jdk-8u151-linux-i586.tar.gz -C /usr/local/lib/java | |
# JAVA_HOME=/usr/java/jdk1.8.0_05/ | |
# update-alternatives --install /usr/bin/java java ${JAVA_HOME%*/}/bin/java 20000 | |
# update-alternatives --install /usr/bin/javac javac ${JAVA_HOME%*/}/bin/javac 20000 | |
# increase number of file watchers | |
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.guguweb.com/2019/02/07/how-to-move-docker-data-directory-to-another-location-on-ubuntu/ | |
service docker stop | |
vim /etc/docker/daemon.json | |
#{ | |
# "data-root": "/data/docker" | |
#} | |
rsync -aP /var/lib/docker/ /data/docker | |
mv /var/lib/docker /var/lib/docker.old | |
service docker start | |
docker pull ubuntu | |
docker inspect <image-id> | grep WorkDir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
server_name www.example.com; | |
return 301 $scheme://example.com$request_uri; | |
listen 80; | |
} | |
server { | |
listen 80; | |
server_name example.com; | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
access_log /var/log/nginx/example.com.access.log; | |
error_log /var/log/nginx/example.com.error.log; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
# location /context { | |
# rewrite /context(.*) $1 break; | |
# proxy_pass http://127.0.0.1:7439; | |
# } | |
error_page 404 /404.html; | |
location = /404.html { | |
root /usr/share/nginx/html; | |
} | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_connect_timeout 59s; | |
proxy_send_timeout 600; | |
proxy_read_timeout 36000s; ## Timeout after 10 hours | |
proxy_buffer_size 64k; | |
proxy_buffers 16 32k; | |
proxy_pass_header Set-Cookie; | |
proxy_hide_header Vary; | |
proxy_busy_buffers_size 64k; | |
proxy_temp_file_write_size 64k; | |
proxy_set_header Accept-Encoding ''; | |
proxy_ignore_headers Cache-Control Expires; | |
proxy_set_header Referer $http_referer; | |
proxy_set_header Host $host; | |
proxy_set_header Cookie $http_cookie; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Server $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Port '443'; | |
proxy_set_header X-Forwarded-Ssl on; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_set_header Authorization ''; | |
proxy_buffering off; | |
proxy_redirect off; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment