Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ant-rod-silva/a7ee60869daf6cf567d5804c12bdce15 to your computer and use it in GitHub Desktop.
Save ant-rod-silva/a7ee60869daf6cf567d5804c12bdce15 to your computer and use it in GitHub Desktop.

Ubuntu 12.04 LTS precise

Infos

  • Release Date: 26/04/2012
  • End of Life date: 28/04/2017

/etc/apt/sources.list

deb http://old-releases.ubuntu.com/ubuntu/ precise main restricted
deb http://old-releases.ubuntu.com/ubuntu/ precise-updates main restricted
deb http://old-releases.ubuntu.com/ubuntu/ precise universe
deb http://old-releases.ubuntu.com/ubuntu/ precise-updates universe
deb http://old-releases.ubuntu.com/ubuntu/ precise multiverse
deb http://old-releases.ubuntu.com/ubuntu/ precise-updates multiverse
deb http://old-releases.ubuntu.com/ubuntu/ precise-security main restricted
deb http://old-releases.ubuntu.com/ubuntu/ precise-security universe
deb http://old-releases.ubuntu.com/ubuntu/ precise-security multiverse

Sudo without password

Add user to group sudo:

sudo usermod -aG sudo user

Type visudo:

sudo visudo

Edit

%sudo   ALL=(ALL) NOPASSWD:ALL

Reboot. And Test

sudo visudo -c

How to Add Cloudflare DNS

As root:

echo 'nameserver 1.1.1.1' >> /etc/resolvconf/resolv.conf.d/head
sudo resolvconf -u
cat /etc/resolv.conf

How to install useful packages/apps

sudo apt-get install -y aptitude trash-cli guake terminator graphicsmagick
sudo apt-get install -y p7zip-full unace unar unrar zip unzip sharutils p7zip-rar 
sudo apt-get install -y gcc cpp make bwbasic libxtst-dev libghc-x11-dev libgl1-mesa-dev mercurial subversion
sudo aptitude install libgtk2.0-dev
sudo apt-get install -y gfortran fort77 clisp ghc6 ucblogo texlive-full texmaker kturtle guake terminator
sudo apt-get install -y git aptitude nginx gunicorn mc ppa-purge bison flex texinfo texi2html openssh-server
sudo apt-get install -y pwgen sqlite3 redis-server
sudo apt-get install -y python-tk tk-dev build-essential libgsl0-dev libcfitsio3-dev libncurses5-dev 
sudo apt-get install -y libblas-dev liblapack-dev libatlas-base-dev libfreetype6-dev libpng-dev gdb
sudo apt-get install -y libwww-perl vim htop nbtscan ipcalc ntp bleachbit ttf-liberation
sudo aptitude install -y build-essential cython gfortran xvfb python-imaging python-simplejson freetds-dev python-lxml
sudo aptitude install -y python-suds libpq-dev libssl-dev libldap2-dev libsasl2-dev libncurses5 libncurses5-dev 
sudo aptitude install -y libxml2 libxml2-dev libxslt1-dev libblas-dev liblapack-dev libatlas-base-dev 
sudo aptitude install -y libjpeg8-dev libffi6 libffi-dev libgdk-pixbuf2.0-0  shared-mime-info
sudo pip install supervisor virtualenv virtualenvwrapper
sudo apt-get install -y python-dev libcurl4-openssl-dev python-software-properties

How to uninstall unecessary packages/apps

sudo apt-get remove --purge -y banshee pitivi evolution empathy shotwell simple-scan thunderbird rhythmbox
sudo apt-get remove --purge -y libreoffice* xscreensaver pidgin audacious xfburn sylpheed osmo
sudo apt-get clean
sudo apt-get autoremove

~/.bashrc alias

https://pastebin.com/cMy8XD3x


How to Install Python 3

sudo apt-get install -y python3 python3-dev python3-apt

Install OpenSSL 1.1.1a (Release date: 11/11/2018)

https://websiteforstudents.com/manually-install-the-latest-openssl-toolkit-on-ubuntu-16-04-18-04-lts/

sudo apt-get install -y zlib1g-dev checkinstall build-essential
wget ftp://openssl.org/source/openssl-1.1.1a.tar.gz
tar -xvzf openssl*.tar.gz
cd openssl*
sudo ./config -Wl,--enable-new-dtags \
    --debug \
    --prefix=/usr/local \
    --libdir=/lib \
    --openssldir=/usr/local/ssl && \
    make && sudo make install

After that the version of OpenSSL you downloaded should be installed on the directory /usr/local/ssl.

Ubuntu default OpenSSL version is installed in the /usr/lib/ssl and it’s where apps that need to use SSL look by default

You’ll need to reference the version you installed.

Run the commands below option Ubuntu default man page

sudo nano /etc/manpath.config

Then add the following:

MANPATH_MAP     /usr/local/ssl/bin      /usr/local/ssl/man

Then run the commands below to update the manual database…

sudo mandb

You can also update the execution path to include the new location for OpenSSL. run the commands below to open Ubuntu environment configuration file.

sudo nano /etc/environment

Then add the /usr/local/ssh/bin as shown in the line below…. Use the exact path as shown…

PATH="/usr/local/sbin:/usr/local/bin:/usr/local/ssl/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

Reboot


Install Wget 1.20 On Ubuntu (Release Date: 30/11/2018)

http://www.linuxfromscratch.org/blfs/view/8.3-systemd/basicnet/wget.html

sudo apt-get update
sudo apt-get remove -y wget

Baixar o arquivo http://ftp.gnu.org/gnu/wget/wget-1.20.tar.gz pelo navegador

tar -zxvf wget-1.20.tar.gz
cd wget-1.20/
./configure --prefix=/usr --sysconfdir=/etc  --with-ssl=openssl
make && sudo make install
wget --version

Install CURL 7.63 (Release-Date: 12/12/2018)

http://www.linuxfromscratch.org/blfs/view/8.3-systemd/basicnet/curl.html

wget --no-check-certificate http://curl.haxx.se/download/curl-7.63.0.tar.gz
tar -zxvf curl-7.63.0.tar.gz
cd curl-7.63.0
./configure --prefix=/usr --disable-static --enable-threaded-resolver --with-ca-path=/etc/ssl/certs
make && sudo make install
which curl
curl -V

Download the package ca-certificates manually from the Ubuntu repositories.

You can download it using wget with wget --no-check-certificate http://security.ubuntu.com/ubuntu/pool/main/c/ca-certificates/ca-certificates_20210119~20.04.2_all.deb

Run dpkg -r --force-depends ca-certificates to remove the old package and eventual files that's without content.

Run dpkg -i ca-certificates_20210119~20.04.2_all.deb to install the package.


PIP 18.1 (Release Date: 05/10/2018)

wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
sudo python2.7.15 get-pip.py
pip --version

How to Install Mate Desktop

sudo add-apt-repository ppa:spvkgn/mate-precise
sudo apt-get update
sudo apt-get install mate-desktop mate-core gdebi

Logoff and select Mate Desktop on Login

How to uninstall Unity

sudo apt-get remove unity
sudo apt-get remove unity-2d

Anaconda

Instalation

wget --no-check-certificate https://repo.continuum.io/archive/Anaconda2-2018.12-Linux-x86.sh
bash Anaconda2-2018.12-Linux-x86.sh

Configuration

You’ll receive the following output to review the license agreement by pressing ENTER until you reach the end.

Please answer 'yes' or 'no':'
>>> yes

Press ENTER to confirm the location

Anaconda2 will now be installed into this location:
/home/user/anaconda2
Do you wish the installer to initialize Anaconda2
in your /home/user/.bashrc ? [yes|no]
>>> yes
source /home/user/anaconda2/etc/profile.d/conda.sh

commands

List envs

conda info --envs

Create Environment

conda create -n flaskenv python=3

environment location: /home/user/anaconda2/envs/flaskenv

Delete Environment

conda remove -n flaskenv

To activate this environment, use

conda activate flaskenv

To deactivate an active environment, use

conda deactivate

To export:

conda env export > environment.yaml

Flask Environment useful packages

conda install --name flaskenv flask flask-sqlalchemy wtforms six pyyaml openpyxl pandas
conda install --name flaskenv numpy xlrd xlwt unicodecsv pep8 pycrypto beautifulsoup4
conda install -c conda-forge --name flaskenv flask-babelex flask-login flask-mail flask-wtf
conda install -c conda-forge --name flaskenv flask-security sqlalchemy-utils tablib suds-jurko pendulum
conda install -c conda-forge --name flaskenv arrow pypdf2 

Django Environment useful packages

conda create -n django2 python=3
conda activate django2
conda install --name django2 django=2.1.4 ipython psycopg2
conda install --name django2 -c conda-forge django-extensions ipdb django-debug-toolbar
conda install --name django2 -c conda-forge ipython_genutils ipdb

Test if Django is installed in an isolated environment!

conda activate django2
python -c "import django; print(django.get_version())"
conda install --name cython  six  python-dateutil reportlab
conda install --name django2 xlwt xlrd xlutils simplejson flake8 fabric requests pyyaml pandas
conda install --name django2 numpy


conda install --name django2 -c conda-forge django-mptt django-import-export

conda install --name django2 https://anaconda.org/conda-forge/dj-static/0.0.6/download/noarch/dj-static-0.0.6-py_2.tar.bz2
conda install --name django2 https://anaconda.org/auto/django-localflavor/1.0/download/linux-32/django-localflavor-1.0-py27_0.tar.bz2
conda install --name django2 https://anaconda.org/auto/django-role-permissions/0.3.1/download/linux-32/django-role-permissions-0.3.1-py27_0.tar.bz2
conda install --name django2 https://anaconda.org/travis/django-sslserver/0.11/download/linux-64/django-sslserver-0.11-py27_0.tar.bz2

validate_email

conda install -c auto --name django2 django-smart-selects


How to install Oracle Java 8

tar -zxvf jdk-8u191-linux-i586.tar.gz 
sudo cp -Rap jdk1.8.0_191 /opt
sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_191/bin/java 100
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_191/bin/javac 100
update-alternatives --display java
update-alternatives --display javac
java -version
javac

How to install gcc/g++ 4.7, 4.8 and 5.4.1

http://mortenvp.com/installing-a-newer-gccg-on-ubuntu-12-04-lts/

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7 g++-4.7
sudo apt-get install gcc-4.8 g++-4.8
sudo apt-get install gcc-5 g++-5
update-alternatives --display gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
update-alternatives --display gcc
gcc -v

How to install node v11

wget  http://nodejs.org/dist/node-latest.tar.gz
tar -zxvf node-latest.tar.gz
cd node-v11.6.0/
./configure  --openssl-no-asm
make && sudo make install
node -v

How to install Golang 1.11.4

wget https://dl.google.com/go/go1.11.4.linux-386.tar.gz
tar -zxvf go1.11.4.linux-386.tar.gz
sudo mv go /usr/local
echo '# Node Enviroment Setup' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' >> ~/.bashrc

Go out from Terminal and open Terminal again

mkdir -p ~/go/src/hello && cd ~/go/src/hello
touch hello.go
nano hello.go

hello.go

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}

Build the hello.go file:

go build

Run the script:

./hello

Install Yarn 1.12.3

curl -o- -L https://yarnpkg.com/install.sh | bash

How to install Apache, PHP, Mysql

Follow this step by step:

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Install MySQL

sudo apt-get install mysql-server
sudo mysql_secure_installation

Use MySQL

mysql -u root -p
sudo nano /etc/apache2/sites-enabled/000-default

Change AllowOverride to All

<Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>
sudo service apache2 restart

Problem: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

sudo touch /etc/apache2/conf.d/fqdn
sudo nano /etc/apache2/conf.d/fqdn

then add

ServerName localhost

Restart

sudo service apache2 restart

Firefox 44 Ubuntu 11.04 (Release date: 21-09-2015)

sudo apt-get install -y libgtk-3-dev libcanberra-gtk-module libcanberra-gtk3-module
sudo rm -rf /opt/firefox* && sudo rm -rf /usr/bin/firefox && sudo rm -rf /usr/share/applications/firefox.desktop
https://ftp.mozilla.org/pub/firefox/releases/44.0b9/linux-i686/pt-BR/firefox-44.0b9.tar.bz2
tar -xjvf firefox*.bz2
mkdir /opt
sudo mv firefox /opt/firefox
sudo ln -sf /opt/firefox/firefox /usr/bin/firefox
echo -e '[Desktop Entry]\n Version=44\n Encoding=UTF-8\n Name=Mozilla Firefox\n Comment=Navegador Web\n Exec=/opt/firefox/firefox\n Icon=/opt/firefox/browser/chrome/icons/default/default128.png\n Type=Application\n Categories=Network' | sudo tee /usr/share/applications/firefox.desktop
sudo chmod +x /usr/share/applications/firefox.desktop
cp /usr/share/applications/firefox.desktop  /home/user/Desktop

sublime3.desktop

[Desktop Entry]
Type=Application
Terminal=false
StartupNotify=true
Name=Sublime Text 3
Name[en_US]=Sublime Text 3
GenericName=Text Editor
GenericName[en_US]=Text Editor
Comment=Edit text files
Comment[en_US]=Edit text files
Exec=/usr/bin/sublime_text_3/sublime_text %U
Icon=/home/user/Pictures/sublime.png
Categories=Development;TextEditor
MimeType=text/plain

TSL

June 30, 2018 => On that date all remaining python.org sites, including PyPI, will no longer support TSL 1.0 and 1.1. Older Python versions that do not implement TLSv1.2 will be prohibited from accessing PyPI.

check your version of python supports TLS1.2:

python -c "import json, urllib2; print json.load(urllib2.urlopen('https://www.howsmyssl.com/a/check'))['tls_version']"
  • Python 2.7.1+ (Ubuntu 11.04) => TLS 1.0
  • Python 2.7.15 => TLS 1.3
ll /usr/bin/python
lrwxrwxrwx 1 root root 9 2018-12-25 11:24 python -> python2.7*

Ubuntu 12.04

OpenSSL 1.0.1 14 Mar 2012
TLS 1.2
apt-get changelog openssl

Update Python to 2.7.15

The package “python2.7” exists in the Ubuntu repositories but it’s not up-to-date.

If you want the latest version of Python, you’ll have to install it from source.

version=2.7.15
mkdir -p /opt/python/packages/python/
cd /opt/python/packages/python/
wget --no-check-certificate https://www.python.org/ftp/python/$version/Python-$version.tgz
tar -xf Python-$version.tgz -C /opt/python/packages/python
ln -s /opt/python/packages/python/Python-2.7.15 /opt/python/packages/python/current
cd /opt/python/packages/python/current
./configure --prefix="/opt/python/builds/python/$version" --with-ssl
make && sudo make install
cd ..
rm /opt/python/packages/python/current
ln -s /opt/python/builds/python/2.7.15/ /opt/python/builds/python/current

Test

/opt/python/builds/python/2.7.15/bin/python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))'

Link

sudo ln -s /opt/python/builds/python/2.7.15/bin/python /usr/bin/python2.7.15
python2.7.15 -V
sudo rm /usr/bin/python
sudo ln -s /opt/python/builds/python/2.7.15/bin/python /usr/bin/python

Solve problem [ ValueError: /usr/bin/python does not match the python default version. It must be reset to point to python2.7 ] on apt-get install

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python

Solve problem [No module named 'lsb_release'] when lsb_release -a

sudo ln -s /usr/share/pyshared/lsb_release.py /usr/lib/python2.7/site-packages/lsb_release.py

Test

python
import lsb_release

Solve problem [ sudo: add-apt-repository: command not found ]

sudo apt-get install -y python-software-properties

How to fix Python SSL CERTIFICATE_VERIFY_FAILED

Server certificate verification by default has been introduced to Python recently (in 2.7.9). This protects against man-in-the-middle attacks, and it makes the client sure that the server is indeed who it claims to be.

As a quick (and insecure) fix, you can turn certificate verification off, by:

export PYTHONHTTPSVERIFY=0
python your_script

or

PYTHONHTTPSVERIFY=0 python your_script

Bugfix ModuleNotFoundError: No module named 'apt_pkg'

cd /usr/lib/python3/dist-packages
sudo cp apt_pkg.cpython-32mu.so apt_pkg.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment