Hi folks,
I recently joined the community call on the Discord server of the Growin Community. We had a Linux session where we learned some handy tricks with Linux.
If you donβt own a Linux machine, donβt worry! You can use:
- Killer Koda β Just choose Ubuntu from here.
- copy.sh
Alright, you're all set to get your hands on the terminal.
3, 2, 1, Go! π«π
LINUX Tricks
-
To execute a previous command:
-
historyβ prints the history of commands. -
!<cmd_no>β executes a command from history based on its number.
-
-
To copy and paste lines in
vim:-
Esc + 10yyβ copies 10 lines. - Paste with
pto insert after the cursor.
-
-
To perform a reverse search:
-
Ctrl+Rβ reverse search through the command history.
-
-
To count lines in a file:
-
wc -l aks.txtβ counts and lists the number of lines.
-
-
Yanking (copying) in
vim:-
yyβ yanks (copies) the current line. -
Esc + 5yyβ yanks (copies) 5 lines. - Paste with
pafter yanking.
-
-
Navigating in
vim:-
Esc + :1β jumps to line 1. -
:set nuβ enables line numbers. -
Esc + Shift+Gβ moves to the end of the document.
-
-
Deleting in
vim:-
Esc + dGβ deletes everything from the current line to the end of the document. -
Esc + uβ undoes the last change.
-
-
Finding unique adjacent lines in a file:
-
uniq -cβ looks for unique adjacent lines.
-
-
Sorting, unique filtering, and counting occurrences:
-
cat aks.txt | sort | uniq -cβ lists all unique lines inaks.txtwith their counts after sorting.
-
That's it! Youβve learned a lot from this article. Do like it and share any comments you have. Donβt shy away!
See you next time!
Top comments (2)
π€£ I usually do a Esc then :wq Enter