commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
brings up all your history for modification or get rid of the history on linux files
These series of commands allows you all at once to make a backup of your current config, edit that config, then saves it as the running config and makes it persistent. I would advise knowing what your doing to the config before running this because if you mess up say the port 22 portion, you may get knocked off the system. ;) Don't say I didn't warn ya!
If you are running sshd on different port use above this command to edit/view remote file with vi/vim.
In above example I am using port 12345.
Deletes lines from START to END, inclusive. For example +4,10d will delete line 4, 5, ..., 10. Just like the vi command :4,10d does it.
Deletes lines to of a file. You must put the end line first in the range for the curly brace expansion, otherwise it will not work properly.
For example, to remove line 5 from foo, type: vi +5d +wq foo
This is not printing, real editing using the text editor.
1. Get name of task by task=$(basename "$(pwd)")
2. Check whether "$task.c" exists as a file
3. open "$task.c", "$task.in", "task.out" in vim with such layout.
| | $task.in |
| | |
| | $task.out |
| | |
eh stands for Edit History
Frequently, I'll mistype a command, and then step back through my history and correct the command. As a result, both the correct and incorrect commands are in my history file. I wanted a simple way to remove the incorrect command so I don't run it by mistake.
When running this function, first the ~/bash_history file is updated, then you edit the file in vi, and then the saved history file is loaded back into memory for current usage.
while in vi, remember that `Shift-G` sends you to the bottom of the file, and `dd` removes a line.
this command is different than bash built-in `fc` because it does not run the command after editing.
Open up vi or vim at the first instance of a pattern in [file]. Useful if you know where you want to be, like "PermitRootLogin" in sshd_config. Also, vi +10 [file] will open up a file at line 10. VERY useful when you get "error at line 10" type of output.
this lets you edit a crontab file (which may be used as a backup as well) and insert this into your crontab. this way is especially handy, when multiple users are working on one account (e.g. root)
say you've just found all the config files with this command
find . -name '*.config'
and you need to edit them all
will re-execute the command and present them to vi in the argument list
don't use if the list is really long as it may overflow the command buffer
That will open vi with the four README files in different viewports.
Specially handy when you find there is only one file matching your pattern and you don't want to specify the full path.
the middle command between the ; and ; is the vi commands that insert that line into the last line of the file, the esc with the carets is literally hitting the escape key, you have to have the smbfs package installed to do it, I use it to access my iTunes music on my mac from my linux PC's with amarok so I can play the music anywhere in the house. among other things, it allows you to access the files on that share from your computer anytime you're on that network.
The -R flag prevents you from making changes to a file, useful when you only want to view the file. This command is nicer than the 'more' or 'less' commands because for source codes, vi shows syntax highlight.