Skip to content

Instantly share code, notes, and snippets.

@danilobatistaqueiroz
Last active May 19, 2020 03:24
Show Gist options
  • Select an option

  • Save danilobatistaqueiroz/ba5c751170249b199d2a14bb7f0a7618 to your computer and use it in GitHub Desktop.

Select an option

Save danilobatistaqueiroz/ba5c751170249b199d2a14bb7f0a7618 to your computer and use it in GitHub Desktop.
bash tips

set-a-shortcut-for-always-on-top-ubuntu
Alt+Space ... T https://askubuntu.com/questions/126233/how-to-set-a-shortcut-for-always-on-top-for-window

Configurando variáveis de ambiente permanentemente

https://help.ubuntu.com/community/EnvironmentVariables#Session-wide_environment_variables

configurando o .profile, em distribuições RedHat/CentOS/Fedora .bash_profile

PERMANENT BASH ALIASES ON GIT FOR WINDOWS

inside user's folder: C:\Users\<<your user>>

create the file:
.bash_profile

add the aliases:
alias cls='printf "\033c"'

Start a java program without the console

start javaw -jar -Xms1024m -Xmx1024m crafty.jar


Links

https://stackoverflow.com/questions/5367068/clear-a-terminal-screen-for-real
https://stackoverflow.com/questions/37104273/how-to-set-aliasses-in-the-git-bash-for-windows


Diversos Comandos

listar todas as variáveis de ambiente:
printenv | more
printenv | less

é possível utilizar o comando env e o set também.

Trocar o prompt do bash

Trocar usuario@hostname:~$ para usuario:~$
entre em ~/.bashrc e insira a linha: export PS1="\u:\w\\$ "

digite source ~/.bashrc no terminal para refletir as alterações.

link: https://www.ostechnix.com/hide-modify-usernamelocalhost-part-terminal/

Mostrar a versão do ubuntu

lsb_release -a
ou use:
cat /etc/lsb-release

Detalhes de um pacote disponível no repositório

apt-cache show PACKAGE_NAME

Hibernar

sudo systemctl hibernate

Conectar numa rede

sudo nmcli dev wifi con "nomedarede" password <<senha>>

reconectar:
nmcli c up id "nomedarede"

listar redes wifi:
nmcli dev wifi

visualizar os IPs das interfaces

ip address show enp0s3 - exibe o ip
ip link show enp0s3 - exibe o macaddress

Listar portas escutando

sudo netstat -tulpn

listar todos os hosts na mesma rede

nmap 192.168.1.0/24 - lista os hosts e as portas abertas

Renomear o terminal

adicione no arquivo ~/.bashrc

# function to set terminal title
function set-title() {
  if [[ -z "$ORIG" ]]; then
    ORIG=$PS1
  fi
  TITLE="\[\e]2;$*\a\]"
  PS1=${ORIG}${TITLE}
}

Alias para limpar terminal

adicionar em ~/.bashrc

alias cls='printf "\033c"'

Configurar a rede

ls /etc/netplan/....yaml
sudo vim /etc/netplan/....yaml
https://www.tecmint.com/configure-network-static-ip-address-in-ubuntu/

Reiniciar o driver de rede

sudo modprobe -r rt61pci &&
sudo modprobe rt61pci

Appending a line in the end of a file

echo "abc" >> file
https://askubuntu.com/questions/21555/command-to-append-line-to-a-text-file-without-opening-an-editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment