Some application that installs automatically such as Netbean, JDK often install to /usr/local and I run it by normal user (not root).But another application, just extract tar.gz file and run it. Under normal user, I cannot use cp command to copy from Download directory to /usr/local directory, I must use root user (su command).But because I copy by root user this directory belongs to root, so I cannot run it under normal user. It makes my headache. How can I run it under normal user, as other application that I list above. Or, is there another way to install it?
Install application to /usr/local
linux
There are two potential issues you may be getting tripped up by.First issue - execute permissions for directoriesThe permissions on one of the directories you copied into /usr/local may not have the permissions set correctly. The permissions on the directories needs to be such that users other than root, can execute the programs/scripts out of these directories.The permissions on the directory probably need to be set so that other users are able to execute applications out of this directory.For example# don't have permissions on directoryroot$ cd /usr/local$ ls -ld somedirdrwxr-x--- 2 root root 4096 Apr 25 13:27 somedir# have permissions on the scriptroot$ ls -l somedir/testscript.bash -rwxr-xr-x 1 root root 23 Apr 25 13:27 somedir/testscript.bashIn this scenario even though other users have execute permissions on the script to both read & execute it, they won't be allowed due to the fact they don't have read & execute on the directory the script is in.Changing the permissions on the directory allows them access: user$ ls -ld somedir/ drwxr-xr-x 2 root root 4096 Apr 25 13:27 somedir/ user$ somedir/testscript.bash  hiThis entire issue can be resolved by changing the permissions in the directory being unpacked from the tar.gz file by finding all the directories that have scripts and running the command chmod +rx <dir> against these directories.Second issue - execute permissions for filesThe permissions on the files from the .tar.gz file may not have been set prior, so applications or scripts in the archive would've been unpacked missing these. Simply chmod +x <script> will resolve this issue on files that have this particular problem.### For exampleuser$ ls -ld somedirdrwxr-xr-x 2 root root 4096 Apr 25 13:27 somedir/user$ ls -l somedir/testscript.bash -rw-r--r-- 1 root root 23 Apr 25 13:27 somedir/testscript.bashuser$ somedir/testscript.bashbash: somedir/testscript.bash: Permission denied