LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   permission denied (https://www.linuxquestions.org/questions/linux-newbie-8/permission-denied-4175432772/)

Whatif 10-17-2012 06:06 PM

permission denied
 
Hello,

I'm trying to move the tomcat docs tar I downloaded but keep getting the following error:

mv apache-tomcat-7.0.32-fulldocs.tar.gz /software

mv: cannot create regular file '/software/apache-tomcat-7.0.32-fulldocs.tar.gz' : permission denied.

What can I do?

Thanks in advance,
Mike

chrism01 10-17-2012 06:08 PM

Well, as it says, you don't have permission.
You need to check the ownerships and perms of that dir and compare to your current user.

GlennsPref 10-17-2012 06:27 PM

Hi, when you do this,
Quote:

mv apache-tomcat-7.0.32-fulldocs.tar.gz /software
you use an absolute address, that is copy/move to /software

You might try to put it in the /home/$USER/software by leaving out the /
(relative addressing, from where you are, like /home/$USER/)

type this,
Code:

mv apache-tomcat-7.0.32-fulldocs.tar.gz software
or
mv apache-tomcat-7.0.32-fulldocs.tar.gz ~/software

Most times a $USER may not write to any file/directory folder outside of /home/$USER/

Regards, Glenn

frankbell 10-17-2012 09:05 PM

This command will tell you the permissions of the tarball:

Code:

ls -l apache-tomcat-7.0.32-fulldocs.tar.gz
This command

Code:

ls -l /software
will tell you the permission on the software directory (You should use the full path to the directory).

This will give you a good introduction to permissions: http://www.slackbook.org/html/book.h...RE-PERMISSIONS

shivaa 10-17-2012 10:12 PM

First of all make sure that /software directory exists. If it exists, then check permission and ownnership of both tar file as well as /software dir. as follow:
Quote:

ls -l apache-tomcat-7.0.32-fulldocs.tar.gz
ls -ld /software



If any one of them is owned by root or any other user or if do not have "write" permission for group and others, then it will not permit you to do so.
So switch to "root" user and invoke the mv command, and also use absolute paths, not relative paths. It will sure work.
Code:

# mv ./apache-tomcat-7.0.32-fulldocs.tar.gz /software/

Whatif 10-18-2012 09:11 AM

I logged in as root and the mv command worked. The output from the ls -l command for the /software is

drwx------ 2 root root 16384 Oct 16 16:58 lost+found/

and for the file I was tring to move is

-rw-r--r-- 1 mike mike 4906088 Oct 17 12:15 apache-tomcat-7.0.32-fulldocs.tar.gz

Is the problem with the /software since it doesn't have world write permission?

/software is the mount point for /dev/sda5 and I used the mount /dev/sda5 /software command to mount it since it's not in the /etc/fstab

I'm searching online to find out how to modify the /etc/fstab file but if the problem with the /software, can I modify the permissions with the mount command?

Thank you,
Mike

User\ Name=`echo $USER` 10-18-2012 11:33 AM

If I understand the problem you're having correctly, have you tried

Code:

sudo chmod 664 (filename)
?

mandyapenguin 10-18-2012 12:04 PM

Quote:

mv apache-tomcat-7.0.32-fulldocs.tar.gz /software

mv: cannot create regular file '/software/apache-tomcat-7.0.32-fulldocs.tar.gz' : permission denied.

What can I do?

Thanks in advance,
You can set permissions to particular user using Access Control List., Just see the below examples
Code:

# ls -ld /software/
drwxr-xr-x 2 root root 4096 Oct 18 22:08 /software/

As you can see user has full permission(rwx) to /software folder, group and others having only read and excecute permission

Code:

# getfacl /software/
getfacl: Removing leading '/' from absolute path names
# file: software/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

Just try to create file as "Whatif" user
Code:

# su Whatif
$ cd /software/
$ touch Whatif
touch: cannot touch `Whatif': Permission denied

$ exit
exit

Give full permission to only "Whatif" user to /software folder.
Code:

# setfacl -R -m u:Whatif:rwx /software/

# echo $?
0

# getfacl /software/
getfacl: Removing leading '/' from absolute path names
# file: software/
# owner: root
# group: root
user::rwx
user:Whatif:rwx
group::r-x
mask::rwx
other::r-x

# su Whatif
$ cd /software/
$ touch Whatif
$ ls -ltrh
total 0
-rw-rw-r-- 1 Whatif Whatif 0 Oct 18 22:09 Whatif


shivaa 10-18-2012 01:56 PM

Quote:

Originally Posted by Whatif (Post 4809115)
I logged in as root and the mv command worked. The output from the ls -l command for the /software is

drwx------ 2 root root 16384 Oct 16 16:58 lost+found/

and for the file I was tring to move is

-rw-r--r-- 1 mike mike 4906088 Oct 17 12:15 apache-tomcat-7.0.32-fulldocs.tar.gz

Is the problem with the /software since it doesn't have world write permission?

/software is the mount point for /dev/sda5 and I used the mount /dev/sda5 /software command to mount it since it's not in the /etc/fstab

I'm searching online to find out how to modify the /etc/fstab file but if the problem with the /software, can I modify the permissions with the mount command?

Thank you,
Mike

Mike, there's nothing tricky in your problem. It was simply because you were trying to move something in a directory which was write protected.
Well, there are following ways now:
First way# Add write permissions for /software directory for group and other, so you will be able to move anything from/to it, as follow:
# su - root
Enter root password:

(I assume that you know the root password, else use command # sudo su - root)
# chmod 777 /software

Second way# You can change ownership and group of the directory, so it will then allow you, as follow (again do it as root only):
# chown mike:mike /software
# ls -ld /software
drwxrwxrwx 2 root root 16384 Oct 16 16:58 /software
(Output would be something like this, though you've mentioned wrong output of lost+fond file instead of /software in your last comment. So take a note that always use ls -ld not just ls -l, as ls -l will give you content inside the dir.)

Third way# Instead of changing permissions or ownership, just change group of the /software dir. and add yourself in that group and then add "write" permission for group on it, as follow:
# chgrp mike /software (Or you can specify any other group in place of mike)
# chmod 770 /software


All times are GMT -5. The time now is 12:52 AM.