Saving commands to a file using Ctrl-x-e
One very interesting trick that you may not know is that you can type a line of text (presumably a command) on the Linux command line and immediately save it to a file by pressing just three keys. The editor that will open up will depend on your $EDITOR setting that you can view using the command shown below:
$ echo $EDITOR nano
If you prefer to use a different editor, use a command like this before typing or moving back to the command that you want to save:
$ export EDITOR=vi
And don't forget to save this change to your .bashrc (or other start-up file) if you want to make this change permanent. For example: