Skip to content

Instantly share code, notes, and snippets.

@ucaiado
Last active November 8, 2018 18:13
Show Gist options
  • Save ucaiado/bc7d776f97e401ebf2d0 to your computer and use it in GitHub Desktop.
Save ucaiado/bc7d776f97e401ebf2d0 to your computer and use it in GitHub Desktop.
LINUX

LINUX - COMMAND LINE

TO COUNT NUMBER OF LINES AND STRING LENGTH

wc -l <filename>  # lines
wc -c 'string'  #length of the string
sed '<lne_number>q;d' <filename> | wc -c  # length of the output string

TO READ A SPECIFIC ROW IN A FILE

ser '<row_number>q;d' <file_name>

RANDOM

tar cvJf vega2.tar.xz df_vega.txt (para fazer um tar.gz)
tar xvzf [ARQUIVO TAR]
7za x [ARQUIVO 7Z]
kwrite ~/.bashrc (arquivo com meus paths)
echo $PATH (para ver o que tem no meu PATH)

UP DATE FLASH PLAYER

su -
zypper in flash-player

IT WOULD BETTER IF YOU DO NOT CHANGE THIS FILE

kdesu kwrite /etc/fstab  &

TO SEE WHERE YOU ARE

pwd

TO FREE THE CONSOLE WHEN YOU USE IT TO RUN SOMETHING ELSE

ctrl+z
bg

TO CREATE OR "TOUCH"ANY FILE

touch filename

TO REBOOT

sudo init 6 - reinicia
sudo init 0 -desliga

MAKE ALIAS

alias st='"path/to/my/program"' (as aspas duplas são para quando tiver espaço no nome)
unalias st#desfaz alias

RENAMING FILES

mv test.txt hope.txt

REMOVE FILES

rm -r directory

PROCURA E LEITURA

history | less ->> Vê uma lista dos comandos utilizados
more [ARQUIVO] ->>Lê arquivo no terminal
less [ARQUIVO] ->> Um more mais sofisticado e que pode ler grandes arquivos
	q - Sai do less
grep -a [ARQUIVO] | less ->> filtra arquivo usando less

SUMÁRIOS

du -hc [PASTA, * (pasta atual)] ->> tamanho das pastas

ZYPPER

zypper in <nome do pacote>: Instala o pacote.
zypper rm <nome do pacote> : Remove o pacote.
zypper ve : Verifica se está tudo OK com as dependências dos pacotes.
zypper lu :Verifica se há updates nos repositórios.
zypper up :   Faz os updates necessários (use em conjunto com o zypper lu).
zypper dup : Faz um update na distro.
zypper se <nome do pacote> : Realiza uma busca pelo pacote.
zypper up -t package : Atualiza todos os pacotes (quando necessário).
zypper help : Abre a seção de ajuda de um comando específico.

PYTHON HTTP SERVER

python -m SimpleHTTPServer 8888

KEEP THINGS UPDATED

sudo zypper up -lt patch  # update the official repos
sudo zypper up -l patch   # update the other ones

WHEN SCREEN LOCKER BRAKE

crtl + alt + 2 x backspace  # it will restart the screen server

TO REPLACE TEXT IN A FILE

sed -i 's/<OLD TEXT>/<NEW TEXT>/g' <file>

TO CONVERT LINUX TIME

date -d @<epoch here>

TO LOOK AT THE LAST LOG FILE GENERATED

cat $(ls -t <SOMETHING HERE>*.log | head -n 1)

TO CHANGE PERMISSION OF A FILE

chmod 754 <FILE NAME>

TO CHECK MEMORY AND FREE SWAP

free -h
sudo swapoff -a && sudo swapon -a

TO KILL ALL INSTANCES PROCESSES

pidof <PROCESS NAME> | xargs kill
pkill <PROCESS NAME>

TO TAIL LOGS FROM A PROCESS WHERE YOU DO NOT KNOW WHERE IT IS

tail -F $(pwdx $(pidof <PROCESS NAME>) | cut -d' ' -f 2 | head -n 1)/*.log
@Sinobal
Copy link

Sinobal commented Nov 23, 2015

nice

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