Magic Command Line Collection

From LinuxReviews
Jump to navigationJump to search
Konsole.svg

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


avatar

Clement12

21 months ago
Score 0++
Hello everyone i want to testify on how I joined the illuminati kingdom and my life change totally WHATSAPP +1(657) 325 0548 i become rich and famous. I was trying to join this society for so many years I was scammed before I was down i could not feed my self and my family anymore and I tried to make money by all means but all in vain, I was afraid to contact any illuminati agent because i was scam before . finally a friend of mine WHATSAPP call/text +1(657) 325 0548 introduce me to the right way to join illuminati. I was initiated, surprisingly I was given an instant benefit money of $80,000,000.00 as a new member of the great illuminati kingdom WHATSAPP call/text +1(657) 325 0548 I was very happy, for those of you trying to join this illuminati society this is your opportunity for you to join. $80,000,000 Contact the illuminati. Hello everyone i want to testify on how I joined the illuminati kingdom and my life change totally WHATSAPP +1(657) 325 0548 i become rich and famous. I was trying to join this society for so many years I was scammed before I was down i could not feed my self and my family anymore and I tried to make money by all means but all in vain, I was afraid to contact any illuminati agent because i was scam before . finally a friend of mine WHATSAPP call/text +1(657) 325 0548 introduce me to the right way to join illuminati. I was initiated, surprisingly I was given an instant benefit money of $80,000,000.00 as a new member of the great illuminati kingdom WHATSAPP call/text +1(657) 325 0548 I was very happy, for those of you trying to join this illuminati society this is your opportunity for you to join. $80,000,000 Contact the illuminati.
avatar

Anonymous (704c8aec45)

11 months ago
Score 0
Take care of your mental health and make sure you get the sleep you desperately need. Bitch.
avatar

Anonymous (f4d295287a)

4 minutes ago
Score 0
Thinking of joining the scummy perpetrators of all harm & suffering in this world is a VERY bad idea.
Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.