Ctrl + X will quit the editor and you will be asked if you want to save your changes. If you do, press Y for Yes
.
Ctrl + O should also work, since that means to save the file, but you won't be asked "Save modifier buffer ? " because you already told nano
to save.
I may have misunderstood your question. SHH doesn't exist, do you mean SH or SSH? Or maybe Bash? (EDIT: brought an edit to fix this)
Anyway, nano
won't be much of assistance here. echo
will.
echo "ServerName localhost" > /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
The above shell code will send your text into the file. Replacing >
with >>
will append it instead, if that's what you're looking for.
If you need root privileges to write to this file, then use tee
instead of a simple shell redirection (>
/>>
). This will allow you to use sudo
properly:
echo -e "ServerName localhost" | sudo tee -a /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
nano
is here so that you, the user, can write data manually into a file. However, if you're looking for an automated process, there's no need for an editor, coreutils can handle that just fine. Linux doesn't need the fancy nano
interface to write into a file.
Best Answer
Yes you could save it temporarily to your home directory. Press Ctrl+O to change the path to your home directory or in /tmp and then press Enter to save it. Then you can
sudo mv
it.Press CTRL+O will show you the path. Change that to your home directory or /tmp. For example File Name to Write: /tmp/filename and press Enter.