Configuring permissions to folder in ubuntu in order to prevent user's from removing files of others - linux

I have a folder owned by a group named "wheel".
The 'ls' command details for that folder is:
drwxrws--- 2 tps wheel 4096 may 8 08:10 tsreports
(tps = a user, owner of the file, wheel = the group, tsreports = name of the folder)
I need to configure the folder permissions in such way that files written into it are still owned by the wheel group, but so that one member of wheel cannot delete another member's files.
I think I already managed the part where newly created files in the folder will be automatically owned by the 'wheel' group
(I used chmod g+s tpsreports in order to do that)
but I'm not sure how I can prevent one member of 'wheel' from deleting another's file.
I could use some help, Thanks.

On the internet, I found this URL, mentioning a "sticky bit", which might solve your problem.

Related

windows 10 - permission denied when trying to delete folder

I have a certain folder on my computer that I want to delete but I can't. I opened the cmd console as administrator and tried to delete the folder, but access was denied. It doesn't even let me change ownership on the folder. I'm using windows 10 64-bit. How can I delete the folder?
Thanks.
Try Lock Hunter , its a unlocker software which worked well for me
open power shell as administrator
cd c:\folderInQuestion
rm -r .\folderInQuestion\
If the folder lies outide of your specific User Account folder, then you will have to take ownership of the folder (or a parent folder) before you can delete it.
In my case, I needed to delete a subfolder that was nested deep inside my Projects folder, which sits at my root. Even though my account had "full control" (see this)
To take ownership of the folder, follow this: https://answers.microsoft.com/en-us/windows/forum/windows_10-files/give-permissions-to-files-and-folders-in-windows/78ee562c-a21f-4a32-8691-73aac1415373

Change ownership in cpio archive without root

I need to add files to an initramfs file(I own the file as this is for some other device), however I do not have root permissions on my development machine. The usual way would be to unpack the initramfs, add files, change owner to root and pack again. I can not do this, as changing owner on this machine would require root permissions. If I do not change owner the system might behave weird(and it is just not a clean setup).
I can not do this on the target system as it is an embedded system, which only has read only access to the initramfs file.
Is there any way to change the permissions during or after packing the cpio archive?
Use fakeroot to deal with permissions during extraction and compression. it is developed to provide root environment without actually being root.
girishp#~/incoming$ /usr/bin/fakeroot /bin/bash
root#~/incoming$

Can a OS Update Modify the Permission in a Directory?

I upgraded my Fedora box a few days ago. I went from Fedora 18, to Fedora 20 using fedup. This morning I noticed that when I tried to delete a zip file from one of my directories, I couldn't. Then I tried to create a directory, and I couldn't. I had to use sudo.
The directory where this is happening is the /var/www/html directory, which is the root directory of my server. Before doing the update I could modify the contents of this directory without any problem. I don't remember, but I may have changed the permission of the directory at some point to allow me to do this. Is it possible that the upgrade modified the permission of the html directory?
Please note that I'm not asking how to gain permission again, I've already modified the permission in the html directory. I just want to know if the reason for this happening was that the upgrade modified the permission on that directory.
Thanks.
The /var/www/html directory on Fedora is owned by the httpd package so yes, if that package got updated, then the permissions for that directory will be reset to whatever the package specifies.

Linux: Allow one user to manage all files from another user/group

I just installed lamp-server^ on my home linux machine.
Now I created a new folder project with files in the /var/www/ directory (server root directory). I set the owner user/group to www-data via sudo.
Now I want to access the folder and its files via cd or normally via the file explorer, but I get the error that I haven't the permission to do/access that folder or its files (with my normal user account).
Is it possible to give my user account the rights to access/modify the project folder?
you can either
a+rwx the directory or
include yourself in that group, but from your question, it seems you don't want to do that. it would be more secure than allowing anyone to read, write and execute that dir.
Yes it is possible. Just add your user in www-data group.
useradd -G www-data {your_username}

Bash scripting and user home from root account (Linux)

I'm writing an install script in bash for an application on Linux.
This script copies some files into /usr/bin and /usr/share, so it needs to be executed by a root user, furthermore it makes an hidden directory in the $HOME dir for configuration files.
Here is the problem: if a normal user wants to install the program, he needs to be root. But if he is root, the $HOME directory will be /root/ instead of /home/username.
...and, further, if UserA installs the software, but UserB runs it, UserB won't have the hidden directory under /home/UserB. Also, the hidden directory under /home/UserA will be owned by root, not userA.
So, you need to have the application create the hidden directory, not the installer.
Another possible option is not to install in the system directories; one possible alternative location is /usr/local. However, even that can require root privileges. Think about whether it can be installed in other places, and how it could locate its materials.
However, requiring root privileges to install is not the end of the world - a nuisance for some, but not completely out of order. But requiring everyone who uses to have root privileges is way out of order - and if everyone who uses it needs to run the installer, that is bad.
Final point (for now): if you use sudo, it does not change the value of $HOME, even as you acquire root privileges. However, requiring everyone who uses your application to have sudo privileges is not a good thing either.
Must you use $HOME? Maybe you could prompt for the username and install to ~$username instead?

Resources