Skip to content

Instantly share code, notes, and snippets.

@alexishida
Last active October 20, 2025 17:51
Show Gist options
  • Select an option

  • Save alexishida/a1843e75f2087924b7d75af52aa98b53 to your computer and use it in GitHub Desktop.

Select an option

Save alexishida/a1843e75f2087924b7d75af52aa98b53 to your computer and use it in GitHub Desktop.
Comandos Linux
# Definiro o ZSH como terminal padrao
chsh -s $(which zsh)
# Symbolic Link
ln -s <source> <target>
# Ubuntu configure locale e timezone
sudo dpkg-reconfigure locales
sudo dpkg-reconfigure tzdata
# Acessar pasta WSL no Windows
\\wsl$
# Contando arquivos na pasta
ls -l | grep -v ^l | wc -l
# Listando os ips com mais acesso
cat access.log | cut -d ' ' -f 2 | sort | uniq -c | sort -nr | head
# Portas Abertas
sudo lsof -i -P -n | grep LISTEN
# Comprimir pastas
tar -zcvf archive-name.tar.gz directory-name
# Comprimindo pastas excluíndo
tar --exclude='./folder' --exclude='./upload/folder2' -zcvf /backup/filename.tgz .
# Comprimir Zip diretorios
zip –r filename.zip directory_name
# Procurando conteudo dentro de arquivos
grep -rnw 'HEAD'
# Buscar por arquivo
find / -type f -name "*.txt"
# Buscar por pasta
find / -iname *php*
# Busca por arquivo e executa arquivo
find . -type f -name "*.txt" -exec rm {} +
# Verifica o tamanho de um diretório
du -sh /var
# Remove trailing \r character that causes this error:
sed -i 's/\r$//' filename
# SSH KEY
ssh -i /path/my-key-pair.pem [email protected]
# SSH PASSWORD
sudo pico /etc/ssh/sshd_config
PasswordAuthentication yes
PermitRootLogin yes
sudo service sshd restart
# https://crontab.guru/
# http://www.crontabgenerator.com/
# crontab -e
* * * * * su -s /bin/bash root -c 'bash /app/start.sh' > /var/logs/error.log
# Reset crontab
crontab -r
# Add crontab through a script
(crontab -l 2>/dev/null; echo "0 * * * * /bin/sh -c \"(export PATH=/usr/bin:/bin; /app/run.sh)\" > /app/log.txt") | crontab -
# Bash loop
while true
do
echo "Press [CTRL+C] to stop.."
sleep 1
done
# Nohup commands
nohup command >/dev/null 2>&1 # doesn't create nohup.out
nohup command >/dev/null 2>&1 & # runs in background, still doesn't create nohup.out
nohup command </dev/null >/dev/null 2>&1 & # completely detached from terminal
nohup ./job.sh > app.log 2>&1 &
# Configure JAVA_HOME (.zshrc .bashrc)
JAVA_HOME=/opt/oracle/jdk1.8.0_321
export JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH
# Create a simbolic link on /usr/bin
sudo ln -s /opt/oracle/jdk1.8.0_321/bin/java /usr/bin/java
sudo ln -s /opt/oracle/jdk1.8.0_321/bin/javac /usr/bin/javac
# Generate htpasswd
# MD5
htpasswd -cm .htpasswd usuario
# bcrypt
htpasswd -cB .htpasswd usuario
# Force add install repo without key
echo deb [trusted=yes] http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
# Resetando Painel do Mate
mate-panel --reset
# Instalando fonts windows
sudo apt-get install ttf-mscorefonts-installer
mkdir ~/.fonts
wget -qO- http://plasmasturm.org/code/vistafonts-installer/vistafonts-installer | bash
sudo fc-cache -f -v
# Limpando cache das fonts
sudo fc-cache -f -v
# Não atualizando e atualizando o pacote especifico
sudo apt-mark hold docker-ce
sudo apt-mark unhold docker-ce
# Revertendo Commit Git
git reset --hard [previous Commit SHA id here]
git push origin [branch Name] -f
#If you want to keep your changes, you can also use:
git reset --soft [previous Commit SHA id here]
# Alterando nome de usuario e email do GIT
git config --global user.name "Fulano de Tal"
git config --global user.email [email protected]
# Novo repositorio
cd existing_folder
git init --initial-branch=main
git checkout -b main
git push --set-upstream origin main
git remote add origin [email protected]:group/reponame.git
git add .
git commit -m "Initial commit"
git push -u origin main
# warning: shebang line ending with \r may cause problems
git config --global core.autocrlf true
rails app:update:bin
# Listando os maiores arquivos
cd /path/to/some/where
du -hsx * | sort -rh | head -10
# Atualizando o Ubuntu
sudo do-release-upgrade -d
# Verificando a versao da distro
lsb_release -a
# debconf-set-selections - insert new values into the debconf database
echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections
# Diffie-Hellman parameter for DHE ciphersuites
# $ sudo openssl dhparam -out dhparam.pem 2048
# Configurar hora do servidor
sudo service ntp stop
sudo ntpdate -s time.nist.gov
sudo service ntp start
# Sincronizando horario com o windows
timedatectl set-local-rtc 1 --adjust-system-clock
# Lista todos os pacotes globais npm
npm list -g --depth=0
# Remove pacotes global
npm -g uninstall <name> --save
# Tmux comandos
# https://tmuxcheatsheet.com/
ctrl+b % ou "
ctrl+z
ctrl+b seta
$ tmux
$ tmux a -t 0
# Nginx rate limit
limit_req_zone $binary_remote_addr zone=site:10m rate=3r/s;
limit_req zone=site burst=5;
# Linux Firewall ufw
https://www.digitalocean.com/community/tutorials/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server
# SSH Tunnel Linux
https://www.tecmint.com/create-ssh-tunneling-port-forwarding-in-linux/
# sudo apt install openssh-server
$ sudo nano /etc/ssh/sshd_config
GatewayPorts yes
$ sudo systemctl restart sshd
OR
$ sudo service sshd restart
$ ssh -f -N -D 1080 [email protected]
# Partition mount "read-only" flag on all detectable ntfs partitions everytime it shuts down or reboots.
If you don't want it to do that, boot to your windows, open up a administator powershell (to do that find powershell in start, right click on it, then select "run as Administrator").
powercfg -h off
# Google Chrome ui small problem
/usr/bin/google-chrome-stable --force-device-scale-factor=n %U
# You can get your current inotify file watch limit by executing:
$ cat /proc/sys/fs/inotify/max_user_watches
$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
#If you like to make your limit permanent, use:
$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p
# Corrigindo bug do icone ubuntu matte 20.04
$ sudo sed -i '/Icon\[/d' /usr/share/applications/*.desktop
$ sudo sed -i '/Icon\[/d' /usr/share/mate/desktop-directories/*.directory
$ sudo update-desktop-database
# Como desativar o relatório de erros do Apport no Ubuntu
# os erros ficam em /var/crash/
$ sudo service apport stop
$ sudo gedit /etc/default/apport
# set this to 0 to disable apport, or to 1 to enable it
# you can temporarily override this with
# sudo service apport start force_start=1
enabled=0
OU
$ sudo sed -i 's/enabled=1/enabled=0/g' /etc/default/apport
# Testando largura de banda
# Startando servidor
$ iperf3 -s -f M
# Teste do client
$ iperf3 -c 10.0.0.1 -t 60 -f M
# Teste do client reverso
$ iperf3 -c 10.0.0.1 -t 60 -f M -r
# Iperf3 public server
# https://github.com/R0GGER/public-iperf3-servers?tab=readme-ov-file#latin-america
iperf3 -c speedtest.sao1.edgoo.net -p 9204-9240
# Limpando a máquina
$ sudo apt-get clean
$ sudo dd if=/dev/zero of=/EMPTY bs=1M
$ sudo rm -f /EMPTY
$ cat /dev/null > ~/.bash_history && history -c && exit
# Ubuntu installation on computers with Intel(R) RST enabled
https://discourse.ubuntu.com/t/ubuntu-installation-on-computers-with-intel-r-rst-enabled/15347
# Ubuntu Vanilla change icon and themas
$ sudo apt install gnome-tweak-tool
$ gnome-tweaks
# Ubuntu ungroup icons
# https://github.com/home-sweet-gnome/dash-to-panel
$ sudo apt update
$ sudo apt install gnome-tweaks
$ sudo apt install gnome-shell-extension-dash-to-panel
# Clean /r to files
$ sed -i -e 's/\r$//' scriptname.sh
# Locale to shortcut app
$ nautilus /usr/share/applications/
# Add icon shortcut
$ sudo apt install alacarte
# If you want to work with sockets manually, you can use the socat utility to expose them over network ports:
$ socat TCP-LISTEN:12345 UNIX-CONNECT:/var/lib/socket.sock
# Grub customizer
$ sudo add-apt-repository ppa:danielrichter2007/grub-customizer
$ sudo apt-get install grub-customizer
$ sudo add-apt-repository ppa:danielrichter2007/grub-customizer -r -y
$ sudo apt-get remove grub-customizer --auto-remove
# Legacy SSL NODE
export NODE_OPTIONS=--openssl-legacy-provider
# Update Firmware
$ sudo service fwupd start
$ sudo fwupdmgr refresh
$ sudo fwupdmgr update
# Icones Área de Trabalho (Desktop)
$ nano ~/Área\ de\ Trabalho/seu_script.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Executar Meu Script
Comment=Atalho para meu script shell
Exec=/caminho/para/seu_script.sh
Icon=/caminho/para/icone.png
Terminal=true
Categories=Utility;
chmod +x ~/Área\ de\ Trabalho/seu_script.desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment