Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

2 Answers 2

up vote 2 down vote accepted

Another way to do this is to use here documents:

#!/bin/sh

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

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
add comment

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
add comment

Your Answer

 
discard

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.