PEN-200
(I hopped on a few minutes late, unfortunately…)
I always forget that redirects work both ways:
# Redirect dmesg to an external file.
#
dmesg > boot.log
# Push boot.log into cat, and output with line numbers.
#
cat -n < boot.log
This, incidentally, makes the “heredoc” syntax a little more explicable - it’s basically “appending” text to the <
redirect.
# "Heredoc", which I always forget about.
#
cat -n << EOF
Line A
Line B
Line C
EOF
# Also, redirect "heredoc" into a file.
#
cat << EOF > file.txt
Line A
Line B
Line C
EOF
Handy shortcut to clear the current terminal screen: CTRL+K
.
CTRL+SHIFT+D
will (horizontally) split the default terminal in Kali Linux; CTRL+SHIFT+R
will split the default terminal vertically. Use CTRL+SHIFT+E
to close a pane. That said, the separation between the created panes is much less clear than with Tmux.
Handy command: watch
will periodically run a program (specify the interval with -n
) and display the output in the terminal.
The extended regexp function with grep
(-E
) does not require the use of parentheses if you’re looking for a single “or” (for example, grep -E "kali|root" /etc/passwd
).
Another trick: cut
supports negative numbers to count fields from the right, rather than the left.