What's Your 20 Most Used Commands As normal user and root?
GeneralThis forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have an irrational dislike for long pipelines of commands that can be shortened with liberal use of "awk". Yes, I know it's ridiculous when taken to extremes. But I think learning just a little "awk" is well worth it to avoid running 6+ processes in a pipeline, possible with multiple "awk" calls, when 2 might work with a just a little more code added.
So here's a rework of that commandline that's just "history" and one "awk" for your amusement.
Code:
history | awk '{CMD[$2]++;count++;} END { spot=1; for (a in CMD) { apc=CMD[a]/count*100; if(apc>TOP[spot]) { TOP[spot]=apc; DESC[spot]=sprintf("%5d %5.2f%% %s", CMD[a], apc, a); for(ii=20;ii>=1;ii--) if(TOP[ii] < TOP[spot]) spot=ii } } for(ii=1; ii<=20; ii++) { spot=1; for(jj=1; jj<=20; jj++) if(TOP[jj]>TOP[spot]) spot=jj; printf "%2d %s\n", ii, DESC[spot]; TOP[spot]=0 } }'
I'm not saying is the right way to do it, but I do think the original was pretty awful.
And as long as I'm posting, here's what I got on my Ubuntu desktop.
And yes, "." a command a use regularly to update environment variables in my shell.
Also, no idea why the original commandline was filtering out anything that started with "./". That seems odd to me. Yes, those are probably local scripts, but it's still interesting IMO.
I cut the " | head -n20" off of that to find out how many commands it requires to fulfill 100% of my commands. Well ... I didn't add it up to validate that it was 100%, but the list ran out to 57 total commands.
Interesting, and "whatever". I figured that ls, cd, cat, vi, tar, and man would be some of my tops. Just didn't think that sudo and echo would also be there.
Glad to see that exit was up there though! Means I properly quit my terminal sessions, heh-heh!
Heh-heh! Had a few, but I knew what they were. It's a testament to how long my system has been running? Untrue because I rebooted yesterday as a matter of fact, so that's full of water. Either case, I know I haven't run some build scripts in years, but they showed up and in my top 20.
Person shows up and asks for your root and user top 10 bash commands?
No way. No how.
Code:
1 666 6.95253% nacho
2 666 6.95253% nunya
Meh. I looked at what kind of information was being given out, and it isn't a big deal. cd and ls are of course the big top two commands for just about everyone so far, and since any real information is stripped except for the command itself, self-identifying information is not there. Oooh... you know that I use emacs rather than vi... big whoop.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.