Yet another linux CLI tips & tricks list
(update: 2017-12-15 added few magic mc commands at bottom)
When I started my jurney with *nix like systems, the environment was hostile to me. But after a few years it become obvious that the
CLI is a superior way of dealing with Linux OS.
You can see a lot of similiar articles in the web like
here or
here but this list is stripped to what I find useful on the one hand, eliminating obvious on the other
(eg. I'm assuming that you know you can browse hostory with arrow key or use
tab for
apt-get install completion).
So here is my list.
ctrl+r then type old-command-part - reverse search
Reverse search is one of the most important key shortcuts when using CLI, because usually you don't remember what exact arguments were used in in your beloved
tricky_and_very_long_command you've commited in the past.
You will find out that in the real life there is a limited number of commands (with minor modifications) your are using frequently.
ctrl+d leave or exit from console/ssh session etc
current line navigation commands
ctrl+e go to end of line
ctrl+a go to begining of line
ctrl+u delete till begining of line
ctrl+k delete till end of line
ctrl+w delete word before cursor
NOTE you can change default bash editor to vi like editor with:
set -o vi command
tmux
Allows executing commands on a detached console (useful when doing something via ssh and can't/won't have open session) - this should be a separate blog post but here is my cheat sheet
tmux start a new tmux session
tmux a or tmux attach attach to an existing tmux session
while in tmux session
ctrl+b+d leave (d for detach) tmux session not killing it
ctrl+b+c create a new pane
ctrl+b+n next pane
ctrl+b+p previous pane
ctrl+b+" split pane horizontally
ctrl+b+% split pane vertically
ctrl+b+arrow go to: up right down left panel
ctrl+b holding ctrl key and pressing one of arrow keys - allow change panel size!
NOTE: nice thing about tmux is...you can use tmux in tmux by doing double
ctrl+b
mc - Midnight Commander
If you are old enough (like I am) you do remember famous Norton Commander or Total Commander.
Midnight Commander is a similar tool - superior when it comes to copy files over ssh or ftp.
NOTE: if an escape key
esc is not present int your keyboard - like in many bluetooth keyboards - you can use
ctrl+[ instead.
ctrl+\ - open favorite location list (then add current, edit, delete)
esc+9 - open right pane menu
esc+0 - exit
esc+h - in any entry field (like 'open ftp/ssh' dialog window) wherever ^ character is present - opens current entry field history dialog
- alt + o - display dir under cursor on other pane
- alt + i - display current dir on other pane
- alt + . - display/hide hidden files
- alt + h - display history
- alt + y/u - change dir to previous/next dir