cp: cannot create directory Permission denied [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a Folder named "Parser" with in my directory .
I am trying to copy this folder (Parser) from my own directory to my collegues directory under /home/vinay
But i am getting this Exception
cp: cannot create directory `/home/vinay/Parser': Permission denied
These are the commands i executed .
-bash-3.00$ cp -r Parser /home/vinay/
cp: cannot create directory `/home/vinay/Parser': Permission denied

This is because you have no permission to write vinay's home folder.
You can do this either as a root user (if you're in sudoer list), or you can place the file at someplace public (e.g. /tmp) and told vinay to fetch it there.
This is an article about linux file permissions. Hope it helps.

The error message reads Permission denied, which means you - a user - don't have permission to write to vinay - another person - home directory. For more reading

Related

Creating a file inside 0766 directory fails [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Created a directory as root and changed its permissions to 0766:
drwxrw-rw- 2 root root 4096 Aug 2 13:33 test/
When running touch test/test.txt as a user, I get error: touch: cannot touch 'test/test.txt': Permission denied.
$getfacl /test
getfacl: Removing leading '/' from absolute path names
# file: test
# owner: root
# group: root
user::rwx
group::rw-
other::rw-
The directory is set with write permission to all users, what am I missing?
For directories the bits of the access rights have a different meaning than for files:
x means that files inside the directory may be accessed.
r means that you can list the names of the files inside directory. If r is set but x is not set, ls can list the names of the files and sub-directories inside the directory; however, ls cannot show you more information if x is not set; not even if some file it is a regular file or a sub-directory.
w is required to rename or to delete files or to create files or sub-directories inside the directory. However, w has no effect if x is not set!
0766 directory
Because x is not set for group and others, this is the same as a 0744 directory:
Other users may list the names of files and sub-directories inside the directory, but they cannot do more: They cannot even see if some file inside the directory is a regular file or a sub-directory.
You might have an Access Control List (ACL), which permits the access to your folder.
I don't know very much about those lists, but this link should explain them https://www.redhat.com/sysadmin/linux-access-control-lists
You can view the ACL using the getfacl command

How to protect a file under a writable directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am coming across some problem with file permission and acl.
I've got a writable directory name "dir" with the permission 777 (dir rwxrwxrwx)
Under dir I create a file tmp.txt (dir/tmp.txt)
I was wondering how can I stop other/group members to edit/delete the file while not changing the permission of "dir". Everyone is free take any action as they like to the other file/directory under "dir".
I was wondering maybe "setfacl" or what.
Whoever owns the directory can delete the files within it, even if they are owned by root.
There are two ways to get you to almost where you want.
Idea 1 - Sticky Bit
$ ls -ld /tmp
drwxrwxrwt 33 root root 1020 2020-03-14 14:06 /tmp/
This is the common permissions for Unix /tmp directory. That t there at the end of the permissions denotes the sticky bit, you can set it by running:
chmod +t /tmp
The sticky bit says that even though everyone has write permission on the directory, the only ones who can delete a file under that directory are root, the directory owner, and the file's owner.
Idea 2 - Extra Directory
A directory cannot be deleted if it's not empty. If you put your files in a directory that's owned by you, where only you (and root) can delete files, then nobody else can delete it:
root#playground# tree -up
.
`-- [drwxrwxrwx root ] box
|-- [-rw-r--r-- test1 ] f1
`-- [drwxr-xr-x test2 ] hello
`-- [-rw-r--r-- test2 ] f2
2 directories, 2 files
root#playground# su test1
test1#playground$ rm box/hello
rm: cannot remove ‘box/hello’: Is a directory
test1#playground$ rm -rf box/hello/
rm: cannot remove ‘box/hello/f2’: Permission denied

What does the 'x' mean in rwx on a directory? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I got a testdir by mkdir testdir, and created a file in it by touch testdir/a.
drwxr-xr-x 2 jermaine jermaine 4096 Mar 12 22:57 testdir
If I remove the 'x' by chmod -x testdir
Then I won't be able to
cd testdir
touch testdir/b
ls -l testdir
cat testdir/a
So my question is why can't I list the file hierarchy under a directory with a 'r' but without an 'x'? What exactly does the 'x' mean on directory?
I knew some explanations like "x means entering the direcotry, you have to enter before read and write". But what does 'enter' mean? I really appreciate answers on inode or dentry level. Thanks a lot.
"Execute" is the traversal permission on a directory. It allows you to access files and folders within the directory.
If you can read a directory, you can list the contents.
If you can write a directory, you can make new files and folders within it.
If you can "execute" a directory, you can move through the hierarchy, even if you don't know what's inside.
When applying permissions to directories on Linux, the permission bits have different meanings than on regular files.
The write bit allows the affected user to create, rename, or delete files within the directory, and modify the directory's attributes
The read bit allows the affected user to list the files within the directory
The execute bit allows the affected user to enter the directory, and access files and directories inside
Execute permission on a directory means you can access files in that directory.
Check this link out for more information about Unix permissions:
http://www.cyberciti.biz/faq/how-linux-file-permissions-work/

E138: Can't write viminfo file $HOME/.viminfo [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am using opensuse for my production environment.
I am login as "test" user and trying to edit a file using "vi" but when i am going to save
that file it shows the following error
**
E138: Can't write viminfo file /home/test/.viminfo
**
Under the "test" user all the files and folder autometically become read-only.
I am trying to change the permission using "root" user but unable to change it.
also I look for temp file like "~/.viminf*" but there nothing like this.
Don't know what to do plaese help....
anyone aware about this problem
Fix your home directory owner and permissions.
sudo chown -R test /home/test
sudo chmod u+rw -R /home/test
And finally check that no old temp files were left behind (e.g. ~/.viminf*) and that you can write in the directory of the .viminfo file.

read-only files on Ubuntu [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
when trying to delete file, I got the rm command on ubuntu page at https://help.ubuntu.com/community/DeletingFiles. And on, this page I got the term read-only files. I have tried to google read-only file linux, but cannot find any definition about this. Could you tell me what read-only mean? Does it mean all owner, group and other have only read permission? Thank you!
Does it mean all owner, group and other have only read permission?
They may have different permissions. But you (the current user) have only read permission.
Linux has three kind of permission for user, group and others.
r: read permission
w: write permission
x: execute permission
If the file is read-only, it means you (the user) don't have the w permission on it and so you cannot delete the file.
Use:
chmod +w FILE
To add that permission. You can change files permission only if you're the owner of the file.
Otherwise, you can remove the file using sudo, gaining super user privilege.
sudo rm FILE
It will prompt you for a password and it will works only if you're in the /etc/sudoers/ file (and you're likely to be there if you're the only user, since you're using Ubuntu).
A read-only file is a file that you don't have permission to alter its content. To see detailed info about your permissions use ls -l; if you want to change the permissions, use chmod. Also see this example for better understanding.
Change the Permissions with chmod or try with sudu:
sudo rm file.xxx

Resources