By default, Apache on Ubuntu runs as www-data.
Let's assume your folder is located in /var/www/mysite.
You can do this:
chown -R www-data:www-data /var/www/mysite
chmod -R og-r /var/www/mysite
After doing this, www-data (the Web server) will have full access to the site's files, while other non-root users will have no access at all.
If you wish to allow select users to access the site, you can make the folder group-readable and add those users to the group www-data.
I'm going to address two parts of your question: java installation and folder creation.
Java installation
We already have a question about that: How can I install Sun/Oracle's proprietary Java JDK 6/7/8 or JRE?.All of the necessary commands are there, and I strongly suggest you read their manual pages with man COMMAND
in terminal.
There's also open-source version of Java, Open JDK. Installation of that is somewhat simpler
sudo apt-get install openjdk-7-jre openjdk-7-jdk icedtea-7-plugin
That's pretty much it - apt-get will take care of everything. When you install some package with apt-get
or dpkg
there should be preinstall and postinstall scripts that come along with the package, and run automatically to set up whatever program you're getting.
Folder Creation
Folder ( in linux terminology - directory ) creation, just like file creation, depends on the permissions. If a folder has the following permissions,
drwxr-xr-x 15 testuser testuser 4096 Nov 22 12:34 testuser/
that means the owner of that folder testuser
can read-write-execute stuff there (first rwx
), and group testuser
can only read and execute stuff there - that's the r-x
part, and final r-x
part means read execute for any other groups or users.
/usr
folder is owned by root user, so only root can write there, that means create files or folder. Hence for that you need sudo
to gain root privileges temporarily.
Best Answer
stat -c %a FILE_OR_FOLDER_PATH
e.g.
stat -c %a /etc
shows755