Ubuntu

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

Ubuntu 20.04

After Install

chrome

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

sudo dpkg -i google-chrome-stable_current_amd64.deb

google-chrome --version

flatpak

https://flatpak.org/setup/Ubuntu/

sudo apt install flatpak \
gnome-software-plugin-flatpak

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

To complete setup, restart your system

flathub

https://flathub.org/

flatpak install flathub com.github.huluti.ImCompressor

flatpak install flathub org.keepassxc.KeePassXC

flatpak install flathub org.gnome.meld

flatpak install flathub org.gimp.GIMP

flatpak install flathub org.inkscape.Inkscape

flatpak install flathub com.visualstudio.code

        # Fix: https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc
        # FIX: [nodemon] Internal watch failed: ENOSPC: System limit for number of file watchers reached, watch

        cat /proc/sys/fs/inotify/max_user_watches

        cat /etc/sysctl.conf

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

        cat /etc/sysctl.conf

        cat /proc/sys/fs/inotify/max_user_watches

        # 1 - Launch VS Code
        # 2 - Quick Open (Ctrl+P), paste the following command, and press enter.

        ext install dbaeumer.vscode-eslint
        ext install esbenp.prettier-vscode
        ext install foxundermoon.shell-format
        ext install @id:ms-python.python

flatpak install flathub com.github.micahflee.torbrowser-launcher

flatpak install flathub com.obsproject.Studio

flatpak install flathub org.blender.Blender

flatpak install flathub org.audacityteam.Audacity

flatpak install flathub org.avidemux.Avidemux

snapcraft

https://snapcraft.io/store

snap list
snap version

sudo snap install chromium

sudo snap install cmake --classic

sudo snap install jq

    jq

sudo snap install links

sudo snap install nmap

    # Display live hosts on the network

        nmap -sP "$(ip -4 -o route get 1 | cut -d ' ' -f 7)"/24 | grep report | cut -d ' ' -f 5-

sudo snap install node --classic --channel=12/stable

    node -v
    npm -v
    yarn -v

    # Use o comando abaixo para alterar o canal;

        sudo snap switch node --channel=12/stable

    # Para atualizar as informações, use este comando;

        sudo snap refresh

sudo snap install htop

    # htop

sudo snap install docker

    docker version
    docker-compose version
    docker-machine version

    docker info
    # Fix: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/search?limit=25&term=ubuntu: dial unix /var/run/docker.sock: connect: permission denied
    # By default the docker daemon always runs as the root user, therefore you need to prepend sudo to your Docker command(s).
        groups
    # 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

sudo snap install google-cloud-sdk --classic

sudo snap install heroku --classic

    heroku -v

sudo snap install riseup-vpn --classic

sudo snap install konversation

sudo snap install ksnip

sudo snap install glade

sudo snap install shotcut --classic

PPA (Personal Package Archives)

apt-cache search python3

sudo apt install \
    apt-transport-https \
    build-essential \
    ca-certificates \
    curl \
    default-jdk \
    ffmpeg \
    gconf2 \
    git \
    git-cola \
    gnome-tweaks \
    gnupg2 \
    gnupg-agent \
    graphviz \
    gufw  \
    indicator-cpufreq \
    imagemagick \
    lame \
    libavcodec-extra \
    libcanberra-gtk-module \
    linux-tools-generic \
    net-tools \
    openssh-server \
    optipng \
    p7zip-full \
    preload \
    python3-dev \
    python3-pip \
    ruby-full \
    tlp \
    software-properties-common \
    ubuntu-restricted-extras \
    vlc \
    zlib1g-dev \
    webp

sudo apt install pavucontrol # Fix: hdmi sounds

sudo service ssh start

sudo tlp-stat

which ruby
ruby --version

python3 -V
git --version

ImageMagick

https://github.com/ImageMagick/ImageMagick/issues/396#issuecomment-602026541

update(s)

sudo apt update && sudo apt upgrade

flatpak update

sudo snap refresh

npm update --global

gem update --system

git config

git config --global credential.helper cache
git config --global user.email "[email protected]"
git config --global user.name "USR"
git config --global http.postBuffer 524288000 # 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

Node.js

node -v
npm config list
npm list --depth 0
npm list -g --depth 0

# Resolving EACCES permissions errors when installing packages globally
# https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

On the command line, in your home directory, create a directory for global installations:

    mkdir ~/.npm-global

Configure npm to use the new directory path:

    npm config set prefix '~/.npm-global'

    npm config list

In your preferred text editor, open or create a ~/.profile file and add this line:

    echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.profile

    cat ~/.profile

On the command line, update your system variables:

    source ~/.profile

To test your new configuration, install a package globally without using sudo

#

npm install -g lerna
npm install -g npm-check-updates
npm install -g web-ext

#

ncu --global
npm update --global # --unsafe-perm

rubygems

https://rubygems.org/gems

# set up a gem installation directory for your user account
# https://jekyllrb.com/docs/installation/ubuntu/

echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

#

gem --version

gem list

gem install \
  bundler \
  jekyll \
  rouge

bundle -v
jekyll -v

cd ~/dados/projects/mozgbrasil.github.io
bundle install

gem update --system

Jekyll

Run Jekyll

cd ~/dados/projects/mozgbrasil.github.io
JEKYLL_ENV=production bundle exec jekyll serve --verbose

pypi

https://pypi.org/

which pip
pip3 --help
pip3 --version

pip3 check
pip3 list
pip3 help install

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

Dica:

# 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

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

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

dmesg

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 para espelhar discos

--archive               archive mode; equals -rlptgoD (no -H,-A,-X)
--update                skip files that are newer on the receiver
--compress              compress file data during the transfer
--delete                delete extraneous files from destination dirs
--verbose               increase verbosity
--progress              show progress during transfer

rsync --archive --update --compress --delete --verbose --progress /home/marcio/Downloads/ /media/marcio/HDD/Downloads/

rsync --archive --update --compress --delete --verbose --progress /home/marcio/dados/ /media/marcio/HDD/dados/


rsync --archive --update --compress --delete --verbose --progress /home/marcio/dados/ /media/marcio/HDJMicron/2020-05-19-espelho-marcio/dados/

Sincronia entre maquinas locais

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

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

rsync -Pav -e "ssh -i $HOME/.ssh/aws-eb" [email protected]:/var/app/current/ /home/marcio/Downloads/070024

Sincronia entre maquinas e dispositivo USB

# Será copiado a devida pasta para o diretório

rsync --archive --compress --verbose --progress ~/dados/projects /media/marcio/usb-ext4/dados/

rsync --archive --compress --verbose --progress ~/dados/projects /media/marcio/Expansion\ Drive/MeusBackups/dados/projects-2019-10-07/

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/

rsync -av --progress /media/marcio/HDJMicron/2020-04-23/marcio-Inspiron-5548/dados/projects /home/marcio/dados/

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

https://askubuntu.com/questions/818929/login-ssh-with-ppk-file-on-ubuntu-terminal

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

smb://192.168.0.4

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
php-fpm

ps aux | grep php-fpm

netstat -lntp

to see which group the current user belongs to:

groups
groups marcio

to list the group members along with their GIDs.

id $USER

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

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 '127.0.0.1' -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 '127.0.0.1' -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/projects/ -not \( -wholename "*.git*" -prune \) -type f -exec echo [email protected] {} \;

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


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

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