Skip to content

Latest commit

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Linux Training

Dica de ouro: USAR TAB

Navegação

Emacs keybinds

Vi Keybinds

Pedindo por ajuda

Manual de comandos

man COMMAND

Descricao de um comando:

whatis COMMAND

Alternativa para Help:

tldr COMMAND

Coringas:

*?
[]
{}

Informacoes adicionais:

https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm

Gerenciamento de arquivos e diretorios (pasta eh no Windows)

Criar diretório

mkdir -p

DICA: Criar um diretorio e entrar nele:

mkdir foo &&cd"$_"

Remover diretório

rm FILE
rm -r FILE/DIR
rm -rf FILE/DIR

Esta com duvida? Lembre-se que shell nao tem lixeira!

rm -i FILE

Listar diretorio

ls PATH
ls -a PATH
ls -ls PATH
ls -la PATH
ls PATH | less

Mudar de diretorio

cd PATH
cd~cd ../../../../
cd -

Salvar um caminho na pilha

pushd caminho
popd

Onde estou?

pwd

Copiar arquivos e diretorios

cp
cp -r

Pode ser utilizado \ como separador para copiar arquivos com espaco

Mover arquivos e diretorios

mv

Criar modificar arquivos

touch FILE
> FILE

Busca de arquivos, diretórios e historico de comandos

find -name FILE /PATH

find mais amigável

grep e git grep

grep EXPR ARQ
grep -r foo bar.txt
grep -i foo bar.txt

Encontrar caminho do comando

which COMMAND

bg fg

Pesquisar no historico

Ctrl-r Usando fzf

Visualizar arquivos e diretorios

Ler o conteudo de um arquivo

cat FILE
less FILE

Ler o inicio de um arquivo

head FILE
head -n 2 FILE

Ler o final de um arquivo

tail FILE
tail -n 2 FILE
tail -f FILE

Visualizar como uma arvore

tree PATH
tree -L 2 PATH

xdg

https://wiki.archlinux.org/index.php/XDG_user_directories

xdg-open FILE.pdf

Executar mais de um comando por vez

&&;

Redirecionador de comandos

Ler as mensagens do kernel

dmesg
dmesg -w

Compactadores

tar:

-c cria -t lista -x extrai

tar: criar pacote

tar -cvf package.tar dir

tar: listar arquivos em um pacote

tar -tvf file.tar

tar: extrair pacote

tar -xvf file.tar.gz
tar -xvf file.tar.gz -C path

Compactar gz

tar -cvzf file.tar.gz dir

Compactar bz2

tar -cvjf file.tar.bz2 dir

gzip gunzip zcat

gunzip file.gz
gzip file.txt
zcat file.txt.gz

zip unzip

zip -r arquivo.zip caminho
unzip arquivo.zip

Comandos de rede

wget para baixar arquivos curl eh muito utilizado para desenvolvimento axel para arquivos grandes, eh bem rapido o donwload

SSH acessando um host remoto e copiando arquivos

ssh user@address
scp file user@address
scp -r dir user@address

Tmux

General Informations

https://github.com/tmux/tmux/wikihttps://wiki.archlinux.org/index.php/Tmux

Sane settings

Add the follow settings to ~~/.tmux.conf~ file

# Setting the prefix from C-b to C-aset -g prefix C-a
unbind C-b
bind-key a last-window
bind C-a send-prefix
# Setting the delay between prefix and commandset -s escape-time 0
set-option -g repeat-time 1000
# Scrollback buffer number of linesset -g history-limit 10000
# Set the default terminal mode to 256color modeset -g default-terminal "screen-256color"# Refresh 'status-left' and 'status-right' more oftenset -g status-interval 5
# tmux messages are displayed for 3 secondsset -g display-time 3000
# Super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on
# Focus events enabled for terminals that support themset -g focus-events on
# Renumber windows sequentially after closing any of them.set -g renumber-windows on
# Set the base index for windows to 1 instead of 0set -g base-index 1
# Set the base index for panes to 1 instead of 0
setw -g pane-base-index 1
# Enable emacs modeset -g status-keys emacs
# Display mouse offset -g mouse off
# Easier and faster switching between next/prev windowbind C-p previous-window
bind C-n next-window
# Enable clipboardset -g set-clipboard on
# Enable xterm-keys in your tmux configuration
setw -g xterm-keys on
# Key bindings for horizontal and vertical panes
unbind %
bind| split-window -h -c "#{pane_current_path}"bind - split-window -v -c "#{pane_current_path}"# Swap Window
bind-key -r "<" swap-window -t -1
bind-key -r ">" swap-window -t +1
# Moving between panesbind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Resize panebind -r H resize-pane -L 3
bind -r J resize-pane -D 3
bind -r K resize-pane -U 3
bind -r L resize-pane -R 3
# Open new window and new panel at current directorybind C new-window -c "#{pane_current_path}"# Preview sessions in zoom mode
set-hook -g pane-mode-changed 'if -F "#{||:#{&&:#{pane_in_mode},#{&&:#{pane_in_mode},#{!=:#{pane_mode},copy-mode}}},#{&&:#{?pane_in_mode,0,1},#{window_zoomed_flag}}}" "resizep -Z"'# Reload the file with Prefix rbind r source-file ~/.tmux.conf \; display "Reloaded!"### Status Bar confs## Disable activity alerts
setw -g monitor-activity off
set -g visual-activity off
# Set pane colors - hilight the active paneset -g pane-border-style fg=colour235
set -g pane-active-border-style fg=colour240
# colorize messages in the command lineset -g message-style fg=brightred,bg=black
# Status Barset -g status on
set -g status-justify centre
# Set color for status barset -g status-bg colour0
set -g status-fg yellow
# Set window list colors - red for active and cyan for inactive# set-window-option -g window-status-style fg=brightblue# set-window-option -g window-status-style bg=colour0
set-window-option -g window-status-style dim
# set-window-option -g window-status-current-style fg=brightred# set-window-option -g window-status-current-style bg=colour0
set-window-option -g window-status-current-style bright
# Status bar leftset -g status-left-length 40
set -g status-left "#[fg=green] #S :: #I - #P "# Status bar rigthset -g status-right-length 40
set -g status-right "#{prefix_highlight} #[fg=green] %R :: #H "

Cheat Sheet

Start new tmux:

tmux new -s NAME

Attach a session:

tmux attach -t NAME

List sessions:

tmux ls

Kill session:

tmux kill-session -t NAME

Sessions

:new<CR> new session s list sessions $ name session

Windows (tabs)

c create window w list windows n next window p previous window f find window , name window & kill window

Panes (splits)

vertical split
  • horizontal split

    o swap panes q show pane numbers x kill pane

    • break pane into window (e.g. to select text by mouse to copy)
    • restore pane from window ⍽ space - toggle between layouts <prefix> q Show pane numbers <prefix> z toggle pane zoom PREFIX : resize-pane -J (Resizes the current pane down) PREFIX : resize-pane -K (Resizes the current pane upward) PREFIX : resize-pane -H (Resizes the current pane left) PREFIX : resize-pane -L (Resizes the current pane right)

Copy mode:

Enter Copy Mode [

Clear selection C-g Copy selection M-w In copy mode use Emacs keys to navigate

Misc

d detach t big clock ? list shortcuts

 prompt

About

Improve Linux console skills.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors