Discussion:
chmod problem
Matthew S-H
2005-05-07 03:34:51 UTC
Permalink
I just made a slight "oopsie".
I was changing the permissions of everything in a directory inside my
home folder recursively, and I meant to type "chmod 777 .a*", but I
accidentally typed "chmod 777 .*". I stopped it in the middle of what
it was doing right after noticing an error referring to a file it
couldn't change the permissions of. It stopped while in the middle of
changing permissions something in a directory within my home
directory.
Now everything in my home folder with a starting letter before "L" (i
guess it was doing it in alphabetic order) has the permissions 777
(rwx for all users). Does anyone know of any way I can get back the
defaults? Or of any way I can have the permissions reverted to the
way they were less than 10 minutes ago?
Note that my last backup was a LONG time ago. I'd rather deal with
unrestricted permissions than with losing all of my recent work.

~Matt
Vincent Trouilliez
2005-05-07 03:48:47 UTC
Permalink
Post by Matthew S-H
Now everything in my home folder with a starting letter before "L" (i
guess it was doing it in alphabetic order) has the permissions 777
(rwx for all users). Does anyone know of any way I can get back the
defaults? Or of any way I can have the permissions reverted to the
way they were less than 10 minutes ago?
Hardly an expert, but is there any problem with personal data to have
777 permissions ? Even if they are several users on the system, I
suppose they should not be able to access your home folder, so whatever
the permissions of some of the files inside this folder, people wouldn't
see them anyway ?
Easier is probably to just leave everything alone and just call it hands
on experience ;o)


--
Vince
Vincent Trouilliez
2005-05-07 03:56:52 UTC
Permalink
I think to make sure that nobody can see your files (hence access them),
you might have to remove the 'x' permission/flag on your /home/user
folder, for 'group' and 'others'

Probably something like this :

"sudo chmod g-x /home/you" and "sudo chmod u-x /home/you"

FWIW


--
Vince
David
2005-05-07 05:57:22 UTC
Permalink
<irony>
top posted by request:
</irony>

I think I would be inclined to remove world access and then live with the
rest. chmod o-rwx /home/you/* It's not going to be perfect, but it's going
to be better than having someone read everything you have. If you don't
use groups then 740 is probably good too. I don't know of any way of
undoing a chmod. I would be inclined towards chmod ug-x too, on the
assumption that you don't keep executables in your home directory. Aren't
you happy you didn't do it as root..... btw... when did you say you were
going to do a backup?
Post by Matthew S-H
I just made a slight "oopsie".
I was changing the permissions of everything in a directory inside my
home folder recursively, and I meant to type "chmod 777 .a*", but I
accidentally typed "chmod 777 .*". I stopped it in the middle of what
it was doing right after noticing an error referring to a file it
couldn't change the permissions of. It stopped while in the middle of
changing permissions something in a directory within my home
directory.
Now everything in my home folder with a starting letter before "L" (i
guess it was doing it in alphabetic order) has the permissions 777
(rwx for all users). Does anyone know of any way I can get back the
defaults? Or of any way I can have the permissions reverted to the
way they were less than 10 minutes ago?
Note that my last backup was a LONG time ago. I'd rather deal with
unrestricted permissions than with losing all of my recent work.
~Matt
--
ubuntu-users mailing list
ubuntu-users at lists.ubuntu.com
http://lists.ubuntu.com/mailman/listinfo/ubuntu-users
ZIYAD A. M. AL-BATLY
2005-05-07 07:18:22 UTC
Permalink
Post by Matthew S-H
I just made a slight "oopsie".
I was changing the permissions of everything in a directory inside my
home folder recursively, and I meant to type "chmod 777 .a*", but I
accidentally typed "chmod 777 .*". I stopped it in the middle of what
it was doing right after noticing an error referring to a file it
couldn't change the permissions of. It stopped while in the middle of
changing permissions something in a directory within my home
directory.
Now everything in my home folder with a starting letter before "L" (i
guess it was doing it in alphabetic order) has the permissions 777
(rwx for all users). Does anyone know of any way I can get back the
defaults? Or of any way I can have the permissions reverted to the
way they were less than 10 minutes ago?
Note that my last backup was a LONG time ago. I'd rather deal with
unrestricted permissions than with losing all of my recent work.
~Matt
I don't know anything that can revirt to what was 10 minutes ago
(except, of course, backups). But here's a solution:
find $HOME -type f -print0 | xargs -0 chmod 0600 &&
find $HOME -type d -print0 | xargs -0 chmod 0700 &&
echo "You're done! Everything (hopefully) is okay."

The above will do the following:
* Find all the *files* in your home and change their permission so
that you *only* can read/change them.
* Find all the *directories* in your home and change the
permission so that you *only* have the right to
read/write/access them.

Something to be caution about:
Any executable files in your home will lose the execute bit!
(Like shell/Perl/Python scripts, and applications you compiled
yourself.)

Ziyad.
Alf-Ivar Holm
2005-05-09 17:10:33 UTC
Permalink
Post by Matthew S-H
I was changing the permissions of everything in a directory inside
my home folder recursively, and I meant to type "chmod 777 .a*", but
I accidentally typed "chmod 777 .*". [...]
Now everything in my home folder with a starting letter before "L"
(i guess it was doing it in alphabetic order) [...]
As the ".*" is expanded by the shell, you can get the list of files
given to chmod by issuing "echo .*" in the same directory. Your
assumption about sorting is right (at least if you were using
bash(1)). More info here:

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html#sect_03_04_08
Post by Matthew S-H
Note that my last backup was a LONG time ago. I'd rather deal with
unrestricted permissions than with losing all of my recent work.
Your backup may still provide you with the permissions of the files
that existed earlier. With a little bit of shell programming you
might restore most of the file permissions to their "before disaster"
state.

Affi
James Wilkinson
2005-05-10 12:24:00 UTC
Permalink
Post by Alf-Ivar Holm
As the ".*" is expanded by the shell, you can get the list of files
given to chmod by issuing "echo .*" in the same directory. Your
assumption about sorting is right (at least if you were using
bash(1)).
FWIW, what the Original Poster probably wanted was the shopt -s dotglob
command, which makes the shell expand * to include everything beginning
with a dot *except* "." and "..".

https://www.redhat.com/archives/fedora-list/2004-July/msg05222.html

James.
--
E-mail address: james | Space Opera: General term for a subgenre of adventure
@westexe.demon.co.uk | SF in which the men are heroic, the women beautiful,
| the monsters monstrous, and the spaceships make
| whooshing sounds in hard vacuum. -- Eric Raymond
Alf-Ivar Holm
2005-05-10 13:23:15 UTC
Permalink
Post by James Wilkinson
Post by Alf-Ivar Holm
As the ".*" is expanded by the shell, you can get the list of files
given to chmod by issuing "echo .*" in the same directory. Your
assumption about sorting is right (at least if you were using
bash(1)).
FWIW, what the Original Poster probably wanted was the shopt -s dotglob
command, which makes the shell expand * to include everything beginning
with a dot *except* "." and "..".
Have to admit that I didn't know about shopt, but since the Original
Poster actually did a chmod on ".*" and "." and ".." are (normally)
expanded first, my guess would be that they were also modified.

Affi
Alexander Kirillov
2005-05-10 13:24:11 UTC
Permalink
Post by Matthew S-H
I just made a slight "oopsie".
I was changing the permissions of everything in a directory inside my
home folder recursively, and I meant to type "chmod 777 .a*", but I
accidentally typed "chmod 777 .*". I stopped it in the middle of what
it was doing right after noticing an error referring to a file it
couldn't change the permissions of. It stopped while in the middle of
changing permissions something in a directory within my home
directory.
Now everything in my home folder with a starting letter before "L" (i
guess it was doing it in alphabetic order) has the permissions 777
(rwx for all users). Does anyone know of any way I can get back the
defaults? Or of any way I can have the permissions reverted to the
way they were less than 10 minutes ago?
Note that my last backup was a LONG time ago. I'd rather deal with
unrestricted permissions than with losing all of my recent work.
~Matt
--
ubuntu-users mailing list
ubuntu-users at lists.ubuntu.com
http://lists.ubuntu.com/mailman/listinfo/ubuntu-users
The old permissions are not stored anywhere, so there is no way to
tell the system "restore the permissions to the state 10 minutes ago".
:(



There are two ways I see:

- do chmod 644 .* - to make all files have permission 644 (or whatever
is the permission you want to have as default)



or



- get that old backup, use it to lookup what permisssions those fiels
had, and then chmod each of your files to the correct permission
(without changing files content). You can write a bash script to do
that - but I am not very good at shell scripts. Or maybe file
synchronization tools, such as unison
http://www.cis.upenn.edu/~bcpierce/unison can do this?
--
Alexander Kirillov
Loading...