How Do I Save a Bash Script in Linux?
Contents

To Save and quit press Shift + Z + Z , :wq , or in command mode. If you are opening the file in read only mode you will have to hit :q! .

How do I save a script in Linux terminal?

To save a file, you must first be in Command mode. Press Esc to enter Command mode, and then type :wq to write and quit the file.
…
More Linux resources.

Command Purpose
i Switch to Insert mode.
Esc Switch to Command mode.
:w Save and continue editing.
:wq or ZZ Save and quit/exit vi.

How do I store a bash script?

Follow below PATH to achieve this:

  1. Create a folder using mkdir $HOME/bin.
  2. Then put your script in $HOME/bin.
  3. Finally, add the following line under $HOME/. bashrc by editing with gedit $HOME/. bashrc.
Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest