Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to add some line to nano .bash_profile in Terminal. Then:

1) I enter with this command line: nano .bash_profile

2) Add the line I need

3) now I don't know how to Save and Exit

I thought it is :w + enter. If this is correct I need some direction to use it.

share|improve this question
I'm using control+O to save..but it keep asking 'File Name to Write: .bash_profile So how to make sure the 'edited' .bash_profile file is saved? – user23922 Jun 13 '12 at 4:45
Just press 'Enter' then – patrix Jun 13 '12 at 5:27
up vote 20 down vote accepted

No, :w is a /usr/bin/vi command. Use the combination control+x to exit. You will be prompted to save the file if you have made unsaved changes.

Nano is intended to be a bit friendlier / simpler to new users than vi/vim or emacs which both cater to more power users that have spent time learning how to use them effectively.

To get started in nano - look for commands along the bottom of the window when nano is open. (^ stands for the control key)

^X      (F2)            Close the current file buffer / Exit from nano
^O      (F3)            Write the current file to disk
share|improve this answer
Keep in mind the shift key is needed for ^X and ^0 , tripped me up at first when we're used to being given commands in uppercase and the shift key explicitly stated as a shortcut in OSX. – Shwaydogg Apr 13 '15 at 20:30

If you want to save the changes you've made, press Control+ O. To exit nano, type Control+ X. If you ask nano to exit from a modified file, it will ask you if you want to save it. Just press N in case you don't, or Y in case you do. It will then ask you for a filename. Just type it in and press Enter.

If you accidentally confirmed that you want to save the file but you actually don't, you can always cancel by pressing Control+ Cwhen you're prompted for a filename.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.