should I use the text editor? the extension should be .sh or .bat?

marked as duplicate by Sergiy Kolodyazhnyy, Videonauth, edwinksl, Eliah Kagan, muru Nov 3 '17 at 7:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Your question is more likely to receive useful answers if it contains some specifics. Such as what type of data is to be processed, including realistic examples of input and output. – J. Starnes Nov 3 '17 at 0:54
  • @SergiyKolodyazhnyy The duplicate nominee is closed as too broad. As such the close vote on this one should be "too broad" as well. That said it seems like a reasonable question to me as I was once in the dark myself :) – WinEunuuchs2Unix Nov 3 '17 at 1:13
  • @WinEunuuchs2Unix It is closed but does have an accepted answer, which will give OP what they want, or at least a starting point. – Sergiy Kolodyazhnyy Nov 3 '17 at 1:30
  • @EliahKagan If a mod agrees perhaps he can reopen that one and then merge the answers from here to there? – WinEunuuchs2Unix Nov 3 '17 at 10:56
  • @WinEunuuchs2Unix That question, which this received close votes to be duped to, was actually reopened a few hours ago, then closed again as duplicate of that highly voted question. Both of them are listed as "originals" in the duplicate banner here (i.e., this question is duped to both of them). So if answers are to be merged, they'd probably be put there. Do you think that would be useful? – Eliah Kagan Nov 3 '17 at 11:04

To create one use the .sh extension but it doesn't really matter but it helps future users to quickly determine which file type it is. The bat name is mostly used on Windows but in Linux file name extensions do not really matter. Meaning I can call my file say run.de and it would still run in bash file but I believe it's a good practice to name them with the .sh file extension.

For the editor, part uses any that is best for you between nano vim gedit emacs, but I believe gedit would be nice to start with.

How to:

using gedit text editor:

  1. Create the file:

    gedit runme.sh
  2. Add code into file:

    echo "Hello World!"
  3. Make file executable:

    chmod +x runme.sh
  4. Run the file from terminal:


In linux they are bash scripts. You can use most any editor and you can call it what you wish, Linux does not use extensions such as .sh or .bat or .exe to .doc to identify files, it uses magic.

Probably gedit for a graphical editor and nano from the command line.

Avoid word processors such as libre office as they add headers you don't want.


To write a bash script , start the file with a "SheBang" or #!/bin/bash


# comments start with a '#"

command 1
command 2

Tons of tutorials on the web - https://linuxconfig.org/bash-scripting-tutorial


Batch file equivalent in linux is shell script (.sh). You can use gedit, vim or any other text editor available to create one.

A good start for begginers is http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html.

Hope this helps :)

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