Tech Blog


Linux Pros’ Top Command Line Secrets

Well it was a relatively quiet week here in the Linux blogosphere, giving residents a long-overdue opportunity to catch their collective breath, enjoy a few Tequila Tux cocktails and take stock of all the FOSS-related happenings that have taken place over the past few weeks.

Among the highlights, for those who missed them, were the awarding of the IEEE Computer Society’s 2014 Computer Pioneer Award to none other than Linus Torvalds; the arrival of Tails OS 1.0; and, perhaps most exciting of all, the release of Seattle-based band netcat’s debut album as a Linux kernel module.

“Are you ever listening to an album, and thinking ‘man, this sounds good, but I wish it crossed from user-space to kernel-space more often!'” netcat wrote on its Facebook page. “We got you covered. Our album is now fully playable as a loadable Linux kernel module.”

Linux Girl thought she had seen it all here in the Linux world, but now she realizes she was wrong. Thank you, netcat, for keeping life interesting!

‘Command Line Secrets’

Linux Girl

Speaking of interesting, there’s nothing like a little shop talk around the bar to pass the time during a quiet week, and last week afforded a dose of that as well. Life is good here in the Linux blogosphere!

The forum was Linux Voice — that shiny, new magazine alert readers may remember launched late last year — and the topic was none other than command line secrets.

Linux Girl couldn’t resist.

‘It Manages to Render Most Web Pages’

“There are loads of really good reasons to use the command line,” wrote the masterminds at Linux Voice. “It’s the most powerful and concise method of interacting with your computer.

“However, we decided to take a moment to look at some of its more obscure (and some would say pointless) uses,” they added.

Top of the magazine’s list is the elinks Web browser: “It might not be as colorful as its more famous rivals, but it manages to render most Web pages,” they explained. “As well has having geek-chic, it can come in handy when you just need to quickly check if a Web page is accessible from a computer you only have SSH access to.”

The list goes on from there to include looking up definitions on Wikipedia, among other tips.

Down at the Broken Windows Lounge, patrons had plenty of suggestions of their own.

‘Great for Maintenance’

“Very nice tips on CL commands, very nice,” enthused Google+ blogger Alessandro Ebersol, for example. “But they forgot cowsay, which is great for having some laughs in the darkness of a terminal.”

The command line “is great for maintenance,” he added. “One can automate with bash scripts and make complex tasks with few (or just one) keystrokes.”

Other command line secrets Ebersol would add to the original list are sl (steam locomotive), along with these nuggets:* % cat “food in cans”cat: can’t open food in cans* % nice man womanNo manual entry for woman.* % [Where is Jimmy Hoffa?Missing ].* % make loveMake: Don’t know how to make love. Stop.* % man: why did you get a divorce?man:: Too many arguments.

‘The Most Precious Gem’

“Command-line secrets? There aren’t any such things,” blogger Robert Pogson told Linux Girl. “Desperate newbie? Type ‘help.’ Still need a hint? Type ‘man whatever.’ Want more diversity? Type ‘ls /bin /sbin /usr/bin /usr/sbin | less,’ pick out a few gems and type ‘man whatever’ all night long. I’ve been at it more than a decade. Still having fun.”

Pogson doesn’t remember how long ago he discovered ‘ssh,’ but “it’s the most precious gem of the FLOSS world,” he said.

“The awesome power of ssh is that the joy you have with typing commands on one computer can allow you a hundred times the joy on 100 computers,” he added. “Of course, it’s not fun to type passwords 100 times, so learn to use secure passwordless logins with ssh to make logging in remotely transparent.”

‘Use It With Respect’

Of course, “just as with any pleasurable activity, one can be addicted to the point of destruction,” Pogson warned. “As root, you can type commands to delete everything or otherwise mess things up.

“This is the nuclear option, and just as world leaders should sit on their hands and think carefully before pushing the button, value this power and use it with respect and higher motivations,” he added.

“I once deleted a file system because my thumb dragged the space bar into a command,” Pogson concluded. “I only did that once. Honest.”

‘Very Powerful’

Google+ blogger Gonzalo Velasco C. was no less enthusiastic.

“Even though the GUI tools are easier, in the *nix universe, the command line remains very powerful,” he told Linux Girl. “Even some power MacOS users use them.”

As for Gonzalo Velasco C. himself, “the only commands I would like to master are the process control and killing, to use with ctrl+alt+backspace, so I can handle the one process that is giving me trouble, and the tar.gz files management — that to this very day remains a pain for me,” he said.

‘Ur Doing It Wrong’

Last but not least, SoylentNews blogger hairyfeet had a different perspective altogether.

“The only thing I would add to a story about CLI is this: If you aren’t working in IT and performing repetitive tasks where having an extremely simplistic, primitive way to script something is useful, and yet you are still using CLI, then ‘ur doing it wrong,'” hairyfeet told Linux Girl. “A CLI isn’t magic — it’s a GUI from the 1970s!”

Today there are “useful GUIs thanks to actually having more CPU and RAM than a dollar-store watch — we even have IDEs and scripting languages that can run rings around that 70s throwback, work across the WAN or LAN and interact with the deepest levels of the OS, all while being easier to use thanks to technologies like intellisense and autocomplete,” he explained. “So why in God’s name, if you aren’t one of the 3 percent who are administering systems where every single byte counts, would you be dragging that old pile of junk out of mothballs?”

Hairyfeet’s best CLI advice? “Don’t — join the rest of the planet in the 21st century and learn how to use real languages and tools,” he concluded. “Let CLI join bubble memory and floppies on the dustbin of history.”

Katherine Noyes is always on duty in her role as Linux Girl, whose cape she has worn since 2007. A mild-mannered journalist by day, she spends her evenings haunting the seedy bars and watering holes of the Linux blogosphere in search of the latest gossip. You can also find her on Twitter and Google+.


  • For me, my use of Linux based Operating Systems has been to slowly include elements of the CLI into my computer use.

    When I first started using Linux I was moving from the Windows world, where I was a very advanced user, having worked with Windows Servers as an administrator. I used GUIs to administer my Mandrake Linux desktop exclusively. Over time I began to incorporate CLI commands into my use of the Mandrake, and then Mandriva systems, as I discovered that some things could actually be done better with the CLI.

    It wasn’t, however until I began using Ubuntu, then later Linux Mint (I’m actually back with Ubuntu, but that’s another story), that I started using the CLI to get more and more things done.

    So from my point of view, while there are more than adequate GUI tools, which from the point of view of a Windows Administrator I found quite serviceable, and have always been so, at least since 2000, and at least in Mandrake Linux, I find the CLI gets me there quicker and often more concisely.

    So while the CLI may well be a tool from the 1970s, and I used plenty of those on DECs and Data Generals back in the day, all I can say is thanks guys, you designed it well.

  • CLI has it’s place.

    If you take the time to learn it, scripting can be more efficient than using a GUI.

    The GUI have certainly made using a computer much easier for the common user, who generally does one thing at a time, be it edit a spreadsheet or a document, or browse emails or the web. The use of common apis to provide a consistent experience across the environment is certainly better than learning how to use each application seperately (i.e Wordperfect 5,dbase 4, lotus 123) like in the later eighties/early nineties.

    However you need to be an idiot to think there is nothing you can do on a CLI that you cannot do on a GUI. GUIs are for one, just not generally built with bulk workflows in mind. (Musicbrainz)Picard can process a directory (or nest of directories), but not several directories from different locations and if you try your whole collection, it probably crash.

    As for ‘UI from the 70’s’, I don’t think there was much of a GUI in common use until the Mac or GEM and such, and at the time they weren’t widespread.

    Using the CLI for e-mail/webrowsing or video however is akin to a minimalist lifestyle choice akin to camping out in a yurt and growing your own veggies and milking your own goats.

    It is fun though increasingly hard to achieve.

    Both CLI and GUI have their shortfalls, and neither is completely satisfying as an interactive method. Gestures and touch are only incremental steps and not the big revolution they are being sold on. What does that leave? AI? Then the computers will be doing the thinking for us, Or cerebal links, and then we become the computers.

    • hairyfeet, raising a strawman, wrote, "anything you can do with a CLI can be done better with a GUI"

      That could be true but the creator’s of the GUI cannot anticipate every use a user will make of any software. The best they can do is automate the most common operations. In the real world, every user of software will encounter some awkwardness in a GUI. With CLI, combining elements of a language allows the user to express his need more or less precisely.

      e.g. facial recognition (hairyfeet’s point). Suppose I had a file-system full of pictures and wanted to find as many as I could with some face included. A GUI could be written to do that, no doubt but there have to be some assumptions about files to scan and what to do with the result-set. Suppose the user doesn’t want to display those pictures or put them into some display or report but run another application to apply moustaches, or to add zits for instance and leave the results in a server out there somewhere? That’s not likely to be in a mainstream application but is no problem at all from the CLI. This is not about system administration but human creativity.


      for f in `find somedir -regextype ‘grep’ -iregex ‘.*jpe*g’`;do paintstache $f someotherdir;done;scp -r someotherdir myserver:/home/pogson/

      Now, I can’t tell you how useful that is but neither can the programmer of the GUI, but it will work pretty sharply for the user with this inclination. Change the manipulation of the images to anything you want. How many thousands of clicks on a GUI will that save?

  • Hairyfeet wrote, "A CLI isn’t magic — it’s a GUI from the 1970s!"

    I was there, doing that, in the 1970s. We had GUIs for doing certain things and CLIs for doing other things. Want to choose from "A" or "B" or "C"? Use a GUI. Want to choose the 873rd item from a list of 1K things? Use a CLI. Want to do this, that and the other to a list of 1K things, use CLI.

    CLI is great for doing a lot of the ordinary things ordinary people do. For x86, I started on DOS and later that other OS with its GUI. That GUI was a great improvment over DOS but that was only because DOS was crippleware as CLI.

    I will never forget the first time I became a computer teacher. The previous guy spent hours entering students into the system one user at a time with lots of clicks of a mouse… The first big system I set up with GNU/Linux, I added 700 users in about 15 minutes with a simple script generating and publishing passwords for all of them. Each user had his own website and shared folder, too… Chuckle.

    Now, I know these examples are for system admins, but ordinary users have thousands of images, documents and folders to manage. That’s a lot easier with CLI than a GUI. The thing is CLI is a language which can express anything whereas a GUI is a rather short alphabet designed by a programmer. If anything comes along not envisioned by the programmer, the GUI stops being useful right there, whereas the CLI adds another expression or stanza according to the user’s needs.

    An example: The Little Woman loves parties. She will take ~50 images on her smartphone and she never clears her smartphone’s storage, so they accumulate to thousands. One way or another she gets them to the PC. She has so many folders that she can’t scroll around easily to find them, let alone do operations on the contents. That’s a limitation of the GUI. With CLI, she can select all images taken on a certain date, no matter where they may be found on the hard drive, rename them, resize them, rotate them, brighten them, whatever, as easily as one image could be processed with a GUI. So, if she left all images in a folder named for a date, she could get by with the GUI, but she moves them around her way, putting some of them in so-and-so’s folder, or collecting others for a presentation. With the GUI, she’s tied to hunting them down one by one and click-click-clicking on stuff. With the CLI, one command does it all. Of course, she could put all images in a relational database, but that’s an app, not the basic tools of the OS. She can also run a relational database from CLI and there are some operations better done from CLI for databases too.

    Definitely, a GUI has advantages in being easier to learn but it’s also more limiting for any user.

    Another example: Consider word-processing where one is always editing and revising. Everyone recognizes that search and replace is a basic tool every word-processor should have. Everyone values a GUI for word-processing. Now, how do the GUIs change every occurrence of "XP" to "XP and 2003" without messing up mispellings and other typos? They use CLI methods, like "regular expressions". Otherwise they botch "xP", "expert", and "X P" or they have the user say "yes or no" to every occurrence. Don’t laugh. I saw it in a document found on the web last week. The guy decided to make the change didn’t catch all the glitches… So, even a GUI that’s well-designed will admit easy access to CLI methods or fail miserably one way or another. That’s because there’s no better way to do some things than via CLI.

    • You gonna do facial recognition with a CLI? I’d like to see that because the GUI picture managers have had that for a few years now. Word processing? Nobody cares because you can keep whichever one you are comfortable with. office 2K? runs in Win 8.1, you see that is what happens when you have backwards compatibility and stable ABIs, you don’t HAVE to change programs because some dev gets a bee in his butt to change everything. BTW good look if you want to keep ALSA, KDE 2, or init over systemd because if you don’t like the "new stuff"? tough.

      Sorry pogson but anything you can do with a CLI can be done better with a GUI, the ONLY exception to this rule is system administration and even there the GUI does everything just as well, it just isn’t as scriptable. A CLI is NON intuitive, NON discoverable, its a throwback to the age of bellbottoms. Linux refuses to get with the 21st century and where has it gotten? Mozilla adding DRM, MSFT can put out double flops and still get more users in a week than Linux has in 20 years, hell the only "positive" you could claim was Android and now google is turning that into another TiVo (look up the Ars article on Android going proprietary).

      Lets face it, the masses have made it clear that they don’t want to play your reindeer games, if you want to stay at 1%? Hope you can find some hardware that will actually run FOSS once the PCs are replaced with tablets, all running GUI only BTW.

  • I disagree with Hairyfeet

    Yes ofc the terminal is a sysadmins best pal, tho there’s so much moar to it than system administration. Using a terminal to watch/search/download any youtube video or audio, watch local tv, watch/search/download live streams. (mutt) for email, media player, package management on any linux system, text editor,SSH,ping,find,netstat,figlet 🙂 to name a few from my zsh history.

    A terminal lets me do these tasks with minimal effort (tho i cheat & use zsh aliases) it is faster, moar fluid than any GUI equivalent, which in turn benefits my workflow

    so my message to any budding linux user/s is, do not shy away from the terminal, it’s so much fun and it opens up a whole new world of possibiltys, many which cannot be accomplished using a GUI.


Leave a Comment

Please sign in to post or reply to a comment. New users create a free account.

E-Commerce Times Channels