You've partially fallen prey to an idiotic choice on behalf of the creators of Raspbian to give the normal "pi" user superpowers, although to be fair people will find ways to do this kind of thing on normal linux systems too.
Permissions are significant, as is /etc
. If all you did was sudo chmod 777 /etc
, you can easily fix it but you will require another POSIX system where you can act as root to do it. That would include OSX which uses the same permissions scheme and commands, although you would need to install software to read the ext4 filesystem (and I cannot promise this is really possible as I've never tried it).
A much better idea is to get a linux live CD. Anyone with a pi who doesn't have another linux system and thinks figuring out how to use a live CD is a waste of time is probably wasting a lot more time other ways. You might as well use Debian, since that's what Raspbian is based on. You probably have an "amd64" computer (aka. x86-64), within that you'll find a bunch of choices with regard to desktop; the one on Raspbian is LXDE but you can choose any of them (gnome/kde/mate/cinnamon will be snazzier, I believe cinnamon is intended for ease of use). Those are standard .iso
files that can be used to create a DVD (it's actually not a live "CD" anymore) on any OS.
Somewhere in the applications menu you will find a "system" submenu that includes "root terminal" (or console) as a choice. You should then be able to mount the SD card and chmod 755 /mnt/whatever/etc
. Beware that running an OS off a CD is very slow.
I was looking to initially add a file to etc folder but i lacked permission so I used chmod 777. What would the the appropriate approach?
Note that presumably you could have just used sudo mkdir
but WRT "the appropriate approach" there isn't one. Despite the title, /etc
is not just some toplevel directory in which to store random junk. It is used to configure system software and unless that's what you are doing, leave it alone.
If you want to put a directory somewhere that isn't /home/pi
:
Create a new directory in /home
for a non-existent user, e.g., /home/misc
, and remember not to create such a user in the future. You'll need sudo mkdir
again, then you can sudo chmod 777
. You could also use something like /home/admin
, since there is already an "admin" user, but that user does not have a home directory and ownership is not based on file names.
Create a toplevel opt
or misc
directory (again: sudo mkdir
), then put whatever it is in there.
I see Linux doesn't like to spoonfeed its users like the other operating systems haha
In the sense of making it easier for you to mess with stuff you shouldn't mess with, sort of. This was made particularly easy on Raspian due to the idiotic choice of its creators I mentioned earlier. I would guess that decision was intended to increase the "spoonfeed" factor, unfortunately it was (again) a completely idiotic mechanism to use. OTOH, we don't get as many problems reported here as I would have guessed, so the choice to stick with it may not be as ridiculous as I'm claiming.
In a more general sense you are correct, GNU/linux does not prioritize a normal audience, its primary real world use beyond the pi is for a range of things including internet servers, supercomputers, and embedded devices (which is how it ended up on the pi). However, there are obviously lots of normal PC systems using Debian, Ubuntu, Fedora, etc.
It's probably worth finding a book or reading stuff online about, if you are into reading at all
(if you made it this far into my post that counts, lol). Raspbian is a standard GNU/Linux OS so anything like "Linux for Dummies", etc. will apply.