I am presently modifying this shell script to turn it into a shell script for installing Arch Linux, with custom username(s), password(s), etc. At the moment I am wondering what I need to do in order to get this script to prompt users for a value for the FQDN variable (which is essentially the hostname for the Arch Linux machine) and set this variable to whatever value the user types in. If you are unclear as to what I mean take the example of the passwd command and how it prompts users to set the password for the target account, via this sort of prompt:

Enter new UNIX password: 
Retype new UNIX password: 

I would like this shell script to prompt users with:

Enter hostname: 

To set their PC's hostname. Then users enter their desired hostname and it is used as the value for the FQDN variable.

1 Answer 1


In bash, you can use the read function to request input from a user and store it in a variable. You should be careful using this to read in passwords. A good primer on this builtin can be found at http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_08_02.html#sect_08_02_01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .