change owner of folder

Got problems with your B2 or B3? Share and get helped!
Post Reply
ahab
Posts: 35
Joined: 25 Aug 2008, 17:35

change owner of folder

Post by ahab » 28 Dec 2008, 08:34

Hi,

I've uploaded various files to my bubba2 from different computers. Unfortunately I put some files in my admin-folder and some in my user-folder and some files in the storage-folder. Somehow I've also managed to get different owners (admin/user) of the folders. This makes it hard for me to move the files into one folder.

Can anyone please tell me how to change the owner of a folder?

I'm not that experienced at debian (yet), but I've tried to move the folders from my visa computer using the explorer, the web-ui and winscp. No matter what I do I always get a "permission denied"-message.

I've also tried to edit the permissions of the folder via the web-ui, windows explorer and winscp but I get "permission denied".

Xargon
Posts: 34
Joined: 10 Nov 2007, 18:16

Post by Xargon » 28 Dec 2008, 16:19

Hi.
I use CHMOD.

Log in using SSH.

Become root

Code: Select all

su
Password

Code: Select all

excito
Change folder and file preferences

Code: Select all

chmod -R 777 /directory/to/change/
BR,
Xargon[/code]

ahab
Posts: 35
Joined: 25 Aug 2008, 17:35

Post by ahab » 29 Dec 2008, 05:43

Thank you! Now I've changed the permissions so that I can work with the files :D

For some reason it couldn't find the folder storage so I had to change the permission for all files (chmod -R 777 /) :oops: But it works, and that's what's important!

carl
Posts: 474
Joined: 07 May 2008, 04:41

Post by carl » 29 Dec 2008, 09:09

ahab wrote:Thank you! Now I've changed the permissions so that I can work with the files :D

For some reason it couldn't find the folder storage so I had to change the permission for all files (chmod -R 777 /) :oops: But it works, and that's what's important!
That wasn't probably the wisest choice; above command can render your system fully unusable and un-upgradable, with the only solution a full reinstall, the command that should have been issued is:

Code: Select all

chgrp -R users /home/storage
(as root)

/Carl
/Carl Fürstenberg, Excito Software Developer
http://www.excito.com
support@excito.com

ahab
Posts: 35
Joined: 25 Aug 2008, 17:35

Post by ahab » 29 Dec 2008, 09:23

Oops, is it possible to undo my chmod command?

carl
Posts: 474
Joined: 07 May 2008, 04:41

Post by carl » 29 Dec 2008, 09:47

ahab wrote:Oops, is it possible to undo my chmod command?
Sadly no, as it's a destructive command. I assume correctly that you can't use "su" any more? (if you ran this on root /, then all setuid bits would have been removed from essential executables). If so, the only solution is a full reinstallation of the system. You might be able to keep the /home partition, as it doesn't contain any executables and such, and after reinstall of system, issue following commands:

Code: Select all

find /home -type f -exec chmod 0644 '{}' ';'
find /home -type d -exec chmod 0755 '{}' ';'
find /home/ -type d -a \( -wholename '/home/*/private' -o -wholename '/home/*/torrents' -o -wholename '/home/*/downloads' \) -exec chmod 0700 '{}' ';'
chmod 0777 /home/storage
chmod 0750 /home/web
chgrp -R users /home/storage
chown -R www-data:users /home/web
Hope this helps.

/Carl
/Carl Fürstenberg, Excito Software Developer
http://www.excito.com
support@excito.com

Xargon
Posts: 34
Joined: 10 Nov 2007, 18:16

Post by Xargon » 29 Dec 2008, 10:22

I have used it a lot both on Bubba and Bubba|Two and never had any problems. But I trust Carl so I guess I have to start using chgrp instead.

BR,
Xargon

carl
Posts: 474
Joined: 07 May 2008, 04:41

Post by carl » 29 Dec 2008, 10:30

Xargon wrote:I have used it a lot both on Bubba and Bubba|Two and never had any problems. But I trust Carl so I guess I have to start using chgrp instead.

BR,
Xargon
Following command shows how /bin/su should look like:

Code: Select all

test@bubba:/home$ ls -l /bin/su 
-rwsr-xr-x 1 root root 31000 2007-02-27 19:30 /bin/su
notice the 's' in the permission row, it specifies that the "setuid" flag is set, which means it will execute as the owner of the file instead of the user executing the file; this is a must because "su" needs to be able to have super user privilege. Issuing the command chmod 777 on this file results in that this flag is going to be removed, and no one except root can use su then :)

/Carl
/Carl Fürstenberg, Excito Software Developer
http://www.excito.com
support@excito.com

Xargon
Posts: 34
Joined: 10 Nov 2007, 18:16

Post by Xargon » 29 Dec 2008, 13:42

I have only run it on /home/storage/ so maybe thats why i have not noticed any problems

Xargon
Posts: 34
Joined: 10 Nov 2007, 18:16

Post by Xargon » 29 Dec 2008, 13:43

...and I am truly sorry if I caused you problems Ahab, that was definately not my intention.

:oops:

ahab
Posts: 35
Joined: 25 Aug 2008, 17:35

Post by ahab » 29 Dec 2008, 15:31

No problem Xargon, it was my choice to use the command and after all you only learn from your own mistakes. Mistakes of others are pure entertainment...

Anyway, I noticed that the command didn't execute on all files, I got a lot of "operation not allowed"-messages. But still, some bad things must have happened since I can't access my bubba2 via putty anymore!

As soon as I start the terminal I get a "PuTTY fatal error"-message saying "Server unexpectedly closed network connection". Do you think this is related to the permissions?

Anyway, I can still access my files via WinSCP and the web-ui so I guess I'll have to make a back-up of all my files and then try a full reinstall. Is there a how-to for that?

Xargon
Posts: 34
Joined: 10 Nov 2007, 18:16

Post by Xargon » 29 Dec 2008, 16:11

Yes there is.

Download to usb-stick: http://update.excito.net/install/latest/bubba-two/
Read manual: http://download.excito.net/web/BubbaTwo ... index.html#

STANDARD INSTALLATION
Note: All your personal data will be lost if doing this operation. A complete hard drive format will be done.



Download the recovery image at: http://update.excito.net/install/latest/bubba-two/
Insert the USB memory stick in to your PC (minimum size 256 MByte) and format it, select FAT32 as file system if prompted. The USB stick must have a partition table.
Unzip the downloaded recovery image to the root catalogue on the USB stick.
Shut down Bubba|Two.
Remove power to Bubba|Two.
Place the USB memory in one of Bubba|Two's USB ports, which one doesn't matter.
Make sure that Bubba|Two's WAN port is connected to internet; this is needed during installation (to set time etc.).
Hold the power button pressed, keeping it pressed, and plug in the power cord to Bubba|Two again.
Wait until Bubba|Two begins to flash its LED, hold the button pressed for 5 seconds then release it. Bubba|Two will now automatically format the disk, and install the Linux file system on it. The installation will take about 15 minutes to complete with a 1 TB disk. Wait until the LED stops flashing.
Enter the web interface and do a Software update (as described in chapter Software Upgrade)

/X

ahab
Posts: 35
Joined: 25 Aug 2008, 17:35

problem solved!!!

Post by ahab » 15 Jan 2009, 05:45

Now my bubba is back to normal! and the positivt thing is that I've got a back-up of all my pictures and I've upgraded to the latest firmware. All is well that ends well!

davidI
Posts: 49
Joined: 07 Oct 2008, 13:39

Post by davidI » 15 Jan 2009, 13:51

Please note that chmod 755 changes all bits.
A better option to use is , e.g.

chmod g+w

which only adds the write permission for the group.

the 3 'domains' are u == user g == group and o == others, a == all
the permissions are r == read, w == write, x == execute, s == sticky.

See "man chmod" for more or chmod --help which gives:

Usage: chmod [OPTION]... MODE[,MODE]... FILE...
or: chmod [OPTION]... OCTAL-MODE FILE...
or: chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.

-c, --changes like verbose but report only when a change is made
--no-preserve-root do not treat `/' specially (the default)
--preserve-root fail to operate recursively on `/'
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--reference=RFILE use RFILE's mode instead of MODE values
-R, --recursive change files and directories recursively
--help display this help and exit
--version output version information and exit

Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.

Post Reply