Magic Command Line Collection
The command line can be used to do a whole lot of interesting things. Many of them can be done in a variety of ways. Here is a collection of random useful command line commands in no particular order.
Please add to this collection.
Fun commands that don't modify your system[edit]
Some of these require additional packages; if you get an output such as command not found: neofetch
, do sudo apt install neofetch
(or the equivalent) on your distribution.
What are your most used commands?[edit]
history | awk '{print $2}' | sort | uniq -c | sort -nr | head -n 10
Show off your pimped system - With STYLE![edit]
neofetch | lolcat
Like cows?[edit]
echo linuxreviews.org is cool | xcowsay
List the name and contents of files in a directory[edit]
These commands can be useful for browsing files in the Linux /sys/
folder:
fgrep -r '' /sys/devices/system/cpu/vulnerabilities
You can get a identical-looking list using grep -H ''
:
grep -H '' /sys/devices/system/cpu/vulnerabilities/*
You can also get a list of files followed by their contents with awk
:
awk 'FNR==1{print "==>"FILENAME"\n"}1' /sys/devices/system/cpu/vulnerabilities/*
It can also be done by creating a function that prints a filename followed by its contents and running it:
header-cat () { local f; for f in "$@" ; do printf '=== %s ===\n' "$f"; cat "$f"; done; }
header-cat /sys/devices/system/cpu/vulnerabilities/*
Having this function in .bashrc
can be quite handy.
You can get a similar output from the less and possibly least elegant:
for f in /sys/devices/system/cpu/vulnerabilities/*;do echo $f;cat $f;done
Enable comment auto-refresher
Clement12
Permalink |
Anonymous (704c8aec45)
Anonymous (f4d295287a)