Nesse artigo será exibido detalhadamente os processos feito via terminal para a instalação dos programas

Ubuntu 18.04

After Install

### PPA (Personal Package Archives)

sudo apt install \
build-essential \
curl \
gdebi-core \
git \
gnome-tweaks \
gnupg2 \
gufw \
indicator-cpufreq \
jq \
lame \
libavcodec-extra \
linux-tools-generic \
lynx \
meld \
net-tools \
openssh-server \
p7zip-full \
preload \
python3-pip \
python3-venv \

sudo service ssh start


sudo add-apt-repository ppa:linrunner/tlp

sudo apt update && sudo apt install tlp tlp-rdw smartmontools && sudo tlp start

# sudo tlp-stat

# https://yarnpkg.com/en/docs/usage

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update && sudo apt-get install yarn    


wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo gdebi google-chrome-stable_current_amd64.deb


git config --global credential.helper cache
git config --global user.email "[email protected]"
git config --global user.name "USR"
git config --global http.postBuffer 157286400 # FIX: Error: fatal: The remote end hung up unexpectedly, https://confluence.atlassian.com/stashkb/git-push-fails-fatal-the-remote-end-hung-up-unexpectedly-282988530.html
git config --global --list

ssh -T [email protected]

# FIX: [email protected]: Permission denied (publickey)
# Obter a SSH Key 'cat ~/.ssh/id_rsa.pub' e adicionar em https://github.com/settings/keys

# https://pypi.org/

which pip
which pip3
pip --help
pip --version
pip3 --version
pip3 check
pip3 list
pip help install

python3 -m pip --version
python3 -m pip check
python3 -m pip list

# Upgrade pip
# Dont use because Crash Dependecies
# pip3 freeze --local | sed -rn 's/^([^=# \t\\][^ \t=]*)=.*/echo; echo Processing \1 ...; pip3 install -U \1/p' | sh


python3 -m pip install --upgrade --user pip

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall --user

pip --version


pip install localstack
pip install beautysh
pip install --upgrade google-api-python-client oauth2client
pip install virtualenv
pip install pipdeptree --user --verbose

pip3 install awscli --upgrade --user
pip3 install awsebcli --upgrade --user

# FIX: Error due to dependency updates

pip3 uninstall cement --yes --verbose
pip3 uninstall awsebcli --yes --verbose
pip3 install awsebcli --upgrade --user

# https://snapcraft.io/store

snap list
snap version

sudo snap install chromium
sudo snap install circleci
sudo snap install docker
sudo snap install ffmpeg
sudo snap install gimp
sudo snap install gitkraken
sudo snap install keepassxc
sudo snap install nmap
    nmap -sP "$(ip -4 -o route get 1 | cut -d ' ' -f 7)"/24 | grep report | cut -d ' ' -f 5- # Display live hosts on the network
    lsof -i -P -n # Display ports
    sudo lsof -i -P -n # Display ports
sudo snap install obs-studio
sudo snap install okular
sudo snap install opera
sudo snap install screencloud
sudo snap install sftpclient
sudo snap install vlc

#sudo snap install ruby --classic
sudo snap install atom --classic
sudo snap install brackets --classic
sudo snap install google-cloud-sdk --classic
sudo snap install heroku --classic
sudo snap install node --channel=10/stable --classic
sudo snap install shotcut --classic

# https://atom.io/packages

apm install \
    atom-beautify \
    atom-clock \
    atom-html-preview \
    auto-indent \
    autoclose-html \
    busy-signal \
    color-picker \
    editorconfig \
    file-icons pigments \
    highlight-selected \
    intentions \
    linter \
    linter-csslint \
    linter-js-standard \
    linter-php \
    linter-ui-default \
    markdown-preview-plus \
    markdown-writer \
    open-recent \
    pretty-json \
    script \
    sort-lines \

Docker setup

# By default the docker daemon always runs as the root user, therefore you need to prepend sudo to your Docker command(s).
# 1. Create the docker group.
sudo groupadd docker
# 2. Add your user to the docker group.
sudo usermod -aG docker $USER
# 3. Log out and log back in so that your group membership is re-evaluated.
# 4. Verify that you can run docker commands without sudo.
docker run hello-world
# more ...
docker info
docker search ubuntu
docker container ls

NVM - Node Version Manager

# https://www.npmjs.com/
# https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
# https://github.com/nvm-sh/nvm
# Global Modules without sudo
wget https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh
bash ./install.sh
command -v nvm # To verify that nvm has been installed
nvm install node

npm config list
npm list --depth 0
npm list -g --depth 0
ncu --global
npm update --global # --unsafe-perm

npm install -g npm-check-updates && ncu -u && npm i

npm install -g clever-tools
npm install -g create-react-app
npm install -g depcheck
    depcheck  . --json | jq
npm install -g lerna
npm install -g nodemon
npm install -g now
npm install -g speed-test
npm install -g stremio-addon-sdk
npm install -g pm2
    pm2 start server.js
npm install -g npm-check

# FIX: [nodemon] Internal watch failed: ENOSPC: System limit for number of file watchers reached, watch

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p


# Deploy :: https://zeit.co/dashboard
# https://github.com/zeit/now-examples
# https://zeit.co/docs/v2/deployments/official-builders/python-now-python/
# https://github.com/zeit/now-cli

# [CONTRA:] Não permite uso de sub pastas e não tem automação do Composer

now login
now ls
now dev --debug         # Run locally during development
now                     # Deploy to the cloud
now billing ls
now logs stremio-dublados.mozgbrasil.now.sh
now rm magento-mozg


# Global Modules without sudo
# https://rvm.io/

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

curl -sSL https://get.rvm.io | bash -s stable --rails

rvm -v
rvm list

# To start using RVM you need to run `source /home/marcio/.rvm/scripts/rvm` in all your open shell windows, in rare cases you need to reopen all shell windows.
# To start using rails you need to run `rails new <project_dir>`.


gem install jekyll
gem install github-pages
gem install rouge
jekyll -v        
gem install capistrano


aws --version
eb --version
docker version
docker-compose version
docker-machine version    
which gem
gem --version
heroku --version
node --version
yarn --version
npm --version
nvm --version
pip -V
python -V
which ruby
ruby --version    


# https://phar.io/

wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver pool.sks-keyservers.net --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
sudo mv phive.phar /usr/local/bin/phive

phive install php-cs-fixer --global


# Após criar uma pasta e compartilhar pelo Nautilus só deve funcionar a autenticação após ser criado o devido usuário no Samba
sudo smbpasswd -a $USER


cd ~/dados/containers_docker
git clone https://github.com/cytopia/devilbox
cd devilbox
cp env-example .env
touch touch.txt
echo "commit - $(date '+%d/%m/%Y %H:%M:%S')" > touch.txt

diff --brief --recursive tmp/devilbox-2019-03-07 devilbox
meld tmp/devilbox-2019-03-07 devilbox

docker-compose up

run devilbox

cd ~/dados/containers_docker/devilbox

docker --version && docker images && docker images -a && docker images ps && docker ps && docker ps -a && docker network ls

sudo netstat -tulpn # To list open ports use the netstat command

service --status-all
sudo service mysql stop
sudo service apache2 stop
sudo service php7.2-fpm stop

docker-compose down --remove-orphans
docker-compose up

cd /shared/httpd/localhost/htdocs/mozgbrasil/magento2


Virtual Hosts

mkdir -p ~/dados/mount/www/localhost/htdocs/

sudo nano /etc/hosts localhost.loc

cd ~/dados/mount/www/localhost/htdocs/

ln -s /home/marcio/dados/mozgbrasil

echo "<?php phpinfo(); ?>" > phpinfo.php

cat > .htaccess <<- _EOF_
# enable directory browsing
Options +Indexes

Fix: tail: recursos esgotados do inotify, tail: inotify não pôde ser usado; revertendo para sondagem (polling)

cat /proc/sys/fs/inotify/max_user_instances # 128
cat /proc/sys/fs/inotify/max_user_watches # 8192
sudo sysctl -w fs.inotify.max_user_instances=12345
sudo sysctl -w fs.inotify.max_user_watches=640123


# https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp/
# https://hostadvice.com/how-to/how-to-setup-varnish-http-cache-on-an-ubuntu-18-04-vps-or-dedicated-server/
# https://e-tinet.com/linux/servidor-apache/
# https://serverfault.com/questions/904065/switch-apache-from-prefork-to-event-in-ubuntu-16-get-php-7-working

sudo apt install \
libmcrypt-dev \
mysql-client \
mysql-server \
php-apcu \
php-dev \
php-gettext \
php-imagick \
php-memcache \
php-pear \
php7.2 \
php7.2-bcmath \
php7.2-cgi \
php7.2-common \
php7.2-curl \
php7.2-fpm \
php7.2-gd \
php7.2-imap \
php7.2-intl \
php7.2-json \
php7.2-mbstring \
php7.2-mysql \
php7.2-opcache \
php7.2-pspell \
php7.2-recode \
php7.2-soap \
php7.2-sqlite3 \
php7.2-tidy \
php7.2-xmlrpc \
php7.2-xsl \
php7.2-zip \

sudo pecl channel-update pecl.php.net
pecl search mcrypt
sudo pecl install mcrypt-1.0.2

sudo nano /etc/php/7.2/fpm/php.ini
sudo nano /etc/php/7.2/cli/php.ini

sudo a2dismod mpm_prefork # This disables the prefork MPM. Only one MPM can run at a time.
sudo a2enmod mpm_event # Enable event MPM. You could also enable mpm_worker.
sudo a2enmod headers # FIX: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
sudo a2enmod proxy_fcgi setenvif actions rewrite ssl http2
sudo a2ensite default-ssl
sudo a2enconf php7.2-fpm

sudo nano /etc/apache2/sites-available/000-default.conf

    # add into <VirtualHost> - </VirtualHost>

<Directory "/var/www/html">
  AllowOverride All

<FilesMatch "\.php$">
SetHandler "proxy:fcgi://"

sudo nano /etc/php/7.2/fpm/pool.d/www.conf

    # line 36: search "listen ="

    listen =

Symlink WWW

sudo ln -s ~/dados/mount/www/localhost/htdocs /var/www/html

FIX: Apache

# No Magento2 no processo de instalação é exibido o retorno

# "$HTTP_RAW_POST_DATA is deprecated from PHP 7.2 onwards and will stop the installer from running. Please open your php.ini file and set always_populate_raw_post_data to -1.", pesquise por ";always_populate_raw_post_data = -1" e retire o comentário ";"

    sudo nano /etc/php/7.2/fpm/php.ini

# Atualize para

    display_errors = On
    max_input_vars = 2000
    memory_limit = 1024M
    zlib.output_compression = On
    max_execution_time = 90

# Algumas mudanças que que vai ajudar a fazer o seu servidor apache um pouco mais eficiente

    sudo nano /etc/apache2/apache2.conf

# Atualize "Timeout 300" para "Timeout 600"

# Atualize "KeepAliveTimeout 5" para "KeepAliveTimeout 2"

FIX: Apache - Acesso aos arquivos de log

ls -lah ~
groups $USER
groups www-data

# 1. Add your user to the www-data group.
sudo usermod -aG www-data $USER

ls -lah ~
groups $USER
groups www-data

Em seguida executei as instruções “Restart: apache & php-fpm”

sudo service apache2 restart
sudo service php7.2-fpm restart



phpmyadmin / senha

  #1698 - Access denied for user 'root'@'localhost'
  sudo mysql -u root
      SELECT User FROM mysql.user;
      ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'nova senha';

To activate the new configuration, you need to run:

sudo systemctl restart apache2

FIX: pdo_mysql extension is not installed

sudo phpenmod pdo_mysql

#sudo phpdismod pdo_mysql

Restart: apache & php-fpm

apache2 -v
sudo apache2ctl configtest
sudo apachectl fullstatus
sudo apachectl -M
sudo apachectl -V

service --status-all
sudo service mysql status
sudo service php7.2-fpm status
sudo service apache2 restart
sudo service php7.2-fpm restart


mysql --version
apache2 -v
php -v




    curl -sS https://getcomposer.org/installer | php

## FIX: https://getcomposer.org/doc/00-intro.md#globally

    sudo mv composer.phar /usr/local/bin/composer

## FIX: [RuntimeException] /home/???/.composer/cache/vcs does not exist and could not be created.
## Cannot create cache directory /home/???/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
##  [RuntimeException] Can not clone [email protected]:???/???.git to access package information. The "/home/???/.composer/cache/vcs " directory is not writable by the current user.
## FIX: https://github.com/thomaszbz/native-dockerfiles-typo3/issues/19

    sudo chown -R $USER $HOME/.composer

## plugins

    composer global require hirak/prestissimo

Sobre o Ubuntu

Para começar a atualização do Ubuntu do sistema, primeiro precisamos atualizar a lista de índice de pacotes. Abra o terminal e digite:

sudo apt update

Podemos instalar a atualização para todos os pacotes de uma só vez: A forma a seguir vai atualizar todas as versões dos pacotes instalados, sem remover pacotes.

sudo apt upgrade

Tudo feito. Seu sistema Ubuntu agora está totalmente atualizado.

Durante a atualização inicial do sistema, alguns dos pacotes podem se tornar obsoletos e, portanto, não são mais necessários. Para remover todos os pacotes desnecessários, execute:

sudo apt autoremove

Para analise do Kernel


Para analise da Bios

sudo dmidecode -t bios

UFW ( Uncomplicated Firewall ) é um firewall padrão no Ubuntu 18.04 Bionic Beaver Linux.

Por padrão, o UFW está desativado. Você pode verificar o status do seu firewall executando o seguinte comando:

sudo ufw status

Para habilitar a execução do firewall:

sudo ufw enable

Sincronia entre maquinas locais

rsync --archive --compress --verbose --progress /home/marcio/dados/mozgbrasil/ [email protected]:/home/marcio/dados/mozgbrasil/

rsync --archive --compress --verbose --progress /media/marcio/HDJMicron/videos/ [email protected]:/media/marcio/HDD/videos/

Sincronia entre maquinas e dispositivo USB

rsync --archive --compress --verbose --progress ~/dados/mozgbrasil /media/marcio/HDJMicron/dados/

rsync -av --progress ~/Imagens /media/marcio/Expansion\ Drive/MeusBackups/backup_inspiron_7520_01052019/
rsync -av --progress ~/Downloads /media/marcio/Expansion\ Drive/MeusBackups/backup_inspiron_7520_01052019/
rsync -av --progress ~/dados /media/marcio/Expansion\ Drive/MeusBackups/backup_inspiron_7520_01052019/

Conectar ao SSH “Secure SHell”

Download via SCP “Secure Copy”

scp -r [email protected]:/home/marcio/Imagens/ /home/marcio/Imagens/

Upload via SCP “Secure Copy”

scp -r /home/marcio/Imagens/ [email protected]:/home/marcio/Imagens/

Como criar a SSH Key

ssh-keygen -t rsa

Como obter a SSH Key

cat ~/.ssh/id_rsa.pub

Efetuar login no SSH com chave ppk


sudo apt-get install putty-tools

puttygen yourkey.ppk -O private-openssh -o yourkey.pem

chmod 400 yourkey.pem

ssh -i yourkey.pem [email protected]

Conectar via SFTP pelo nautilus

Conectar via Samba pelo nautilus


Conectar via ssh pelo terminal

Obter a versão do PHP via terminal

php -r \@phpinfo\(\)\; | grep 'PHP Version' -m 1

php -i | grep 'PHP Version' -m 1

Execução comando condicional em linha

sh -c 'if [ "$TRAVIS_PHP_VERSION" = "5.4" ] || [ "$TRAVIS_PHP_VERSION" = "5.5" ]; then echo '0'; else echo '1'; fi;'

How to check if php-fpm is running

php-fpm --test

ps aux | grep php-fpm

netstat -lntp

Monitorando Apache

Visualizar erros do servidor

No terminal pode ser o comando para a visualização do log de erro do servidor

tail -f /var/log/apache2/error.log

to see which group the current user belongs to:

groups groups marcio

to list the group members along with their GIDs.

id $USER

Monitorando MySQL

Na necessidade de acessar o MySQL Client e ver os processos

mysql -h 'localhost' -u root -p

show processlist;

ou melhor ainda

mysqladmin -u root -p -i 1 processlist

mysql config

mysql -h '' -P '3306' -u 'root' -p'12345' -e "SHOW GLOBAL VARIABLES LIKE 'innodb_buffer_pool_size';"

mysql --help

sudo echo "innodb_buffer_pool_size = 8M" >> /etc/mysql/mysql.conf.d/mysqld.cnf

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

cat /etc/mysql/mysql.conf.d/mysqld.cnf

sudo systemctl status mysql
sudo systemctl restart mysql

mysql -h '' -P '3306' -u 'root' -p'12345' -e "SHOW GLOBAL VARIABLES LIKE 'innodb_buffer_pool_size';"

Recursively fix bad file permissions

# A common suggestion is to use which means:

# 755 for directories: full control for the user, and everyone else can traverse directories.
# 644 for files: read-write permissions for the user, and read-only for everyone else.

find /home/marcio/dados/mozgbrasil/ -not \( -wholename "*.git*" -prune \) -type f -exec echo [email protected] {} \;

find /home/marcio/dados/mozgbrasil/ -not \( -wholename "*.git*" -prune \) -type d -exec echo [email protected] {} \;

find /home/marcio/dados/mozgbrasil/ -not \( -wholename "*.git*" -prune \) -type f -exec chmod 644 {} \;

find /home/marcio/dados/mozgbrasil/ -not \( -wholename "*.git*" -prune \) -type d -exec chmod 755 {} \;