Skip to content

Instantly share code, notes, and snippets.

@lavesan
Last active March 21, 2020 20:35
Show Gist options
  • Save lavesan/a06375f34c1e276deba12314c6027ee2 to your computer and use it in GitHub Desktop.
Save lavesan/a06375f34c1e276deba12314c6027ee2 to your computer and use it in GitHub Desktop.
Linux

Matar o processo em uma porta em uso

kill -9 22182
# Se não funcionar:
sudo kill -9 `sudo lsof -t -i:9001`
# Se não funcionar mesmo assim:
sudo kill -9 $(sudo lsof -t -i:9001)
# Adicionar um namespace para um ip
sudo nano /etc/hosts # Adiciono o ip nesta rota
# Ver ip
ifconfig

Retornar processo de uma porta em específico

1 -

lsof -i :3000

2 - Derrubar processo da porta

kill [número do PID retornado acima]

Rodar processo mesmo quando o terminal é fechado

nohup [comando para rodar meu processo, como um 'npm run start']

Listar todos os processos ativos

ps
# Para listar os processos de um grupo especifico (neste exemplo lista todos os nohup)
ps -ef |grep nohup

Alterar arquivo com Vim

  • Para abrir um arquivo no vim: sudo vi ./path/do/arquivo
  • To edit the file, Press I from keyboard to enter into insert mode, here you can do editing just like the normal editor.
  • When done with editing, get out of this mode by pressing Esc. It will return you to normal mode.
  • To save the file, type :w in command mode
  • To quit the editor, type :q in command mode
  • To combine the above actions type :wq to save and quit simultaneously.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment