Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I want to modify configure.sh to create a file /etc/pam.d/XXX with some predefined content.

How can I do this by putting the file's absolute path and content in configure.sh?

Please explain the syntax.

share|improve this question
up vote 2 down vote accepted

Another way to do this is to use here documents:


cat > /etc/pam.d/XXX << 'EOF'
Place whatever
should go in
the file here

chown root:root /etc/pam.d/XXX  # Or whatever floats your boat
chmod u=r,go= /etc/pam.d/XXX    # Ditto
share|improve this answer

If you already have the content, it would be best to put that in a separate file and just cp or install the file to \etc\pam.d\XXX. That way you avoid any problems related to escaping data within shell scripts. For example, to create a file only readable by root:

install --owner=root --group=root --mode='u=r' my_file /etc/pam.d/XXX

Note that on Unix and Linux systems, paths are always separated by slashes (/), not backslashes.

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.