Without Linux, computing and especially WEB would evolve in different way and most likely would be less affordable. Summary of commands/approaches, I use frequently. WIP.
history
- historyBecomes really useful paired with grep
,
that allow to narrow history
output results.
Whenever I remember only a part of command, that I have used (copy-pasted form internet,
cause this is what You do in Linux, find commands You barely understand and run with sudo
privileges),
just add the remembered part after grep
:
> history | grep tail
638 [10/10 21:02:43] history | grep tail
639 [10/10 21:02:46] history | grep tails
640 [10/10 21:03:29] dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+'
Now in order to use the command, hit !640
- it will execute the command with
number 640.
> !640
rc linux-image-5.11.0-27-generic 5.11.0-27.29~20.04.1 amd64 Signed kernel image generic
rc linux-image-5.11.0-40-generic 5.11.0-40.44~20.04.2 amd64 Signed kernel image generic
rc linux-image-5.11.0-43-generic 5.11.0-43.47~20.04.2 amd64 Signed kernel image generic
rc linux-image-5.13.0-28-generic 5.13.0-28.31~20.04.1 amd64 Signed kernel image generic
ii linux-image-5.15.0-50-generic 5.15.0-50.56~20.04.1 amd64 Signed kernel image generic
When need to edit command before use, add :p
:
> !640:p
dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+'
Now it will become the last entered command, so can hit UP
or fc
arrow to edit it.
dpkg --purge
Purging old kernels.Sometimes You can’t sudo apt-get upgrade
anymore it gives some error.
Especially when disk is encrypted, boot
partition tends to be smallish.
So just check df /boot/
:
> df /boot/
Filesystem Type Size Used Avail Use% Mounted on
/dev/nvme0n1p2 ext4 704M 308M 345M 48% /boot
Use%
should be small, found no better explanation than here:
Official doc
What I use from guide:
dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+'
sudo update-initramfs -d -k old-kernel-name
sudo dpkg --purge old-kernel-name
fc
- open last command in editorMaking typos in commands is annoying.
sudo apt-gEt update && sudo apt upgrade && sudo apt autoremove`
sudo: apt-gEt: command not found
Instead of hitting UP
key, and key navigate to typo, fc
would
bring in last command inside VIM, edit, and :wq
.
VIM
- Setting as default editorUsing fc
command makes only when VIM is Your editor.
echo "export EDITOR='vim'" >> ~/.bashrc
- or --
In your bash commands-
- single letter parameters, even when You pass many together.
ls -alt
parameters here will be treated as a
, l
, t
.
--
- named parameters.
apt-get autoremove --purge
- paramter will be treated as purge
VIM
getting through the dayWhy? No need to ever touch mouse, in combination with Tmux
becomes a super power.
Using daily as main code-editor for typescript. Mostly using only basic commands.
Enjoy the pattern: action
+ in or around
+ symbol
.
c
+ i
+ {
- change text in curly braces.y
+ i
+ [
- copy text in rectangular braces.d
+ i
+ (
- delete text in usual braces.v
+ a
+ {
- visually select all around curly braces.(gv
to select same again)And same pattern modified: action
+ on what exactly
.
c
+ 3w
- change 3 wordsd
+ 7l
- change 7 lettersWhole line actions (regardless of curor position in line):
dd
- delete whole linecc
- change whole lineyy
- copy whole lineNavigation inside the text:
gg
- move to top of fileG
- move to bottomNavigation between files(buffers):
ctrl
+ o
go to previous bufferctrl
+ i
got to next bufferGoing into insert mode for code is usually:
Shift
+ o
- above current lineo
- below current lineCopy using system clipboard (from Vim to any other program):
"
+ *
+ ‘y’ - copies visually select text to clipboardAside from basic moves (j
, k
) that is enough to get Me trough the day.
Vim is a rabbit whole in a way. There are multiple to do an operation. Generally
less keystrokes approach should win.
Full configuration includes plugins also.
Would emphasize NerdTREE
as an absolute must have, as it gives project tree view on the left,
with easy file operations context menu.
There are 12 more plugins in my config, they should be doing syntax highlighting, auto completion and fuzzy search. Not really needed to get started.
Official guide covers it all: https://github.com/neovim/neovim/wiki/Building-Neovim
Now need to make it to actually launch neovim
, when You type vim
in terminal
emulator(no rational justification to do it, just type nvim
).
update-alternatives
command comes to help
> sudo update-alternatives --config vim
There are 2 choices for the alternative vim (providing /usr/bin/vim).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/local/bin/nvim 100 auto mode
1 /usr/bin/vim.basic 30 manual mode
2 /usr/local/bin/nvim 100 manual mode
Press <enter> to keep the current choice[*], or type selection number:
Sometimes after pulling latest changes, build breaks, most of the times need
to purge old stuff with sudo make distclean
.
Whereas different terminal emulators might do have different shortcuts to
splitting the screen, or adding a tab, tmux
being an app running inside any
terminal emulator, allows to remember those key-combos once. (no mouse again)
Great cheat sheet found here: https://tmuxcheatsheet.com/
An experience changer -> rebinding ctrl
+ b
to ctrl
+ a
.
My config.
Great supplement to VIM.