3 Handy Commandlinefu One Liners
Download the authoritative guide: Data Center Guide: Optimizing Your Data Center Strategy
Download the authoritative guide: Cloud Computing: Using the Cloud for Competitive Advantage
More on Commandlinefu.comCommandlinefu is a simple repository for storing and sharing shell commands with the rest of the world. Here are three new command-line one liners that stand out.
Commandlinefu.com collects your useful command-line one liners and shares them with the rest of the world. I check it out every so often (if you're really dedicated, there are Twitter and RSS feeds), and here are some neat commands I learned recently:
!sudo tee %
If you've opened a file in Vim and forgot that you don't have permission to edit it, you can save it anyway using this command. I regularly encounter this problem, and I wish I'd known about it before. ! indicates to Vim that the rest of the line is to be passed to the shell, and % refers to the current filename. tee writes standard input to the specified file; in this case, the vim w[rite] command is the input, and it pipes the current buffer into tee to be saved.
- Ctrl-x Ctrl-e
Takes what you currently have on the commandline and dumps it into your default editor. To set your default editor, type export EDITOR=vim or add that line to your ~/.bashrc to set it permanently. This is useful for editing long and complex commands or if your terminal is behaving strangely, which I sometimes find happens at the bottom of the screen. When you save and exit the editor, the command will run.
| column -t
Shows your current mountpoints in a nice table. column is a very handy little utility that I hadn't encountered before. It takes input and turns it into, yep, columns. -t formats them as a table. It will try to guess the number of columns, or you can set them with the -c option. This is potentially useful for quick-and-dirty eyeballing of all sorts of data.
Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...