LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shell script (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-645776/)

bkcreddy17 05-30-2008 03:02 AM

shell script
 
hi,
There is a batch file script to set password to a folder. Of course we can use chmod or chown and restrict user. But in home PC every one logs in as root. Can any tell me the script in Linux?

mrrangerman 05-30-2008 04:34 AM

Quote:

bkcreddy17

But in home PC every one logs in as root.
Set up user accounts for each person, running as root is NOT a smart thing to do.......... Your asking for trouble.

bkcreddy17 05-30-2008 04:47 AM

Thank you.
That's ok. But my motto is, when we try to open a folder, it should prompt for password. How can we do it?

jschiwal 05-30-2008 04:59 AM

Don't run as root. Use permissions and maybe even acls to control access to directories and files. (see manpages for chown, chgrp, setfacl & getfacl). If a person doesn't have read permission on a folder or file, they can't read it. If you have files & subdirectories in a globally readable & writable parent directory, set the sticky bit on the directory to prevent any user from deleting any file.

The permission (and password) to enter a directory or read a file was determined when they log in and enter their password.

You can also use encryption. Then a person needs to know a password to decrypt the file.

PS. <gripe>Why does it seem that so many people from India do things like run RH9, use telnet and log in as root?</gripe>

ischi 05-30-2008 05:18 AM

Never ever run as root, because if you are running as root all your programms also have root privileges and even a small bug can srew up your whole System! Thats what user accounts are for. I would even limit the login that ie root over ssh is not possible, so you first login as normal user and than do su.
That being said, if all your users have the root password anyway its not save to just set permissions for the users, it is improtant to do that but not sufficiant for safety. What I would do:
Either change the root password to something strong, and dont give it to anybody (if nobody else needs root) than set the permissions.
or if thats not possible than encrypt the home of each user (or at least a folder for each user) where only the user knows the password. this can be done with Truecrypt ie.

Personally I would designate a trustable admin who has root, and nobody else knows the password which should be something strong liken 231kfas41as"!")(§kasd



I

Ajax4Hire 05-30-2008 08:12 AM

Quote:

Originally Posted by bkcreddy17 (Post 3169111)
But my motto is, when we try to open a folder, it should prompt for password. How can we do it?

You are asking for contradictory criteria.
How to give all users to have complete access but not complete access.

Everyone logs in as root, meaning everyone has complete control over everything.
Everyone need to enter a different password for individual folders.

The reason "root" is root is to NOT have to enter password for everything.
Root is to setup, cleanup, fixup the mess ups.
User is to use the computer.

Give each user a name, a username.
There is a reason why you don't run as root,
you will discover this reason the hard way.
Take the advice now or take it later but you will take it.

i92guboj 05-30-2008 08:46 AM

You are just confused on how the linux multiuser paradigm works on its own.

You need to create one regular user per person. Each user has it0s own home directory and it's own password. No one can read the files from USER_A unless USER_A explicitly permitted it via chmod/chown.

You are trying to re-invent the wheel in an insane way. If you run as root, everything runs as root, and that included malicious javascripts and trojans. Not to speak about the damage that your users can (and will) do to your system.

seraphim172 05-30-2008 04:04 PM

What's the reason of passwords if everyone runs as root? Do you want a tool that locks out root? Even if you would have such a tool, as root you could disable it.

If you want to password-protect folders for regular users, then the question is what application is used to browse directories. If a web-browser is used on an Apache server, then .htaccess and .htpassword files can be used.

Linux Archive


All times are GMT -5. The time now is 12:07 AM.