Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

Lets say I wanted to create a .txt file that had some commands in it. Then from .txt file the contents are extracted to the terminal. Is this even possible and does it have to be a .txt file? oh and I am running 12.04

share|improve this question
up vote 2 down vote accepted

it can be done. Just cd to the directory of the file in the terminal and type chmod +x commands.txt, and then ./commands.txt runs commands in the file

No, it need not be .txt, extension doesn't matter

share|improve this answer
Simple enough thank you. – TerNovi May 30 '12 at 3:58

You can also put one command per line in the text file (e.g. my_commands.txt), and then run them all as:

source my_commands.txt
share|improve this answer
This is new for me. Thanks – Anwar Shah May 30 '12 at 6:31

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.