Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello,
I'm running mandrake 9.1 and KDE. Generally, I like it. But
I notice that when I save a file, the default permissions are:
rw-rw-r--
This means that "others" can read my files by default.
This does not seem to be a sensible default, so I
would like to change the default permissions to:
rw-rw----
But where do I change it?
~/.bashrc points to /etc/bashrc
~/.profile doesn't exist
Putting umask 117 in /etc/bashrc doesn't work.
Putting umask 117 in /etc/profile doesn't work either.
I tried putting umask 117 in ~/.bash_profile, logging out then in again, and creating a file.
The permissions are still rw-rw-r--. So that didn't do it.
I tried putting umask=117 in ~/.bash_profile, logging out then in again, and creating a file.
The permissions are still rw-rw-r--. So that didn't do it either.
"If you put your files in your home directory, no one will be able to read them." - Unfortunately this is not the case on my system (Mandrake 9.1, default install). My home directory (and everybody else's too) has the permissions rwxr-xr-x, so they are basically "open". And I'd like to try to fix this.
The default permissions assigned to a newly created file or directory depend of your system and system administrator. The defaults can be changed with the umask command.
umask permission-list
For example,
1.$ umask a=rx,ug+w
specifies that all users have read and, if relevant, execute permission for newly created files and directories. Additionally, write privileges are granted to the user and group.
2 $ umask a=rwx,g=rx,o=
specifies that the user has all permissions, the groups has read and execute permission and others have no permissions.
And that you should specify your desired permissions in ~/.profile file
Setting umask to 177 in ~/.bash_profile creates new files with the right permissions (rw-------), but directories with the wrong ones - so I do not have access to new dirs I create. The magic number for umask seems to be 077. Dirs are now created rwx------, which is good.
Konsole(s) opened from KDE revert to a umask of 022, which is annoying. Konsole doesn't seem to read ~/.bash_profile, which is odd.
All I have to do now is some fancy command-line stuff with "find" and "chmod" and whatnot to reset the permissions properly for all those files and directories that I and the other users have so far created.
To make KDE applications and shells opened from
KDE (eg with konsole), and <CTRL><ALT><F-something> logins save files with the
correct default permissions of rw-------
I had to put umask 077 into
~/.bashrc and
~/.bash_profile
and also put export BASH_ENV=~/.bashrc into /etc/profile
Hate to have to crack this baby back open again, but, how would I do this for all users on a system without editing everyone's bashrc and bash_profile files?
MadTurki, I think you will have to edit all those bashrc and bash_profile files. If there are many users, I expect you can create a script to do this for you, but for just a few, it's probably not worth the effort.
For users that you will create in the future though, take a look in /etc/skel.
So, this is working great for users that telnet or ssh into the server. But the same people using samba are still ending up with the default 755 permissions :S How can I make this effect samba as well?
You don't need to edit every user's files unless they are specifically setting the umask already. If there is no umask command in their home files, then /etc/profile is used. You can add umask to that to make it systemwide (provided it's not overridden in a user's home directory).
Also, there's no need to add it to both bash files. You can simply source .bashrc from .bash_profile, and make whatever modifications you want to .bashrc:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.