3 Handy Commandlinefu One Liners
More on Commandlinefu.com
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:
- :w
!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. - mount
| 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).
Page
1 of
1
0 Comments (click to add your comment)
Networking Solutions
