Linux permission to move files

Permissions Required to Move File to Different Directory in Unix/Linux

Permissions required to move file to different directory in Unix/Linux

Actually, moving a file is either a rename of a file on a single file system or creating a copy and deleting the original (typically only done if the move is a migration from one file system to another).

In either case you need execute and of course write permissions to the target directory and the source directory. However, for a mere rename (and moving from one directory to another can be just that) on a single file system you do not need any permissions on the file itself. It can be cleared of all permissions and still you can move (rename) it (as long as you have write and execute permissions for the directories).

For a real copy (as it is needed when you move the file to a different file system), you need read permissions on the file itself. No write permissions on the original are necessary, as deletion of a file is not writing to it (but to the directory it is in).

Unable to move file in unix

Sorry silly error from myside.

Previously i have added the owner id to my group so it did not work.
Now i have added my id to owner group and it worked.

why can’t I `mv` a directory without extra write permissions

I think the rename(2) man page has the explanation:

ERRORS 
EACCES Write permission is denied for the directory containing oldpath or newpath, or, search per‐
mission is denied for one of the directories in the path prefix of oldpath or newpath, or
oldpath is a directory and does not allow write permission (needed to update the ..
entry). (See also path_resolution(7).)

So apparently in order to move theirs into mine , you need to have permissions to update the .. link on theirs .

How to move a file out of /usr/local if I get Permission Denied?

Check whether you have write access to the folder with

Then you can try changing the ownership of the folder to your current user.

sudo chown -R your_username /path/to/folder

What permissions are needed to delete a file in unix?

You actually need read , write and execute permissions on the directory, not on the file itself since the operation is done considering the permissions effects of directories.

A good documentation can be found on this link, which mentions the below in the section Special Considerations on Directories:

To delete a file requires both write (to modify the directory itself)
and execute (to stat() the file’s inode) on a directory. Note a user
needs no permissions on a file nor be the file’s owner to delete it!

Change all files and folders permissions of a directory to 644/755

One approach could be using find:

Читайте также:  Примеры файловой системы линукс

for directories

find /desired_location -type d -print0 | xargs -0 chmod 0755

for files

find /desired_location -type f -print0 | xargs -0 chmod 0644

Источник

How can I move a file to another user’s directory?

I’m using CentOS 6 and I’m trying to move a file from USER A to USER B but I keep getting permission denied. What do I need to edit to allow to me to put files from one user’s directory into another’s?

3 Answers 3

You need the rights to read the file from user A, and to write the file to user B’s location.

There are several ways to archive this:

1)
As user A (assumed she can read her own files) get WRITE permission to user B’s location. This means being in a group which is allowed to w to the destination directory and which is allowed to access (x) the directory path to the destination.

cd /home/user/A/ ls -l testfile -rw------- 1 userA users 18 Dec 31 16:31 testfile 

Notice the r. User A is allowed to read her own file

cp testfile /home/userB/testdir 

User A will need to traverse to the folders /home, /home/userB and /home/userB/testdir. All of these need to be ‘x’ for her. She wants to write to the folder ‘testdir’ and thus she also needs ‘w’ on that folder.

That ‘w’ can be in the user, group or other part. But if you set it in ‘other’ then every user can write to it. Thus you usually make shared files or shared folders part of a group. (e.g. in /etc/group create a group ‘sales’ and add both users to that).

2)
As user B: (which is assumed to be able to write in his own folder).
Get read permission on the file in userA’s folder and the right to traverse there. (same as in 1).

You now can copy the file to your own location. You can not delete it from user A’s folder unless you also have the rights to do that. So you can copy but not move.

3)
As a user with uid 0 (usually root, toor, admin):

mv /home/userA/testfile /home/userB/

Notice that the file is still owned by userA, and that user B might not have the rights to work on the file. You can correct this with chown .

4)
Without the heavy guns, as often done by two users:

As UserA: cp testfile /tmp/ As userB: cp /tmp/testfile ~ As userA: rm /tmp/testfile 

This is not the most secure way (other can see the file while it is in /tmp), but I think that this is the most common solution.

If you want to do this often then I strongly suggest creating a group and giving all users in that group rights to a shared location.

Not asked, but a solution like this is often practical (shown with music, but it might as well be sales reports).

vim /etc/group and add a line like this: shared_music:*:3141:userA,UserB,UserC . This will create a group called shared_music, give it a number, and select which users will belong to that group.

Then make folder owned by that group.

cd /usr/local/ md our_ultimate_shared_music_collection chgrp shared_music our_ultimate_shared_music_collection chmod g+rwx our_ultimate_shared_music_collection chmod g+S our_ultimate_shared_music_collection 

Make a folder in a sane location. Set the group and then allow all people in that group to read, write and cd into that folder. The last command (make group setuid) means that newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set-group-ID bit of the parent directory. This prevent userA from writing files to that directory which USerB (or anyone but A) could not deleted or rename.

Читайте также:  Man ps linux это

Источник

Permission denied to move files from a live session [duplicate]

I want to clear space on my computer in order to download drivers for my internet, so I tried moving files to a different location. Unfortunately I don’t have permission to do this. How do I change this? I should point out that I am not logged in; I think I’m a guest or something because if I log in I cannot gain access to the internet to download the drivers that I need, so I’m using the live cd in Try Ubuntu mode to try achieve downloading the drivers.

Do you want to move files from the hard disk with the installed system, or to free up space on your live CD/DVD/USB itself? I think you mean the first. See Recovering user files with a Live CD. (For the second, please edit your question with details.) Your problem is different but the solution is similar and my answer shows how to deal with permissions problems. Remember that if you move files into a nonpersistent live environment, like a live CD/DVD/USB’s desktop, they will be gone when you reboot, so don’t do that.

2 Answers 2

To move files, you can use (1) sudo to execute a command as the root and ()2) mv to move them. You must open a Terminal, for instance, by pressing Ctrl + Alt + T on your keyboard to open Terminal and run the follwing command:

The -f option will force the move. The -i will instruct mv to ask for permission before overwrite some file. Example: sudo mv -f -i /home/user/test /home/user/test1

To copy the files, you can use

Example: sudo cp -i -v /home/user/test /home/user/test1

If you use the Try Ubuntu feature and fire up Terminal, type in the following command:

This will log you in as super user without typing a password. You should see the word root before the prompt. Then you can change directory and you will have permission.

also when i right click the files i want to move, it only comes up «send to» not «move to» what is the problem there? will they both do the same thing and completely move the files from one space to another?

Do this in Terminal. So, after ‘sudo su’, cd into the directory that contains the file that you wish to move, then use the following syntax: ‘mv nameOfFile /location/of/where/you/want/to/move’. Using ‘pwd’ helps you determine your current file directory location. This will make it easier to specify where you want to move your file to. Also, note the space I put between nameOfFile and /location.

ok im having major problems with this, i want to move files in the computer, these files contai then folders: bin, boot, cdrom, dev, etc, home, lib, media, mnt, opt, proc, rofs, root, run, sbin, selinux, srv, sys, tmp, usr, var and 4 files: initrd.img, initrd.img.old, vmlinuz and vmlinuz.old. im not sure if i can move these file cuz they may be the basic files to run ubuntu, im not sure, i just want them moved form the computer to the 110GB hard drive, is this possible?

Читайте также:  Узнать графическую оболочку linux

I do not think it would be possible because when you installed Ubuntu, you installed the bootloader also. Moving those files will not move the bootloader, thus rendering your system unable to boot. I would recommend fresh installing Ubuntu on the 110 GB Hard Drive. After this, you should have plenty of space to install those drivers you mentioned.

Источник

How to move a file in Linux

Whether you’re new to moving files in Linux or experienced, you’ll learn something in this in-depth writeup.

Files in a folder

Moving files in Linux can seem relatively straightforward, but there are more options available than most realize. This article teaches beginners how to move files in the GUI and on the command line, but also explains what’s actually happening under the hood, and addresses command line options that many experience users have rarely explored.

Moving what?

Before delving into moving files, it’s worth taking a closer look at what actually happens when moving file system objects. When a file is created, it is assigned to an inode, which is a fixed point in a file system that’s used for data storage. You can find what inode maps to a file with the ls command:

$ ls --inode example.txt 7344977 example.txt 

When you move a file, you don’t actually move the data from one inode to another, you only assign the file object a new name or file path. In fact, a file retains its permissions when it’s moved, because moving a file doesn’t change or re-create it.

File and directory inodes never imply inheritance and are dictated by the filesystem itself. Inode assignment is sequential based on when the file was created and is entirely independent of how you organize your computer. A file «inside» a directory may have a lower inode number than its parent directory, or a higher one. For example:

$ mkdir foo $ mv example.txt foo $ ls --inode 7476865 foo $ ls --inode foo 7344977 example.txt 

When moving a file from one hard drive to another, however, the inode is very likely to change. This happens because the new data has to be written onto a new filesystem. For this reason, in Linux the act of moving and renaming files is literally the same action. Whether you move a file to another directory or to the same directory with a new name, both actions are performed by the same underlying program.

This article focuses on moving files from one directory to another.

Moving with a mouse

The GUI is a friendly and, to most people, familiar layer of abstraction on top of a complex collection of binary data. It’s also the first and most intuitive way to move files on Linux. If you’re used to the desktop experience, in a generic sense, then you probably already know how to move files around your hard drive. In the GNOME desktop, for instance, the default action when dragging and dropping a file from one window to another is to move the file rather than to copy it, so it’s probably one of the most intuitive actions on the desktop:

Moving a file in GNOME.

The Dolphin file manager in the KDE Plasma desktop defaults to prompting the user for an action. Holding the Shift key while dragging a file forces a move action:

Источник

Оцените статью
Adblock
detector