LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 08-29-2013, 05:25 PM   #1
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Rep: Reputation: Disabled
Cannot delete copies of system files


I accidently copied some system directories (boot, sys, etc) to my home directory (did you like how "etc" both means the etc directory and etcetera there?) and I also changed them all so that they are owned by me rather than root.

I can't seem to delete them no matter what I try. rm doesn't work (with or without sudo mode) and neither does chown.

Here's an example of some files I can't delete:
Code:
[wonna@wearcontinue-dl boot]$ ls -l
total 24612
-rwxrwxrwx 1 wonna users   115179 Aug 29 09:17 config-3.3.4-5.fc17.x86_64
drwxrwsrwx 2 wonna users     4096 Aug 29 15:07 extlinux
drwxrwsrwx 2 wonna users     4096 Aug 29 15:07 grub
drwxrwsrwx 2 wonna users     4096 Aug 29 15:07 grub2
-rwxrwxrwx 1 wonna users 17921070 Aug 29 09:17 initramfs-3.3.4-5.fc17.x86_64.img
drwxrwsrwx 2 wonna users     4096 Aug 29 09:17 lost+found
-rwxrwxrwx 1 wonna users  2412391 Aug 29 09:17 System.map-3.3.4-5.fc17.x86_64
-rwxrwxrwx 1 wonna users  4662160 Aug 29 09:17 vmlinuz-3.3.4-5.fc17.x86_64
And here's the output of an attempt to remove it:

Code:
[wonna@wearcontinue-dl boot]$ rm -rfv *
rm: cannot remove `config-3.3.4-5.fc17.x86_64': Permission denied
rm: cannot remove `extlinux': Permission denied
rm: cannot remove `grub': Permission denied
rm: cannot remove `grub2': Permission denied
rm: cannot remove `initramfs-3.3.4-5.fc17.x86_64.img': Permission denied
rm: cannot remove `lost+found': Permission denied
rm: cannot remove `System.map-3.3.4-5.fc17.x86_64': Permission denied
rm: cannot remove `vmlinuz-3.3.4-5.fc17.x86_64': Permission denied
And it doesn't make a difference whether I do it in sudo mode or not. Interestingly enough, chmod works fine on all the files, yet chown and rm don't. I would think that if I can set all of their modes to 777, then I should be able to delete them.

Any ideas?
 
Old 08-29-2013, 05:29 PM   #2
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,912

Rep: Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691
Do you realize that you are rm -rf'ing in your boot directory?

Now, if that really is /home/user/boot and not /boot, maybe your user does not have sudo rm and chown permission.

Have you tried it as root instead of sudo?

Also be careful - many of those might be symlinks to the actual /boot/ files - same for etc and others!

Last edited by astrogeek; 08-29-2013 at 05:33 PM.
 
Old 08-29-2013, 05:32 PM   #3
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
No, I know it looks like its my /boot directory, but its actually /homes/wonna/boot which is the copy I accidently made in my home directory.
 
Old 08-29-2013, 05:34 PM   #4
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,912

Rep: Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691
Quote:
Originally Posted by nathanwonnacott View Post
No, I know it looks like its my /boot directory, but its actually /homes/wonna/boot which is the copy I accidently made in my home directory.
Ok, it just gave me chills!

See my updated comments above - some of those might be symlinks...
 
Old 08-29-2013, 05:56 PM   #5
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
Hmmm... I just realized that I can't sudo rm anything:

Code:
[wonna@wearcontinue-dl ~]$ touch foo
[wonna@wearcontinue-dl ~]$ sudo rm foo
rm: cannot remove `foo': Permission denied
[wonna@wearcontinue-dl ~]$ rm foo
[wonna@wearcontinue-dl ~]$
chown is simular.

So maybe I don't have sudo rm and chown permissions. But my /etc/sudoers file says: "wonna ALL = (ALL) ALL" which I thought meant that I should have all sudo permissions.

I don't have the password for root, so I can't running it as root.

Good point about the symlinks. I didn't think rm -R followed symlinks, but I don't know for sure and the man page doesn't specify.

Another point I should mention, I'm working in an NFS mounted home folder.
 
Old 08-29-2013, 06:05 PM   #6
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,219

Rep: Reputation: 307Reputation: 307Reputation: 307Reputation: 307
Quote:
Another point I should mention, I'm working in an NFS mounted home folder.
This is essential. If this directory is exported with "root_squash" then local root will not be root on remote serwer, but for example anonymous account, so no permission.

About deleting files from /homes/wonna/boot you need write permission on that directory, the files permission are irrelevant.

Last edited by eSelix; 08-29-2013 at 06:14 PM.
 
Old 08-29-2013, 06:15 PM   #7
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
I guess that makes sense, but it still seems to me like I should be able to remove them even without sudo since their modes are rwxrwxrwx. But I guess that isn't the case for some reason.

So if root is useless on the NSF folder, do you have any other ideas for how to delete them? It's starting to look like I'll probably have to get my network administrator involved.
 
Old 08-29-2013, 06:28 PM   #8
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,912

Rep: Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691
Quote:
Originally Posted by nathanwonnacott View Post
Hmmm... I just realized that I can't sudo rm anything:

Good point about the symlinks. I didn't think rm -R followed symlinks...

Another point I should mention, I'm working in an NFS mounted home folder.
Yes, rm -R will follow symlinks and delete from linked directories. So maybe not having rm permission on those has saved you and you didn't know it!

The NFS aspect is likely the key. As noted by eSelix if exported root_squash then local root will not have root permission on remote filesystem - that includes sudo.

But I am still confused as to why it will not allow your user to remove them if they are owned by you.

From your home directory, what does ls -l say about directory permissions down the NFS mount path? In other words, what are the directory permissions of the mount point?
 
Old 08-30-2013, 11:31 AM   #9
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
Here's an ls of my home directory:
Code:
wonna@wearcontinue-dl ~]$ ls -l
total 4624
dr-xr-sr-x   6 wonna users    4096 Aug 29 09:17 boot
drwxr-sr-x   2 wonna users    4096 Aug 28 16:26 Desktop
drwxr-sr-x  18 wonna users    4096 Aug 29 09:17 dev
drwxr-sr-x   2 wonna users    4096 Aug 28 15:34 Documents
drwxr-sr-x   2 wonna users    4096 Aug 28 15:34 Downloads
drwxr-sr-x  19 wonna users    4096 Aug 28 15:34 Dropbox
drwxr-sr-x 161 wonna users   12288 Aug 29 09:17 etc
-rw-r--r--   1 wonna users       0 Aug 29 15:54 foo
drwxr-sr-x   7 wonna users    4096 Aug 28 15:19 Hack
drwxr-sr-x   3 wonna users    4096 Aug 29 09:39 homes
drwxr-sr-x   4 wonna users    4096 Aug 28 15:21 IdeaProjects
-rwxr-xr-x   1 wonna users 2726964 Aug 28 16:27 jersey.zip
lrwxrwxrwx   1 wonna users       7 Aug 29 09:39 lib -> usr/lib
lrwxrwxrwx   1 wonna users       9 Aug 29 09:17 lib64 -> usr/lib64
drwxr-sr-x   2 wonna users    4096 Aug 29 09:39 media
-rwxr-xr-x   1 wonna users    9018 Aug 28 16:26 mozilla.pdf
drwxr-sr-x   2 wonna users    4096 Aug 28 15:20 Music
drwxr-sr-x   6 wonna users    4096 Aug 29 09:39 opt
drwxr-sr-x   2 wonna users    4096 Aug 29 15:05 Pictures
drwxr-sr-x  10 wonna users    4096 Aug 28 15:40 protobuf-2.5.0
-rwxr-xr-x   1 wonna users 1866763 Aug 28 16:26 protobuf-2.5.0.tar.bz2
drwxr-sr-x   2 wonna users    4096 Aug 28 15:21 Public
drwxr-sr-x  42 wonna users    4096 Aug 29 09:39 run
lrwxrwxrwx   1 wonna users       8 Aug 29 09:39 sbin -> usr/sbin
drwxr-sr-x   2 wonna users    4096 Aug 29 09:17 srv
drwxr-sr-x   3 wonna users    4096 Aug 29 09:51 sys
drwxr-sr-x   2 wonna users    4096 Aug 28 15:14 Templates
-rwxr-xr-x   1 wonna users     823 Aug 29 09:16 tmp
-rwxr-xr-x   1 wonna users     546 Aug 28 16:24 tmp~
drwxr-sr-x  22 wonna users    4096 Aug 29 09:39 var
drwxr-sr-x   2 wonna users    4096 Aug 28 15:19 Videos
drwxr-sr-x   6 wonna users    4096 Aug 28 15:21 workspace
drwxr-sr-x   4 wonna users    4096 Aug 28 15:15 yql
 
Old 08-30-2013, 11:42 AM   #10
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
Some more context information:

Originally my home data was under a non-NFS dir (home/wonna). I wanted to move everything into homes/wonna and make that my new home directory. I tried to use "sudo usermod -d /homes/wonna wonna" but it gave me an error message stating that "wonna" was logged in, so you couldn't change it. I didn't have another account to use, so I modified /etc/passwd and changed my home directory from /home/wonna to /homes/wonna. Then I copied all of my stuff over. A lot of problems came up with copying the stuff over and unfortunately I don't remember what all of them were or how I fixed them.

In the process of copying everything over I did a lot of chmod and chown stuff, and I copied all of those important directories (boot, sys, etc) into /homes/wonna. Things were pretty messy and I didn't know what should have what permissions and I had trouble deleteing some things, so at last I decided to re-image my machine. In my mind, re-imaging would mean a fresh start on a clean slate, but I forgot that the NFS stuff would not actually be wiped.

So I formatted my computer, reinstalled Fedora, edited the /etc/passwd file again to make my home under the homes directory and that's where I had the problems deleting files.

So perhaps since I re-installed linux it doesn't think that the "wonna" that owned the files was the same as the "wonna" who I am currently now? I don't know. I didn't set up a new account or anything, all of the accounts are managed on my companies network, but perhaps this could still be a clue to what is going on.
 
Old 08-30-2013, 11:43 AM   #11
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
In answer to my question about it thinking that there are somehow two "wonna"s. I don't think that is it. Because I can do chwon wonna:users to a file and it works just fine. But then I still can't delete it.
 
Old 08-30-2013, 01:29 PM   #12
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
I fixed part of the problem

Its kind of funny because with all of that hard work dealing with chmod and chown, it didn't occur to me to just try the GUI. For some strange reason, editing the permisions in the GUI (right click, properties, permissions, and then just give everyone permissions to write and delete) worked just fine. I really don't know why that would make a difference, but it did. So I deleted all of those annoying files and directories. Its funny, because an average guy who knows nothing about linux commands probably could have fixed it much faster than a team of geeks.

There's still a more important problem though: I still can't get sudo to work in my new home directory.

I've tried a few commands to see which ones work and which ones say "Permission denied" from /homes/wonna/

Commands that work:
sudo ls
sudo stat
sudo cat
sudo vi foo //but if the permisions are rw-r--r--, it will open it in read only mode

Commands that don't work:
sudo touch foo
sudo rm foo
sudo mkdir foo
sudo rmdir foo
sudo chown foo
sudo chmod foo
 
Old 08-30-2013, 03:50 PM   #13
nathanwonnacott
LQ Newbie
 
Registered: Aug 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
Never mind. It turns out that for security reasons, no one at my company can use sudo in their NFS mounted home folders.

The problem is solved

As far as why it worked in the GUI but didn't work in the terminal, my guess is that the files had ext[2/3] attributes. The UI must use chattr, which I did not know how to use until I investigated further.

Then again, I know that there's some funky stuff about NFS with ext[2/3] attributes, so I'm not sure if chattr is even possible with it, but either way, my system works again, so I'm going to move on.

Thanks for your help.
 
Old 08-30-2013, 03:55 PM   #14
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,912

Rep: Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691
Glad to hear you got it sorted out!

I had it in my queue for more thought this afternoon, so my remaining brain cell is now freed for other tasks.

I had made a note that being a corporate setup they may use pam with a set of rules that masks how we would normally expect sudo to work, which may still be the case.

Good luck - and welcome to LQ!
 
Old 08-31-2013, 10:16 AM   #15
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,219

Rep: Reputation: 307Reputation: 307Reputation: 307Reputation: 307
Quote:
dr-xr-sr-x 6 wonna users 4096 Aug 29 09:17 boot
Permissions was clear - owner of "boot" dierectory (or anybody, but root) have no rights to modify "boot" contents, like deleting files. Only root could delete these files, but as mentioned ealier, local root is changed to other (non privileged) accout on NFS share. Just changing permissions of "boot" (as owner you can do this) and you would be able to delete files.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
system files delete by typo, /bin/ gone. How to recover? Dbronk Linux - Server 4 01-23-2010 01:05 PM
Can I delete files in /mnt/tmp? and Files in the trash can will not delete? M$ISBS Slackware 15 10-02-2009 11:56 PM
make duplicate copies of files Paul Griesbaum Linux - Newbie 7 06-08-2009 10:39 AM
Script help - delete files older than 45 days but exclude the system files jojothedogboy Linux - Software 3 06-13-2008 03:43 PM
hacker got into system and root cannot delete files, See my recovery process. Senza Paura Linux - Security 9 10-26-2007 12:54 PM


All times are GMT -5. The time now is 11:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration