0

We have recently taken ownership of a Linux server, on the server is a site creation script which works but seems to be missing the necessary chmod folder permissions (755?).

I think we need to add a chmod line to the following code so that it applies it to the correct 'newly created' folder

My knowledge of Linux is basic so any help would be appreciated.

echo "Please enter the domain name"
read domainname

echo "Please enter a username"
read username

echo "Please enter a password.  This will be the FTP password, and MySQL Database password if used"
read password

echo "Please enter a database name.  If empty, one will not be created"
read databasename

passcrypt=$(perl -e 'print crypt($ARGV[0], "password")' $password)
mkdir /home/$domainname
useradd -g webusers -d /home/$domainname -p $passcrypt $username
chown $username:webusers /home/$domainname

(i have removed some code towards the end as i suspect it may need to be private)

Thanks

1
  • Adding the actual error message might help solving the problem. – Requist Dec 8 '14 at 20:44
0

Since you're making webusers the group owner of the directory, if the user that the webserver runs under is part of that group, you shouldn't need a chown.

For example, the usual user of webserver process on Ubuntu is www-data, and that user is part of the www-data group. By making any directory owned by the www-data group, the webserver would be able to access it using normal group permissions (which are 755 by default).

8
  • I think I understand - the issue is when we try to use those details for FTP - we can get in, we just don't have the correct permissions to upload and download files (espcially via wordpress) – alib0ng0 Dec 8 '14 at 12:26
  • @alib0ng0 What are the permissions of a /home/$domainname folder that gives problems? – muru Dec 8 '14 at 12:31
  • Ok i have uploaded a screenshot from filezilla from a good ftp website and a bad one created with this script [link]tinyurl.com/lfru8xy - it may not be the permissions but rather the owner / group? – alib0ng0 Dec 8 '14 at 13:36
  • @alib0ng0 Looks like your chown isn't working, since the files are owned by root:root. – muru Dec 8 '14 at 13:40
  • Ok that would make sense...i think...any clues how to fix this? – alib0ng0 Dec 8 '14 at 13:42
0

No, it depends on how you want to give security to you files and directories.

By default following permissions are given,

directory 777 file 666

7 means binary 111 which is converted into binary and added to the table of directory information, And it will be translated as

111 111 111

read writ execute / read writ execute / read writ execute
user                        /        group                /              universal

so if you want to give more security then add the chmod otherwise don't need to do anything

The default directory permissions are 777. The default file permissions are 666. Thus, if you have a umask value of 002 (or 0002), you end up with 775 directory permissions and 664 file permissions. The 775 number means "read,write,execute" for the user, "read,write,execute" for the group, and "read,execute" for others. The 664 number means "read,write" for the user, "read,write" for the group, and "read" for others. source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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