date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,561,054,774,000
At the moment I am playing around with linux on my raspbery pi and Im trying to learn how the permission system works. I created a group of two users one of them created a python script in his own documents folder with the permissions: -rwx--x---. The other group member should execute the file with the command python hello.py but he says permission denied. The only way is to give the group also reading permission so: -rwxr-x--- Why is the execution permission not enough to execute the python script?
The execute permissions are enough for the kernel to execute the file. If the file starts with #!, then it will see it's a script, parse that line to find out the path of the interpreter and an optional argument, and then execute that interpreter with that optional argument and the file path as argument. For instance, if the file starts with: #! /usr/bin/python -E The kernel changes the execve("/path/to/the-script", ["the-script", "arg"], [envs]) to execve("/usr/bin/python", ["/usr/bin/python", "-E", "/path/to/the-script", "arg"], [envs]). Without the execute permissions, it would never have gotten that far. Now, at that point, what matters is the execution permission of the interpreter. It it's executables, then it works as normal. However, later, /usr/bin/python will want to open the /path/to/the-script to read and interpret the code in it. And for that, it will need read permission to the file. Unless maybe it has changed euid since last time (for instance if the /usr/bin/python file had the suid/sgid bit), if you didn't have read permissions earlier, you still don't have it. So you can execute a script alright if you have only execute permission to it. It's just that if the interpreter needs to open it to read its content that it fails (and you see the error message comes from the interpreter, not the shell you're trying to run that script from). In a script like: #! /bin/echo Here goes You'll see that not having read permission doesn't matter since echo is not trying to open the file for reading.
Why I can't execute script with only execution permission? [duplicate]
1,561,054,774,000
I now realise, thanks to a comment by jessie_b, that I made a blunder in describing the circumstances of my problem that is not a problem.. If I can I would like to withdraw this question. With apologies for the trouble caused. I am practising with vim to refresh my understanding, and to do this I have created a test file, to edit in user mode. When I tried to change to insert mode I was told "-- INSERT -- W10: Warning: Changing a read only file". I used chmod, in supervisor mode, to change the permissions to permit writing to the file: [Harry@localhost]~% ls -l vim/test --w--w--w- 1 root root 39 Jul 31 19:08 vim/test [Harry@localhost]~% But, going back to edit in user mode, I still get the same warning. Please can someone explain this? No mystery after all, changing the permissions to --w--w-rw- solves the (non-existent) problem.
From within vim try the following: :set noro . The file may be set read only from within vim but I have a feeling something weird is going on because you don't have read permissions to the file...you shouldn't even be able to open it. If I create a test document and chmod 222 I get [Permission Denied] when I try to open with vim not read only.
This question was based on a blunder.Why does vim give "read only" for file with --w--w--w- permissions [closed]
1,561,054,774,000
I am able to read content of rpm by using rpm -qlp *.rpm But it shows me the files without permissions. I want it looks like output from 'ls -l' command. How is this possible without extract the package?
You can use --dump to extract all the available metadata for files in the package, and post-process that: rpm -qp --dump *.rpm | awk '{ printf "%7s %8s %8s %8d %s %s\n", $5, $6, $7, $2, strftime("%c", $3), $1 }' Adapting the strftime() call, and the mode/permissions output, to mimick ls’s behaviour is left as an exercise to the reader.
How to read content from rpm file and show file permissions
1,561,054,774,000
Can anyone explain this one: Embedded Arm system, Linux 3.18.44. No SELinux or anything: # ls -l /dev/console crw------- 1 root root 5, 1 Jan 6 02:40 /dev/console # ls -l /tmp/console crw------- 1 root root 5, 1 Jan 6 02:39 /tmp/console # echo foo > /dev/console foo # echo foo > /tmp/console -sh: can't create /tmp/console: Permission denied # ls -ld /tmp drwxr-xr-x 2 root root 80 Jan 6 02:39 /tmp # ls -ld /dev drwxr-xr-x 11 root root 5480 Jan 6 02:32 /dev Some detail from strace: # strace sh -c 'echo foo > /tmp/console' 2>&1 | grep console execve("/bin/sh", ["sh", "-c", "echo foo > /tmp/console"], [/* 12 vars */]) = 0 open("/tmp/console", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = -1 EACCES (Pe) Versus: # strace sh -c 'echo foo > /dev/console' 2>&1 | grep console execve("/bin/sh", ["sh", "-c", "echo foo > /dev/console"], [/* 12 vars */]) = 0 open("/dev/console", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3 foo It's the same device: major 5, minor 1. Why would the device care about the path name of the filesystem node that refers to it? If that's what the issue is, which is what it looks like: # mknod -m 600 /tmp/cons c 5 1 # echo foo > /dev/cons foo # mknod -m 600 /tmp/cons c 5 1 # echo foo > /tmp/cons -sh: can't create /tmp/cons: Permission denied Some sort of "security theatre"? It works under Linux 3.14 on very similar hardware.
/tmp is mounted nodev and /dev isn't ...?
Can't write to /dev/console through node not in /dev
1,561,054,774,000
I accidentally copied the files from /proc to one of the directory under /home But now I am not able to delete those copied contents. It says "Permission denied". Folder size is ~300GB How can I safely delete the copied version of proc folder?
How to delete files "safely" How to solve your "Permission denied" problem 1. How to delete files "safely" Modern versions of GNU rm will keep you safe from accidentally deleting all of / , but you can still accidentally delete all of /home... The safest way I can think is to first cd into the directory, use ls to check it is the right one, then delete its contents, then cd .. and rmdir proc. rmdir is very safe because it only deletes empty directories. To delete everything in the current directory, use rm -r -- * It is probably "safe" to forget the -- in the rm command. However it might not work as expected, for example if there is a file called -i. You could use a graphical file manager instead, which is generally safer than rm. You can move the file(s) to the "trash". This will leave you a chance to undo the action, until you empty the whole trash, or delete the file(s) from the trash. I prefer using this when possible. It does not always work well. I managed to crash Gnome Files while testing this :-). 2. How to solve your "Permission denied" problem Your problem is that some of the subdirectories have been marked as "read only". (And you are not running as root, which ignores these markings). You can allow writes to the current directory and everything inside it, using chmod u+w -R . Then you will be able to delete it. In some cases, using a graphical file manager to delete a folder will change the permissions for you automatically. Or, you can use the file manager to change permissions manually. If you use Gnome Files: right click -> Properties -> Permissions. Next to Owner, set "Create and delete files". Then do the same again under "Change permission for enclosed files".
Delete copied version of /proc folder in unix
1,561,054,774,000
I understand how to make an executable also execute as root with the chmod u+s command to set the suid. What I am wondering is how I would get the executable always executed as a non root user that is different from the user that is executing the file. So for clarity let's say I have Alice and Bob users, both not in the sudo group. Alice creates an executable that reads something from her homefolder and wants to make sure that Bob can execute the file as well but does not want to have the executable run with root privileges due to security concerns. How can Alice make sure that the file is always ran under her user without Bob needing her credentials?
The suid flag will ensure the file is always executed as the current owner of the file, not root. So if you want a file to always run as alice, then let it be owned by alice using: chown alice filename, then set it as suid.
Execute as another user that is not root
1,561,054,774,000
One of the study questions I'm doing is suggesting that I apply ACL's for the /root directory recursively for a regular user on the system. Obviously, this is bad security practice but it's just for practice inside a VM and I will remove the ACL once I'm done. I've tried like this: setfacl -R -m u:username:rwx /root But when I log in as username I just get every file as rwx permissions, including text files and other non executables. Is there a neater way that copies permissions into the ACL from regular ugo permissions, or would that involve a bit of bash scripting?
I found that it wasn't necessary to use the recursive (-R) switch in this case. Just doing this: setfacl -m u:username:rwx /root Was enough to give me execute access to /root as normal user and also tried copying some executables into the directory and subdirectories. They ran just as if I were accessing my home directory. Thanks to vfbsilva for the reply, which made me try the simpler approach. I have upvoted their comment.
setfacl a whole directory containing assorted file types?
1,561,054,774,000
I'm using the file directive to set the contents of many configuration files. Some of the applications have their own configuration interfaces which are the preferred way to modify these files (before copying them back to Puppet). But some of these applications also change the mode of the configuration files when saving them. Because I can't be bothered to record and keep up to date hundreds of file to mode settings which are irrelevant to the configuration this leads to a fight between Puppet and the application, each overriding the other's mode. Which in turn leads to a longer Puppet run than necessary and to more clutter in the logs. So how do I simply leave the mode alone? To be clear, I do want to replace contents, so replace => false is not an option.
Per the comment, if the mode property of the file resource is set in a base class and you wish to override it, then use undef: class specialist inherits base { File["/etc/example"] { content => "new content", mode => undef, } } The mode property will then be unmanaged and won't be changed by Puppet.
How to set file contents but leaving permissions alone using Puppet?
1,561,054,774,000
I need to mount a storage on server A so that from server B, I can send a file via scp from B to A. On server A, I am trying to mount the storage as: # mount.cifs //u999999.your-storagebox.de/backup /storage/driveNumber -v -o user=u999999,pass=typeUrPasswordHere The mount result is: # ls -la /storage total 8 drwxr-xr-x 3 root root 4096 Feb 2 17:17 . drwxr-xr-x 23 root root 4096 Feb 2 17:16 .. drwxrwxrwx 2 999999 999999 0 Feb 3 17:26 bx20_133060 But, when I try to send the file from server B (my box for now), I get this: $ scp -v -p -P 45789 mysql-incremental.tar.gz [email protected]:/storage/bx20_133060 Executing: program /usr/bin/ssh host d2.wearebionic.com, user slammer, command scp -v -p -t /storage/bx20_133060 OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to d2.wearebionic.com [136.243.80.14] port 45789. debug1: Connection established. debug1: identity file /home/gtl/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/gtl/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/gtl/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/gtl/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/gtl/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/gtl/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/gtl/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/gtl/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH_6.6.1* compat 0x04000000 debug1: Authenticating to d2.wearebionic.com:45789 as 'slammer' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: [email protected] debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ue89Au5xEc1UIDcLMwNhTGWuHP7vwJwNHtQbaYo0cUI debug1: Host '[d2.wearebionic.com]:45789' is known and matches the ECDSA host key. debug1: Found key in /home/gtl/.ssh/known_hosts:8 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/gtl/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 279 debug1: Authentication succeeded (publickey). Authenticated to d2.wearebionic.com ([136.243.80.14]:45789). debug1: channel 0: new [client-session] debug1: Requesting [email protected] debug1: Entering interactive session. debug1: pledge: network debug1: Sending environment. debug1: Sending env LC_PAPER = en_IE.UTF-8 debug1: Sending env LC_ADDRESS = en_IE.UTF-8 debug1: Sending env LC_MONETARY = en_IE.UTF-8 debug1: Sending env LC_NUMERIC = en_IE.UTF-8 debug1: Sending env LC_TELEPHONE = en_IE.UTF-8 debug1: Sending env LC_IDENTIFICATION = en_IE.UTF-8 debug1: Sending env LANG = en_IE.UTF-8 debug1: Sending env LC_MEASUREMENT = en_IE.UTF-8 debug1: Sending env LC_TIME = pt_BR.UTF-8 debug1: Sending env LC_NAME = en_IE.UTF-8 debug1: Sending command: scp -v -p -t /storage/bx20_133060 File mtime 1485968603 atime 1486140418 Sending file timestamps: T1485968603 0 1486140418 0 Sink: T1485968603 0 1486140418 0 Sending file modes: C0777 75337 mysql-incremental.tar.gz Sink: C0777 75337 mysql-incremental.tar.gz scp: /storage/bx20_133060/mysql-incremental.tar.gz: Permission denied debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK Transferred: sent 3336, received 2708 bytes, in 0.2 seconds Bytes per second: sent 13686.3, received 11109.9 debug1: Exit status 1 What am I doing wrong and how to get it right?
for just using scp I would first validate it between server A and server B directly and take your storagebox out of the equation. From each server try something like scp somefile.txt otherserver:/home/gtludwig/ If that does not work then the problem is more simplified and has to do with ssh and scp and the security between each server. But I suspect the problem lies with user, file, and directory permissions not being sync'd between the storagebox and that of the server you are mounting it to. This would be especially true if storagebox being cifs is some storage device that authenticates with some Windows Domain Server... which would technically be Server C. Also know the admin of storagebox can simply restrict what devices can mount storagebox regardless if the username & password are correct for storagebox. This would be the equivalent of restricting a linux NFS export to given hosts as might be specified in /etc/exports. But from the info you provided it looks like what is happening is you have storagebox mounted on server_A and a mount.cifs is directed under user u999999 but when using scp you are SSH'ing into Server_A under user slammer thus permission denied. From Server_A first make sure storagebox is successfully mounted, and then as user u999999 you can then successfully upload a file to storagebox. Then try scp into server_A as u999999, or make sure the username/userid you use for scp is the same as that used for mounting the cifs share.
how to mount a data center storage on a server so an user can access it remotely?
1,561,054,774,000
I want to cat /home/ubuntu/.gnupg/gpg.conf which has 0600 permission. λ ubuntu [~] → sudo stat /home/ubuntu/.gnupg/gpg.conf File: ‘/home/ubuntu/.gnupg/gpg.conf’ Size: 9398 Blocks: 24 IO Block: 4096 regular file Device: fc00h/64512d Inode: 529194 Links: 1 Access: (0600/-rw-------) Uid: ( 1001/ ubuntu) Gid: ( 1001/ ubuntu) Access: 2017-01-23 17:10:31.170988382 +0000 Modify: 2017-01-23 17:10:23.107069483 +0000 Change: 2017-01-23 18:47:55.460216373 +0000 Birth: - but when I try to cat it, I get permission denied! λ ubuntu [~] → who am i ubuntu pts/0 2017-01-23 15:27 (10.0.2.2) λ ubuntu [~] → cat /home/ubuntu/.gnupg/gpg.conf cat: /home/ubuntu/.gnupg/gpg.conf: Permission denied What I'm doing wrong?
Most likely, the permissions on the .gnupg directory are missing the x permissions, which allows traversing to the gpg.conf file and its visibility. Try this: sudo chmod u+x /home/ubuntu/.gnupg
In spite of proper permission not being able to cat the file
1,482,988,715,000
Unix files have two kinds of ownership: user and group, each with its own permissions. Normally, the owner of a file should have full access to it, whereas members of a work group to which the owner belongs might have limited access, and everyone else, even less access. This last category is called other in Unix documentation. For a file, are the permissions for its work group necessarily permissions of its user owner? Since its user owner is a member of its work group, I guess the answer is yes, unless its work group excludes its user owner in the case of permissions. The permissions of its user owner may be more than those of its work group. are the permissions for its user owner necessarily permissions of other? Some said 'other' means the entire world. In that sense its work group should be a subset of 'other', so I guess the answer is yes, unless 'other' excludes its work group. The permissions of its work group may be more than those of 'other'. If it matters, I am focusing on Linux.
Permissions under Unix-like systems use an octal representation. It begins with an optional special permission, followed by user, group, others. u, g, and o permissions are a combination of the following ORed together: read: 4 write: 2 execute: 1 Therefore, the permission 0774 would allow its owner and group full access but read-only access to others. Those permissions, including the special permission, are independent from one another. Files also have a single owner and group, which are also independent, in their attributes. It is therefore possible for the owner to have read-only access while members of groupX have read-write access, and people not matching either owner or group criteria having full access. Lets consider user john that changes permissions of text.txt to 0467, ownership to john, and group to operator: $ chown john:operator text.txt $ chmod 0467 text.txt $ ls -l text.txt -r--rw-rwx 1 john operator 0 Dec 29 00:57 text.txt If john is not part of the operator group, he will not be able to update the file contents: $ echo hi > text.txt text.txt: Permission denied But he can still change the permissions on the file, and update the file: $ chmod u+w text.txt $ echo hi > text.txt $ ls -l text.txt -rw-rw-rwx 1 john operator 3 Dec 29 00:57 text.txt Note that accessing a file also involves folder permissions throughout the directory tree.
Are there superset/subset relations between the sets of permissions of user owner, work group and other for a file?
1,482,988,715,000
I'm confused by "permission denied" despite apparently having correct permissions to /dev/bus/usb/005/017. This is similar to this question, but I have already tried restarting my ssh session. $ sudo ls -la /dev/bus/usb/005/ total 0 drw-rw-rw- 2 root root 120 Dec 25 12:40 . drw-rw-rw- 7 root root 140 Apr 20 2010 .. crw-rw-rw- 1 root root 189, 512 Dec 25 12:20 001 crw-rw-rw- 1 root root 189, 515 Dec 25 12:20 004 crw-rw-rw- 1 root root 189, 516 Dec 25 12:20 005 crw-rw-rw- 1 root adb 189, 528 Dec 25 12:40 017 #adb group, g+rw $ groups ealfonso ealfonso : ealfonso cdrom floppy audio dip video plugdev netdev scanner bluetooth adb # I am in adb group $ ls -la /dev/bus/usb/005/017 ls: cannot access /dev/bus/usb/005/017: Permission denied $ sudo chown ealfonso:ealfonso /dev/bus/usb/005/017 $ sudo ls -l /dev/bus/usb/005/017 crw-rw-rw- 1 ealfonso ealfonso 189, 528 Dec 25 12:40 /dev/bus/usb/005/017 #owned by ealfonso $ ls /dev/bus/usb/005/017 ls: cannot access /dev/bus/usb/005/017: Permission denied What am I missing? Edit: adding output of ls -ld as requested: $ sudo ls -lad /dev/bus/usb/005 drw-rw-rw- 2 root root 120 Dec 25 12:40 /dev/bus/usb/005 #missing a+x $ sudo chmod a+x /dev/bus/usb/005 # add a+x $ ls -la /dev/bus/usb/005/017 # still denied ls: cannot access /dev/bus/usb/005/017: Permission denied $ sudo ls -lad /dev/bus/usb/005 drwxrwxrwx 2 root ealfonso 120 Dec 25 12:40 /dev/bus/usb/005 Edit. As pointed out in the comments, /dev/bus/usb was also missing x permissions $ ls /dev/bus/usb -l ls: cannot access /dev/bus/usb/005: Permission denied ls: cannot access /dev/bus/usb/004: Permission denied ls: cannot access /dev/bus/usb/003: Permission denied ls: cannot access /dev/bus/usb/002: Permission denied ls: cannot access /dev/bus/usb/001: Permission denied total 0 d????????? ? ? ? ? ? 001 d????????? ? ? ? ? ? 002 d????????? ? ? ? ? ? 003 d????????? ? ? ? ? ? 004 d????????? ? ? ? ? ? 005 $ sudo ls /dev/bus/usb -l total 0 drw-rw-rw- 2 root root 60 Apr 20 2010 001 drw-rw-rw- 2 root root 80 Apr 20 2010 002 drw-rw-rw- 2 root root 60 Apr 20 2010 003 drw-rw-rw- 2 root root 60 Apr 20 2010 004 drwxrwxrwx 2 root ealfonso 120 Dec 25 12:40 005 $ sudo chmod a+x /dev/bus/usb $ ls -la /dev/bus/usb/005/017 crw-rw-rw- 1 root ealfonso 189, 528 Dec 25 13:43 /dev/bus/usb/005/017
Here's part of your output: ls -la /dev/bus/usb/005/017 ls: cannot access /dev/bus/usb/005/017: Permission denied Hint: you can always stat a file as long as you can get to it (via the directory that contains it), even if you don't have permission to it. So with this, I suspected that your problem was not actually with /dev/bus/usb/005/017 itself. Getting access to the file in order to be able to stat it is a matter of having x (execute) access to all the directories in the pathname. That is, / /dev /dev/bus /dev/bus/usb /dev/bus/usb/005 One or more of those directories must be missing x permission. But probably not / or /dev as your system would probably be unusable if the problem lay there. Note that any or all of those directories may have r access, allowing you to see what files they contain but not get at those files. Why were your /dev/bus/usb/005 and /dev/bus/usb missing x permission? Those directories will have been created when udev first created the device nodes and their parent directories. Perhaps the umask on the udev daemon is too strict? I'm not really sure why that would be on your system. For correct operation, none of the octal digits in the umask should be odd. Note that the problem might be with the udevd started at early boot time in the initramfs.
permission denied /dev/bus/usb/
1,482,988,715,000
I'm setting up limited accounts on my arch linux build to run proprietary software such as games or windows binaries. These restricted accounts won't have read/write access in my personal folders or any other areas in my OS that I've deemed sensitive. I'd be using the following command to run applications as a limited user: bash -c 'xhost +local:steam;sudo -u steam -H steam /home/limited.users/steam' This would of course require that I input my sudo password every time I launch something as a restricted users. Trying to find a way around having to put that password all the time, I ended up coming across this article that was trying to do the exact same things as I was: How to run Spotify and Wine under a separate user account In a section called Permit your own user account to launch commands under the wine account, he suggest to edit visudo and add the following line at the end: his exmaple: bob ALL=(wine) NOPASSWD: ALL more generically: yourUSERname ALL=(theACCOUNTyourTRYINGrunUNDER) NOPASSWD: ALL The prospect of being able to run apps as another user with less privileges than my own account without a PW is harmless to me. That being said, I don't have a very thorough understanding of visudo and I wanted to know if this line will do anything other than that?
Try bob ALL=(wine) NOPASSWD: /home/limited.users/steam the key point is you can replace ALL by a comma separated list of command allowed. Note that if there are other entries for bob without NOPASSWD, the rules without NOPASSWD may need to come first.
Security ramification of using this line in visudo: yourUSERname ALL=(otherUSERaccount) NOPASSWD: ALL
1,482,988,715,000
I have a directory owned by root, after I copy files into it. All exe files can only be run as root. But I would like everyone to be able to run it. Surely, I can use chmod -R u=rwX,g=rX,o=rX every time after I add new files into it. However, this is very annoying. Is there any thing I can set in the directory to automatically allow all users to run the exe?
Using umask 0022 before making the copy, you will get all new files with -rw-r--r-- permissions by default, but files can be made executable only invoking directly chmod +x on them. You can use the abbreviated command: chmod -R a+rX directory to do it manually. To automatically set all file permissions you can use inotifywait like that: inotifywait -qm <directory> -e create -e moved_to -e modify \ | while read a b c; do chmod a+rX "${a}${c}"; done
set all executable files executable by all users but leave un-executable file non-executable?
1,482,988,715,000
Fedora doesn't boot anymore, so I need to make a backup of my data before running boot-repair. The thing is: I can't acess my fedora-personal files from boot-repair as I don't have permission. How can I make a backup of them then?
From your live CD, try to log in as root in order to copy the data. Or use su/sudo su in a terminal window.
How can I make a backup of data I don't have permission for?
1,482,988,715,000
I have the following folder: $ ls -ahl /mnt/smrtanalysis/ total 16K drwxr-xr-x 4 smrtanalysis smrtanalysis 4.0K Jul 25 01:52 . drwxr-xr-x 6 root root 4.0K Jul 25 01:46 .. lrwxrwxrwx 1 smrtanalysis smrtanalysis 13 Jul 25 01:52 admin -> current/admin lrwxrwxrwx 1 smrtanalysis smrtanalysis 33 Jul 25 01:48 current -> install/smrtanalysis_2.3.0.140936 drwxrwxr-x 4 smrtanalysis smrtanalysis 4.0K Jul 25 01:48 install lrwxrwxrwx 1 smrtanalysis smrtanalysis 16 Jul 25 01:52 smrtcmds -> current/smrtcmds lrwxrwxrwx 1 smrtanalysis smrtanalysis 17 Jul 25 01:52 tmpdir -> /tmp/smrtanalysis drwxrwxr-x 13 smrtanalysis smrtanalysis 4.0K Jul 25 01:52 user data and I would like as user (ubuntu) to be able to write to it: ubuntu@waterhouse-1:~$ groups ubuntu smrtanalysis ubuntu user is in group smrtanalysis, but I still not able to write into /mnt/smrtanalysis/ What did I do wrong?
You have 755 (rwxr-xr-x) on the dir /mnt/smrtanalysis/, shown as . in the ls output, with owner:group of smrtanalysis:smrtanalysis. ubuntu is part of group smrtanalysis but group only has r-x you need to sudo chmod g+w /mnt/smrtanalysis/ to give the group write access.
write permission to a folder
1,482,988,715,000
Will it be safe to enable logging into a write-only log file on a production server? I imagine, that this would protect the log file from unwanted eyes. Are there any drawbacks of using this technique?
Logs should be write-only if they contain potentially confidential data. Obviously they can only be write-only to the application that produces the log and other applications running on the server, and perhaps even to the logging subsystem (once written to the log files), but system administrators and auditors should be able to read them. The most important thing for a log file is integrity. Being write-only doesn't help with integrity. If you can, make the log file append-only (e.g. chattr +a /path/to/log under Linux) — but this may not be practical since only root can do this and it needs to be done on each log rotation. Better yet, log on a separate server which does nothing else (and even then, having a non-readable append-only log file does add a bit of redundancy to the security).
Is granting write-only permission on log files to certain users a good practice?
1,482,988,715,000
I am currently preparing for LPIC Level 1 exam and I have been practicing management of user accounts on CentOS 7 system installed on VirtualBox. Firstly, as root, I created a user 'foo' with group 'bar' and practiced changing file permissions. Then I created a new group 'somegroup' and added user 'foo' to it. Then I removed user 'foo' from group 'bar'. (Kindly note that I used 'groupmems' command for this.) Then I logged into foo's account and used 'touch' command for creating a file in foo's ~/Documents directory and then checked its file permissions with 'ls -l' command. I was expecting that the new file would show file ownership as belonging to 'foo somegroup' but strangely I found that the group ownership was still with group 'bar'. Clearly I'm missing some basic knowledge here. Please help me in understanding this. (I'm sorry if I've been a bit too verbose.)
That's because the parent directory belongs to the old group. On many systems files and directories's default group owner is their parent directory. If you want that to stop, you have to change the group owner of the parent directory. Then you can change the group owner of all its child directories using: chgrp -R desiredgroup parentdirectory The -R option makes it apply to all its children.
Files are created with old group ownership even though the creator doesn't belong to old group anymore
1,482,988,715,000
I have a folder myfolder with lots of files and directories as follows: -rwxrwx--x user1 user1 . -rwxrwx--x root root .. -rw-rw---- user1 user1 file1 -rw-rw---- user1 user1 file2 -rwxrwx--x user1 user1 dir1 I'd like to have a user: master who is able to remove all the files and folders. Be able to do: rm -fr myfolder/* Doing the following does not solve the problem: chown user1:master myfolder Because the user don't have write permissions in the subfolders. The subfolders are written by user1 randomly. I can't change the permissions / owners of those files in a one time operation. If I do that user1 won't be able to create/edit files anymore. What do you recommend?
I would suggest to use ACLs, i.e., something like setfacl -R -m u:master:rwX -m d:u:master:rwX ./myfolder, where especially the second part d:u:master:rwX is relevant here since it means that any new files created in the myfolder directory will get rwX permissions for the user master.
Permissions to remove all files in subdirectory
1,482,988,715,000
avrdude is a simple tool that allows downloading of a program to a target microcontroller. For completeness, the command I am trying to issue is: avrdude -p atmega328p -c usbtiny -P usb -v -U -flash:w:program.hex Every time I issue this command I am subjected the error 'Operation not permitted" and am required to sudo avrdude .. in order to get it to work. I found it strange it was necessary to do this, so I dove into the problem a bit more. The programmer I am using mounts itself at /dev/ttyUSB0 and is part of the dialout group. Further, this device has permissions such that any user in the dialout group shall be able to write to the device, which is what the command above does. crw-rw---- 1 root dialout 188, 0 Jul 15 02:04 ttyUSB0 Despite rootowning the device, simply adding myself to the dialout group seemed to be sufficient to allow myself to use the device. After doing this, I still was met with the error "Operation not permitted". I thought, then, that perhaps the avrdude program itself was the problem. After finding the binary in /usr/bin it was clear that this was not an issue given the permissions of the file. -rwxr-xr-x 1 root root 413888 Oct 21 2013 avrdude tl;dr I am part of the appropriate group and the files have permissions that should allow me to use them, yet I am still unable to without first elevating myself.
Low-level control of USB devices is done via /dev/bus/usb, and you need to set the right permissions on the device there. The way to do that is with a udev rule: Create a file (such as /etc/udev/rules.d/52_local-usbtiny.rules) with: SUBSYSTEM=="usb", ATTR{idVendor}=="1781", ATTR{idProduct}=="0c9f", MODE="664", GROUP="plugdev" That sets the group to plugdev; you could use USER="your-user-name" instead to set the owner. Then reload udev (e.g., service udev force-reload or systemctl reload udev). Next time you unplug/replug the programmer, the new permissions should take effect.
Unable to execute program without root privileges regardless of group or permissions
1,482,988,715,000
I'm working in Ubuntu 3.13. The permissions on a drive are such that the owner can see directories and files with these permissions: drwxrwxr-x 2 michael atlas 4096 Feb 15 12:34 temp2 drwxrwxr-x 2 michael atlas 12288 Mar 18 16:14 temp3 while another member (ubuntu) of the group 'atlas' sees this: d????????? ? ? ? ? ? temp2 d????????? ? ? ? ? ? temp3 unless ubuntu uses sudo ls -l, then the owner, group, and permissions look the same as when michael does an ls -l. Here it can be seen the two users are in the same group: ubuntu@lincloud:~$ grep '^atlas' /etc/group atlas:x:1001:ubuntu,michael What is the cause of the problem? How do I fix it?
The parent directory of temp2 and temp3 is where the issue lies. Your atlas group has read permissions on the parent directory and you need read AND execute in order to see the files and their permissions. if you're in the directory with temp2 and temp3 you can fix the issue with the following command: sudo chmod g+x .
User cannot see directory permissions
1,482,988,715,000
If I store a file in ext2, ext3, or ext4 formatted partition, it's permission is saved. I mean, I can have different permissions for different files in extX partition. However, If I store a file in NTFS partition, I can't change it's permission. The permission is depends on how NTFS partition is mounted. For example, with nautilus, all file permissions will be rwxrwxrwx. It can bring some problems if I backed up some files that need different permissions from extX to NTFS. Two files with rw------- and rw-r--r-- permissions will have rwxrwxrwx permissions if stored in NTFS. My points here is (which basically one point in the title): Where is the information about file permission stored? If it stored in OS configuration, how can I get exactly the same permission if I reinstall the OS. If it stored in the file it self, does it means file state is changed when copying from extX to NTFS and vice versa? If I have a lot of files with different permissions, then copy all of them to NTFS. Is it possible to get back the exact permissions for all file if I copy all of them back to extX? Is it possible to have different file permissions in NTFS?
The permissions are stored in file system metadata. NTFS and ext3/4 file systems differ substantially in how they store metadata. One solution would be to create a tar file of the source directory (with or without compression), writing the resulting file to the NTFS file system. When the content of the tar archive is extracted to a ext3/4 file system the permissions and ownership are preserved. For example: tar cvf /mnt/ntfs_share/archive.tar /source_ext4/* Or, with bzip2 compression: tar cjvf /mnt/ntfs_share/archive.tar.bz2 /source_ext4/*
How do file permissions work with partition filesystem?
1,482,988,715,000
Let's say I chmod 1777 a folder /opt/test and all files inside it as user user1. Hence user2 is able to update and edit files inside the /opt/test directory. When user2 operates via sudo, he's able to delete any file from the directory, even those he does not own; is this normal? If yes, what is the purpose of setting the sticky bit? When another user user3 operating without sudo tries to delete a file he does not own, he gets a "permission denied" error. Note: All users belong to the default group.
When sticky bit is set, only the file's owner, the directory's owner, or root can rename or delete the file. The sudo command is there to enable a user to impersonate another user, including root. When user2 issues a command through sudo to become root, he's getting root's permissions, and root always has all permissions on the system.
Sticky bit and users with sudo permission
1,482,988,715,000
I have a Debian Wheezy 7 installation. When I turn it on it boots to the log in screen normally. However when I type in my username/password and try to login the screen briefly turns off for about one second and returns to the log in screen. I cannot log in. I have made no changes to the system other than an owner/permissions change I made to the "/tmp" folder. If anyone can help it will be greatly appreciated! Please help.
Starting a graphical session requires the creation of files in the /tmp directory. If your user no longer has write permission to that directory, graphical logins will fail. To see that this is the issue, switch to a virtual terminal (press Ctrl+Alt+F2) and log in normally. If the changed permissions on /tmp are the reason, your log in should succeed. To remedy the situation, log in from the virtual terminal as root and issue the command: chmod 1777 /tmp This should return the permissions to the default case and allow you to log in normally (to switch back to graphical screen after switching to the VT, press Ctrl+Alt+F7) This often happens if you extract an archive in the /tmp directory as the root user.
Cannot log in to my Debian Wheezy 7 system
1,482,988,715,000
Script is on exec partition (under /home/~~~ ) and have +x flag (-rwxr-xr-x ). executable on bash shell (not with script) but not on script. script is quite simple. #!/bin/bash data=cat $PWD/.git/config | awk '{for(i=1;i<NF;i++)if($i~"merge")print$(i+2)}' echo data : $data result : /home001/myaccount/uploader.sh: line 3: /home001/myaccount/mydirectory/.git/config: Permission denied target file's permission is symbolic and 777 like below. lrwxrwxrwx But executable and working well at bash command line. myaccount@myserver:~/mydirectory$ cat $PWD/.git/config|awk '{for(i=1;i<NF;i++)if($i~"merge")print$(i+2)}' mybranch Script has +x flag and on executable partition. Also executable without script but not on script. Why?
The problem is in this line: data=cat $PWD/.git/config This temporarily sets the shell variable data to have the value cat and then attempts to execute the file $PWD/.git/config. That is unfortunate because you probably didn't want to execute it. You likely intended: data=$(cat $PWD/.git/config | awk '{for(i=1;i<NF;i++)if($i~"merge")print$(i+2)}') The above will run your cat command, sending its output to awk and saving awk's output in the variable data. If this is what you wanted, then the cat is superfluous. Replace the above with: data=$(awk '{for(i=1;i<NF;i++)if($i~"merge")print$(i+2)}' $PWD/.git/config) Interpreting the error message /home001/myaccount/uploader.sh: line 3: /home001/myaccount/mydirectory/.git/config: Permission denied From the above, we know that uploader.sh was executing. This means that there was no problem with the permissions of uploader.sh. The error occurs on line 3 of uploader.sh which is the command: data=cat $PWD/.git/config | awk '{for(i=1;i<NF;i++)if($i~"merge")print$(i+2)}' The Permission denied error occurred while the shell was attempting to execute this line.
permission denied on running script despite +x
1,482,988,715,000
I have an application that I want to be able to change the hostname in Linux. Currently doing so by running the hostname command. I don't want to set CAP_SYS_ADMIN either. I also don't want to edit /etc/hostname and reboot. Is there a capability that only just allows changing the hostname? If not what are my options?
Setting the hostname in linux is done via the sethostname(2) syscall. And /bin/hostname is a bare wrapper around this syscall (and a few related syscalls). /etc/hostname is supposed to be read during the boot process by some script, who subsequently runs /bin/hostname to complish its job. CAP_SYS_ADMIN is one of linux capabilities(7), allows a thread to perform various system administration operations, which include sethostname. I'm not aware of a smaller ganularity within the capabilities framework. However there are other options. We can grant some user ability to run some command as another user, by sudo(8), in a customisable manner. This example sudoers(5) configuration will allow user alice to run /bin/hostname as root. alice ALL=(root:ALL) /bin/hostname As described in this superuser question, the first "ALL" can be replaced by the hosts where the command is run on, not of use unless in a cooperative environment. "root" can be replaced by "ALL" to allow alice to run as any user. Second "ALL" can be replaced by the groups. The last field is commands alice is allowed to run. As /bin/hostname has limited usage, I guess it is fine. Otherwise we may have it followed by an argument, thus alice cannot run the command without this argument, to restrain the power.
Set hostname without root, and without CAP_SYS_ADMIN
1,482,988,715,000
I need to make files in a directory invisible to everyone. Through invisible I mean that the file must not show up when I use the find * command. My efforts: I was thinking of using the chmod command but was not able to find a particular permission that may serve my task.
You must remove the read permission on the directory for the other users e.g. by chmod 700 dirname You cannot allow access to a directory and hide just some of the files it contains.
Make files in a directory not visible to anyone
1,482,988,715,000
Hi I am wondering what is the difference between the two sets of commands below: 1) To allow Davis to access and modify all files and folders in the the home directory of John # setfacl -m u:davis:rwx:/home/john # setfacl -m d:u:davis:rwx:/home/john 2) To allow Davis to access the home directory of John and all recursive files and folders. # setfacl -R -m u:davis:rwx:/home/john
First command gives rights to davis on the directory itself, the second one sets the default ACL entry for new files that get created. The last one sets all files and directories to give davis rwx access. TBH if you're going to do the last command, the first one seems a little redundant since recursive setfacl's also hit the directory you give it.
What is the difference between these two sets of command for configuring ACL permissions?
1,482,988,715,000
I have an old version of cabal-install so I downloaded cabal-install 1.20 and When installing it errors out. Additional note: ghc 7.8.3 OS: CentOS 6.6 Error: Building network-2.4.2.3... ....... ...... ...... usr/bin/ld: cannot find -lHSparsec-3.1.7-ghc7.8.3 collect2: ld returned 1 exit status error during cabal-install bootstrap: building the network package failed. When I try to run "cabal install network-2.5.0.0",getting following errors root@gains: cabal install network-2.5.0.0 Resolving dependencies... Configuring network-2.5.0.0... configure: WARNING: unrecognized options: --with-compiler, --with-gcc checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configure: error: in `/tmp/network-2.5.0.023068/network-2.5.0.0': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details cabal: Error: some packages failed to install: network-2.5.0.0 failed during the configure step. The exception was: ExitFailure 1
Error : checking whether we are cross compiling... configure: error: in `/tmp/network-2.5.0.023068/network-2.5.0.0': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details So, I run command yum groupinstall "development tools", installed c compiler tools and could compile c programs. Then, checking whether we are cross compiling... configure: error: in /tmp/network-2.5.0.023068/network-2.5.0.0': I tried mount -o remount,exec,suid /tmp which solved the error.Its because of execution rights issue on the file system.
Cabal error: Cannot run c compiled programs
1,482,988,715,000
I cannot enter a directory after creation in a folder with an ACL: I am attempting to limit rwx access to a folder for just a single group and no one else. I would like to be able to add new users to a group and have them gain access to a directory. This is what I have done so far mkdir /mnt/files cp /media/usb0/backup/* /mnt/files chgrp filers /mnt/files chmod -R g+s /mnt/files setfacl -b /mnt/files # to remove user and other setfacl -R -d -m g:filers:rwx /mnt/files getfacl /mnt/files # file: mnt/files/ # owner: root # group: filers user::--- group::rwx other::--- default:user::--- default:group::rwx default:group:filers:rwx default:mask::rwx default:other::--- So far everything looks good . . . cd /mnt/files mkdir test ls -l d---rws---+ 2 jimmy filers 4096 Nov 28 14:32 test cd test -bash: cd: test/: Permission denied Any reason I can't enter the folder I just created? getfacl ./test # file: test # owner: jimmy # group: filers # flags: -s- user::--- group::rwx group:filers:rwx mask::rwx other::--- default:user::--- default:group::rwx default:group:filers:rwx default:mask::rwx default:other::---
Any particular reason why owner doesn't have full permissions? Owner's permissions take precedence. As a root, you can do anything, but as a regular user if you remove rwx for a directory you own, you cannot enter it since you don't have a search bit (x). It does not matter that you are in a group that have permissions. Right know, user jimmy cannot enter his directory, but paradoxically just about any other user in a group filers can. I'd say step 6 should be setfacl -R -d -m u::rwx,g:filers:rwx /mnt/files
User cannot access a file after setting an ACL [duplicate]
1,482,988,715,000
What permissions should each file under .ssh have? I just experienced some glitch caused by .ssh/config not having 600. What permissions other files there should have?
From man ssh_config: ~/.ssh/config This is the per-user configuration file. The format of this file is described above. This file is used by the SSH client. Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not accessible by others. Your private keys and your authorized_keys file should have the same (600) but your public keys can have a more permissive 644.
What permissions should each file under .ssh have?
1,482,988,715,000
I am writing a program for a DISA STIG version of Red Hat Linux 6.5. I wrote a shell script to do self extracting on the program and when it self extracts put temporary files in the tmp directory that will later be moved around and deleted. The permissions for the temporary directory look like such when I run ls -l. drwxrwxrwt. 4 root root 4096 Sep 25 10:14 tmp. However when I run my script to install my program I keep egtting the following output Verifying archive integrity... All good. Uncompressing installation package................................... ./foo.run: line 391: ./tmp/foo/install.sh: Permission denied line 391 is as follows, eval $script $scriptargs $*; res=$? with script="./tmp/foo/install.sh" and scriptargs="". Does anyone know if it is the STIG guidelines that may be causing this issue or something that I am doing?
One thing to be aware, is that STIG locks down /tmp with noexec. If you already spent some time on the box, it's possible that you won't be able to execute the files out of that folder. Try another location for download/install. Also, run your installer as SUDO
Permission denied tmp dir on STIG RHEL
1,482,988,715,000
I've got a unix user "popolo" who is chrooted in /srv/ftp/ and I mount my two external drives by /etc/fstab in /srv/ftp so I have /srv/stp/dude and /srv/ftp/sweet. Popolo has access to those drives by sftp. In dude/ I've several directories: dude/music, dude/photos, dude/movies, and for some of them (like photos) I don't want that popolo can access to them. Is using /etc/fstab and a user chrooted via sftp is the best way to do this ? How can I restrict access to some directories ?
Use normal Linux/Unix permissions on your dude/photos to make sure that popolo can't access them. Assuming that popolo isn't the owner of those files and directories and isn't in the group, then a simple chmod -R o-rwx dude/photos should make sure that popolo can't access those files. Or: An alternative way would be to give popolo and empty chroot home and bind mount all the directories that you want that user to access into that empty chroot. Assuming (again) that popolo's chroot home is now /home/popolo then: mkdir /home/popolo/music /home/popolo/movies mount --bind /srv/ftp/dude/music /home/popolo/music mount --bind /srv/ftp/dude/movies /home/popolo/movies As you haven't bind mounted your dude/photos directory, popolo won't have access to them.
Limit access on external drive mounted and used by sftp
1,482,988,715,000
I'm trying to run a script as another user that starts a piece of software (Etherpad), which is run like so (from root): su -c "/var/www/etherpad-lite/bin/run.sh" -s /bin/bash etherpad but I'm getting the following error: bash: /var/www/etherpad-lite/bin/run.sh: Permission denied This had previously worked perfectly, and only stopped working after I installed a bunch of things for another project I'm working on, none of which should have affected etherpad. /var/log/auth.log shows this: Aug 12 19:59:21 bhs1 su[7289]: Successful su for etherpad by root Aug 12 19:59:21 bhs1 su[7289]: + /dev/pts/1 root:etherpad Aug 12 19:59:21 bhs1 su[7289]: pam_unix(su:session): session opened for user etherpad by root(uid=0) Aug 12 19:59:21 bhs1 su[7289]: pam_unix(su:session): session closed for user etherpad I've done some searching and I found a couple of things that could cause this, but none are relevant to my problem: The file is chmodded to 777 (-rwxrwxrwx) and it's owned by the etherpad user. I only changed it to 777 to make sure it wasn't a permissions issue, it was something like 700 before. The file system doesn't have noexec enabled I'm running Debian 7.6 on a dedicated server.
You can have run.sh with "read by all" privilegs, but if e.g. /var/www/ is with privilegs "read only by root" you will get "permission denied" error message. check permissions of all directories in the path /var/ /var/www/ /var/www/etherpad-lite/ /var/www/etherpad-lite/bin/
Permission denied when trying to run script as other user
1,401,435,560,000
I have these permissions on a file: -rw-r----- 1 root www-data 540 Mar 18 21:12 /etc/phpmyadmin/config-db.php User vagrant is a member of group www-data: vagrant@precise64:~$ cat /etc/group | grep www-data www-data:x:33:vagrant Why can't I read the file as vagrant? vagrant@precise64:~$ cat /etc/phpmyadmin/config-db.php cat: /etc/phpmyadmin/config-db.php: Permission denied
Log in again to make the current group membership configuration active. After a process has been created its group membership does not change (at least not by making changes in the account management).
Not allowed to read a file for some reason
1,401,435,560,000
What happened to the "Primary Administrator" profile in Solaris 11? Why was it cut? Are there any alternatives? How does it differ from the root-role (which is profiles=All;auths=solaris.*) Is the less powerful "System Administrator" better? Why? Reason to use/not use either/both? On my system, I "re-created" it by adding entries in /etc/security/prof_attr.d and /etc/security/exec_attr.d... However Solaris 11 lacks the solaris.grant (auths=solaris.all,solaris.grant;exec=uid=0,gid=0)... Is grant no longer needed? Are there alternatives?
This profile was removed for granting unlimited privileges while not requiring a password. The alternative is simply to use sudo.
What happened to Primary Administrator profile in Solaris 11?
1,401,435,560,000
Trying out Linode for the first time, running an Arch Linux image, I successfully installed nginx as root. This, however, made /usr/share/nginx/html inaccessible to non-root users. Intuitively, I thought this would work: newgrp www (create a new group) chgrp -R www /usr/share/nginx/html (associate directory recursively with new group) chmod -R g=rw /usr/share/nginx/html (give read-write permissions to new group) usermod -a -G www john.doe (add non-root user to new group) However, I still could not write files to /usr/share/nginx/html as john.doe. I also tried chown -R :www /usr/share/nginx/html to see if it had any effect—it didn't. Here's what the setup looks like currently: [john.doe@hydrogen nginx]$ ls -l total 4 drwxrw-r-x 4 root www 4096 Dec 19 08:10 html [john.doe@hydrogen nginx]$ id uid=1000(john.doe) gid=100(users) groups=100(users),10(wheel) [john.doe@hydrogen nginx]$ groups john.doe wheel www users What am I misunderstanding / missing that I can't write to this directory?
Add the Execute bit to your directories. As it stands, john.doe can write and read files in the directory but can't see the files in the directory. You can see this is true by having john.doe edit a file using a path that is inside the directory.
Granting permission for all users in a group to write to a directory and all its subdirectories
1,401,435,560,000
I want to read some configuration file. The problem is that I can't move in the folder peers and typing the command ls -l, I see this permission's record: drwxr-s--- root dip ... I never seen that s, and reading on the web now I know that's the gid bit. Also the name of the group is unusual, normally I read root here. When I try: sudo cd ./peers I get an error because the cd command is not found. Why can't I move in this directory as super user? How can I resolve this?
You can enter the shell as root using sudo su Then you'll be able to cd /etc/ppp/peers Alternatively you could just sudo ls -l /etc/ppp/peers
Can't access the directory /etc/ppp/peers?
1,401,435,560,000
I'm having difficulty with groups and permissions. I have user A part of group A that manages a folder F. A second user B part of group B must access folder F and its content. I added user B to group A but every time B tries to access folder F gets the message saying: 'Permission Denied'. Is this the correct way to achieve that or do I need to do something more? I'm using CentOS 6.4.
What are the permissions, ownership, and groups for folder F? These need to be set such that group A is set as the group on the folder, and the permissions need to allow members of group A access to the folder. Example $ ls -ld F drwxrwxr-x 2 saml blah 4096 Nov 28 08:38 F In the above example, directory F, notice that the group blah is set, and that the permissions are rwx for the group. This would allow any members of that group access to this directory. Fixes If the above isn't the case then you can adjust the permissions like so: $ chmod g+rwx F To change ownership: $ chgrp blah F
Accessing other folder
1,401,435,560,000
How is it possible to make a folder under $HOME accessible to other users? I thought that's the case why we have softlinks but apparently I am missing some bits here. Can someone please shed a light on that? Details: User Hadoop runs hadoop installaion and that contain bin folder with awailable commands to execute. [hadoop@A1n1 hadoop-1.0.4]$ ls -al total 7648 drwxr-xr-x. 14 hadoop hadoop 4096 Apr 22 2013 . drwx------. 11 hadoop hadoop 4096 Oct 30 13:51 .. drwxr-xr-x. 2 hadoop hadoop 4096 Feb 27 2013 bin [hadoop@A1n1 bin]$ ls -al total 152 drwxr-xr-x. 2 hadoop hadoop 4096 Feb 27 2013 . drwxr-xr-x. 14 hadoop hadoop 4096 Apr 22 2013 .. -rwxr-xr-x. 1 hadoop hadoop 14137 Oct 3 2012 hadoop -rwxr-xr-x. 1 hadoop hadoop 2642 Oct 3 2012 hadoop-config.sh I created a softlink pointing to bin folder: [root@A1n1 /usr/local]# ls -l total 44 drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin lrwxrwxrwx. 1 root root 29 Nov 1 08:16 hadoop.bin -> /home/hadoop/hadoop-1.0.4/bin However when I switch to a different user and try to execute a command I get permission denied: [bdst@A1n1 local]$ cd /usr/local/hadoop.bin bash: cd: /usr/local/hadoop.bin: Permission denied I am not sure what I am missing here as to me it seems that file permissions should be ok.
A symbolic link does not circumvent permissions of the original directory/file. As with direct access you need execute (x) permission on all directories in the path of the original and on the original directory itself. The x is missing on /home/hadoop for others.
How to make accessible folder/file to other user
1,401,435,560,000
All of a sudden, I couldn't ssh to a machine to which I used to ssh earlier. Consider I am ssh-ing from A to B. Output when I run ssh root@ip_addr_of_B I get: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). Output when I run ssh -vv root@ip_addr_of_B from A OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to 64.103.232.105 [64.103.232.105] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/identity type -1 debug2: key_type_from_name: unknown key type '-----BEGIN' debug2: key_type_from_name: unknown key type '-----END' debug1: identity file /root/.ssh/id_rsa type 1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.3 debug2: fd 3 setting O_NONBLOCK debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: none,[email protected],zlib debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: mac_setup: found hmac-md5 debug1: kex: server->client aes128-ctr hmac-md5 none debug2: mac_setup: found hmac-md5 debug1: kex: client->server aes128-ctr hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug2: dh_gen_key: priv key bits set: 124/256 debug2: bits set: 523/1024 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host '64.103.232.105' is known and matches the RSA host key. debug1: Found key in /root/.ssh/known_hosts:3 debug2: bits set: 522/1024 debug1: ssh_rsa_verify: signature correct debug2: kex_derive_keys debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /root/.ssh/identity ((nil)) debug2: key: /root/.ssh/id_rsa (0x7f972bb77030) debug2: key: /root/.ssh/id_dsa ((nil)) debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic debug1: Next authentication method: gssapi-keyex debug1: No valid Key exchange context debug2: we did not send a packet, disable method debug1: Next authentication method: gssapi-with-mic debug1: An invalid name was supplied Cannot determine realm for numeric host address debug1: An invalid name was supplied Cannot determine realm for numeric host address debug1: An invalid name was supplied debug1: An invalid name was supplied debug2: we did not send a packet, disable method debug1: Next authentication method: publickey debug1: Trying private key: /root/.ssh/identity debug1: Offering public key: /root/.ssh/id_rsa debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic debug1: Trying private key: /root/.ssh/id_dsa debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (publickey,gssapi-keyex,gssapi-with-mic). Below is the sshd_config file of B. # $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options change a # default value. Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: # Disable legacy (protocol version 1) support in the server for new # installations. In future the default will change to require explicit # activation of protocol 1 Protocol 2 # HostKey for protocol version 1 #HostKey /etc/ssh/ssh_host_key # HostKeys for protocol version 2 #HostKey /etc/ssh/ssh_host_rsa_key #HostKey /etc/ssh/ssh_host_dsa_key # Lifetime and size of ephemeral version 1 server key #KeyRegenerationInterval 1h #ServerKeyBits 1024 # Logging # obsoletes QuietMode and FascistLogging #SyslogFacility AUTH SyslogFacility AUTHPRIV #LogLevel INFO # Authentication: #LoginGraceTime 2m #PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #RSAAuthentication yes #PubkeyAuthentication yes #AuthorizedKeysFile .ssh/authorized_keys #AuthorizedKeysCommand none #AuthorizedKeysCommandRunAs nobody # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts #RhostsRSAAuthentication no # similar for protocol version 2 #HostbasedAuthentication no # Change to yes if you don't trust ~/.ssh/known_hosts for # RhostsRSAAuthentication and HostbasedAuthentication #IgnoreUserKnownHosts no # Don't read the user's ~/.rhosts and ~/.shosts files #IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no PasswordAuthentication no # Change to no to disable s/key passwords #ChallengeResponseAuthentication yes ChallengeResponseAuthentication no # Kerberos options #KerberosAuthentication no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes #KerberosGetAFSToken no #KerberosUseKuserok yes # GSSAPI options #GSSAPIAuthentication no GSSAPIAuthentication yes #GSSAPICleanupCredentials yes GSSAPICleanupCredentials yes #GSSAPIStrictAcceptorCheck yes #GSSAPIKeyExchange no # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'. #UsePAM no UsePAM yes # Accept locale-related environment variables AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE AcceptEnv XMODIFIERS #AllowAgentForwarding yes #AllowTcpForwarding yes #GatewayPorts no #X11Forwarding no X11Forwarding yes #X11DisplayOffset 10 #X11UseLocalhost yes #PrintMotd yes #PrintLastLog yes #TCPKeepAlive yes #UseLogin no #UsePrivilegeSeparation yes #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 #ClientAliveCountMax 3 #ShowPatchLevel no #UseDNS yes #PidFile /var/run/sshd.pid #MaxStartups 10 #PermitTunnel no #ChrootDirectory none # no default banner path #Banner none # override default of no subsystems Subsystem sftp /usr/libexec/openssh/sftp-server # Example of overriding settings on a per-user basis #Match User anoncvs # X11Forwarding no # AllowTcpForwarding no # ForceCommand cvs server /var/log/secure of B contains just this one line server sshd: connection closed by ip_addr_of_A I can ssh from B to A. Issue happens only when I ssh from A to B. Also, I can ssh from A to any machine other than B.
Obviously you disabled password authentication, you don't have ssh keys and kerberos is not configured. Either login locally or login via serial console, or via KVM or if you have server-class machine then it should have a management interface (BMC) allowing remote access to local serial port or making graphical console redirection. Out of that, you are out of luck.
Can't ssh to a machine
1,401,435,560,000
I added a user to my Mint (Ubuntu) Desktop so that he could ftp files that I can share – I am peter he is john, so we have /home/peter and /home/john. I want to have full permissions on his home share, so I can copy files to and from the shared drive but not give him access to my home directory. I assumed that I could add myself to the john group would be enough (no) I have tried various options with no success (Brute force I can sudo cp to my home directory then change ownership)
You need to add both users to a common group, then give that group full access to the shared folder. Some systems have a users group for this purpose, so: $ sudo install -d -m 770 -g users /var/ftp/pub/shared That creates a folder underneath the standard location for the FTP daemon's /pub directory that any member of group users can write to. (Your FTP setup might have a different parent path. I haven't actually tried this on Mint to check it. Check your FTP daemon's configuration.) Then you just need to add both peter and john to that users group: $ sudo usermod -a -G users peter $ sudo usermod -a -G users john
permission on a user I added locally
1,401,435,560,000
I need a PHP script to perform git pull however I am not naive enough to give it permissions on git. I've wrapped git pull in a script which www-data has permissions for, but I'm not sure how to give the script permissions on git itself: $ sudo tail -n1 /etc/sudoers www-data ALL=(ALL) NOPASSWD: /home/php-scripts/git-pull $ cat /home/php-scripts/git-pull #!/bin/bash /usr/bin/git pull $ ls -la /home | grep php-scripts drwxr-xr-x 2 ubuntu ubuntu 4096 Sep 3 09:26 php-scripts $ ls -la /home/php-scripts/git-pull -rwxrwxr-x 1 ubuntu ubuntu 30 Sep 3 08:44 /home/php-scripts/git-pull $ cat /var/www/public_html/git-wrapper.php <?php $output = array(); $value = 0; exec("/home/php-scripts/git-pull", $output, $value); echo "<pre>"; echo "Return Value: {$value}\n"; foreach ( $output as $o) { echo $o."\n"; } ?> Note that /var/www/public_html/ is in fact a git repository. I often perform git pull in that directory from the CLI. However, when I call this script in a web browser I see that the files were not updated via git pull and the following is output to the browser: Return Value: 1 This is on Ubuntu Server 12.04 with Git 1.7.9.5. The remote repository is on the same server.
Your script runs under www-data:www-data I suppose. You have to run the git pull with a user that have a write permission on your cloned repository. You have configured sudo, but you don't call it anywhere which doesn't make much sense (not saying you need to do that at all). Verify under what user you are running and then switch to appropriate one if needed and adjust permissions on your cloned repository accordingly.
Allow www-data to perform specific commands
1,401,435,560,000
My base system is Gentoo amd64, up to date. Before the upgrade, I have the shutdown button in the KDE menu. But after the upgrade, this button is gone...I think it is because of the permission settings are wrong. The user account I used is in the user group. But I have no idea how the set the permission. I even tried to delete the KDE configuration files in the user directory and try to re-configure everything, but does not work.
The configuration file /etc/config/kdm/kdmrc has the following section: [Shutdown] # The command (subject to word splitting) to run to halt the system. # Default is "/sbin/shutdown -h -P now" # HaltCmd= # The command (subject to word splitting) to run to reboot the system. # Default is "/sbin/shutdown -r now" # RebootCmd= # Whether it is allowed to shut down the system via the global command socket. # Default is false # AllowFifo=true # Whether it is allowed to abort active sessions when shutting down the # system via the global command socket. # Default is true #AllowFifoNow=false Un-comment the "AllowFifo=true" line, then the system shutdown as it used to before the latest upgrade. Source and info As long as this is correct you can add a shutdown launcher.
No *shutdown* function in KDE
1,401,435,560,000
I am Windows 7 remoting to Ubuntu 12.04.2 LTS I am new to Ubuntu ( and *nix in general ) and need to understand how permissions are assigned to newly created dirs. Via Putty ssh session : $bash myaccount@mybox:/$ cd /etc/puppet myaccount@mybox:/etc/puppet$ sudo mkdir device myaccount@mybox:/etc/puppet/device$ myaccount@mybox:/etc/puppet/device$ ls -ld drwxr-xr-x 2 root root 4096 Jul 2 17:57 Then via WinSCP session ( SCP mode , also logged-in as myaccount@mybox ) I attempt to copy a file to /etc/puppet/device However this operation fails with an error displayed in pop-up: Error Copying file 'myfile' failed. scp: /etc/puppet/device/myfile: Permission denied It seems logical to me that if my account is assigned sufficient rights to create a dir then it should also have rights to copy a file into that dir ? Or do creating dirs and moving files fall under separate roles ? NOTE: If you are going to down-tick my post, please explain why in a comment. Just anonymously down-ticking doesn't help me understand how these forums work. Seems like I'm playing by the rules, full details, following-up on comments, etc.
In hope that I didn't overlook something: You used sudo to create a directory Your ls clearly states that the directory is owned by root When trying to copy files into that folder as user "myaccount" you are denied This is normal behaviour. You have the following options: Grant write access to "others" (chmod o+w /etc/puppet/device => very bad idea) Create a group e.g. named "adm-puppet" and add all the users allowed to create files in that dir and the puppet user. Then change the group ownership to that group Add users allowed to write files in that directory to the exisisting puppet group Use extended ACLs
Ubuntu : unable to copy file to dir created under same credentials
1,401,435,560,000
I have a Linux RedHat server and a Solaris 10 client. I have mounted a directory which locates on the RedHat server, in the Solaris system with RW(read/write) option. I already have some directories on the server (Redhat), created using a user, say ruser. The permissions on those directories are drwxr-xr-x . I mean it must be like this so that only the owner can write on the directory. the problem is, when I try to write to these directories from my Solaris system through the mounted directory, I get the permission denied error. however when I change the directory permission to drwxrwxrwx it works fine. How can I keep my drwxr-xr-x permission on the server while I am able to write through the mounted client directory? I've already tried creating the same user(ruser) with the same password on the client system, but it seems not enough yet. Any idea? thanks.
The filesystem is not storing the username, but the user id to identify the user. So if you want the user to be recognized as the same user on both systems, he needs to have the same UID. That's the third column in your /etc/passwd. You can see the UID of your user by entering the id command. So to fix this problem, you would need to first make sure that the user on both systems has the same UID, and then chown the directories that used to belong to him, because after the UID change they don't belong to him anymore.
Having owner access on files upon mounted NFS directory
1,401,435,560,000
I'm setting up a sandbox type of server that will be used by a couple users as a development environment and knowledge base. The server will have a web frontend so I've installed Apache, MySQL and PHP. Out of the box, everything under /var/www is owner by root:root. I haven't run a web server in a while but I'm pretty sure this isn't the best way of doing things. I vaguely remember the www-data user existing. How can I get apache et al. to run as these users and have files in /var/www owned by that user and group (to which I can add my own user too)?
Each major OS distro supplies Apache preconfigured slightly differently. It's up to you to decide how you want your security to be configured. If you're using a vendor supplied Apache package, try looking at the main .conf file (under Ubuntu it's called apache2.conf). Look for the User and Group directives. Either change the User and Group to the user/group that you want to own the files, or chown -R <apache user>:<apache group> /var/www. If you're looking to allow multiple users to edit files in /var/www then you'll probably have to get creative. You could: Make sure that the files in /var/www have their group set to a group that all your editing users are in. Let editing users sudo to the www user to edit files. Set ACLs on the files in /var/www to permit users to edit specific files.
Securely running LAMP under a specific user
1,401,435,560,000
In my PC I have installs Windows7 and then Ubuntu as OSes. When I try to access other partitions ( E: and F: which I'm using from Winsows7 OS) it get mount without any issue and can read and modify the files. Only thing I can't do is create or rename file on that partitions. How can I fix this issue?
The default in-kernel NTFS driver only has limited write support; you need to use an NTFS driver that supports those operations. Take a look at ntfs-3g.
Don't have write permission in partition
1,401,435,560,000
I am willing to try a dual boot arch/lmde setup on my laptop next week, but I've ran into a problem: I want to have a shared data storage where my downloads, documents etc would reside and could be read, written and executed. My first fs of choice was ext4 which needs proper attention with permissions, because like others, between distros, there can be overlapping uids and gids. So, my question is: Is there any clean way of managing a shared "data" user group across multiple installations, or do I have to settle for a fs which supports the "uid=N gid=N"option?
If you need the shared access for one group only, you'll "just" have to make sure that the group's gid is the same on both systems. (Access rights are granted to the numerical gid/uid, and not to the human-readable name of the group or user.) This is easier if this is a group that is not present by default on at least one of your systems, because you can use the -g switch to groupadd to force the number. (You might be able to change an existing gid by changing it in /etc/group, but then you'd use all access rights previously granted to that group.) I don't think explicit uid/gid settings when mounting enter into it at all: those exist for file systems which don't have this kind of access control (like vfat), where the owner/group info of files has to be made up.
Shared partition permission management
1,401,435,560,000
How do I transfer write/execute and execute permissions from owner to group and other, respectively? I have some libraries I want to move to opt and set ownership of to root. Unfortunately, permissions are a bit messed up for group and other, and that creates a problem as group and other cannot use the libraries, call the executables and read the files. I want to recursively set the permissions of write/execute and execute to group and other respectively. For example, I want this: -rw-r--r--. 1 root root 4464 Jan 11 23:58 CPackSourceConfig.cmake -rwxr--r--. 9 root root 28672 Jan 11 23:58 executable drwxr--r--. 9 root root 28672 Jan 11 23:58 Source to be this: -rw-rw-r--. 1 root root 4464 Jan 11 23:58 CPackSourceConfig.cmake -rwxrwxr-x. 9 root root 28672 Jan 11 23:58 executable drwxrwxr-x. 9 root root 28672 Jan 11 23:58 Source How do I best go about doing this, considering there are quite a number of files/folders (recursive)?
Some mix of find and chmod should do the trick: all the directories: find /opt -type d -exec chmod 775 {} \; all the "executable" files: find /opt -type f -perm -0500 -exec chmod 775 {} \; all the other files: find /opt -type f -not -perm -0500 -exec chmod 664 {} \;
transfer permissions user -> group/other
1,401,435,560,000
I am curious, in the following scenario, what kind of permission does a shell script or Java program has (owner/group/other)? There is a script called run.sh, and it in turn calls a Java program a.java. The script and the java is owned by user A and have -rwxrw-r-- permissions. When they were run by user A, which permission group do they belong to? Do they get the permission from user A as a owner? And there is another user B, who is in the same group with user A. He execute run.sh and in turn calls the Java program. Now what permission group do they belong to? Do they get the permission from user B as a group? Maybe the program will try to write on a directory /common/abc which have a permission of drwxrw-r--, if the program have a permission of "other", it will fail. A point to notice, is that they both use the expression sh run.sh to run the script, so they don't need the execute permission. Does it only require the read permission?
All processes start executing as the same user and group(s) as the process that call them, unless they are called through a setuid or setgid executable, i.e. one that has rws or r-s or -ws or --s in its permissions. The permission bits other than the s bit are irrelevant. The owner of the executable only matter if the script is setuid (i.e. has the s bit set in the user column), and the owning group only matters if the script is setgid (i.e. has the s bit set in the group column. Therefore, in the scenario you describe, when user A runs the script, the script and the Java program are both executed as user A, and as whatever group(s) A belongs to. When they are executed by user B, they are executed as user B and as whatever group(s) user B belongs to. Running a native executable requires execution permission and nothing more. Running a script (a program starting with #!) requires both execution permission (to start the execution, before the #! mechanism takes over) and read permission (for the interpreter to read the script). If you invoke the interpreter explicitly, the script doesn't need to be executable: as far as the system is concerned, it's just another data file.
permission and user/group of a program executed through a script
1,401,435,560,000
In the fedora docs they refer to owner and group owner as if both are owners of the file. The leads me to think that any member of a group which tries to change permissions of a file owned by that group will be allowed. Is this right, or can only the "owner" in it's most absolute sense change permissions? Example User foo group bar User pc group bar Can pc change a file creates by foo and group bar
Only the owner (not the group owner) of a file could change its permissions. The group owner is only used to establish what access permissions have other users of the same group, other than the file owner. Permissions are not stored on the directory, so you don't need write permissions on the containing directory.
Changing permissions
1,401,435,560,000
I have installed the newest Erlang from source. As the final step I have executed sudo make install Among other things, it placed erl link in /usr/local/bin, but its permissions are insufficient for me to use, other than with sudo lrwxr-x--- 1 root wheel 21B Apr 19 22:26 erl@ /usr/local/bin permissions: drwxr-xr-x 18 root wheel 612B Apr 20 21:45 bin/ sudo gives enough permissions to execute, but not enough to change the permissions. The question is, how do I change the permissions on these symbolic links?
Are you using chmod's -h option (from the man page: "-h If the file is a symbolic link, change the mode of the link itself rather than the file that the link points to")? I tried it, and it seemed to do the job: sudo chmod -h o+rx erl
No exec permissions on programs in /usr/local/bin
1,401,435,560,000
I've an issue with file ownerships. I have a drupal website and the "files" folder needs to be owned by "www-data" in order to let the users to upload files with php. However I'm now using svn and I need all folders and files to be owned by my ubuntu user in order to work. Files have 775 permissions, so both user and group have full access to the files. I've added my ubuntu user to www-data group but it still doesn't work. I don't know why. I've tried to change the group to my ubuntu user group but it still doesn't work. I've also tried to set my ubuntu user as owner, and www-data as group, but in this case the webserver php script cannot anymore upload files into the folder (and this is again strange because the group has full privileges).
In any sort of web development, there are usually several good reasons to handle development differently from production. It's convenient to have a local copy of your web site in your home directory for development, but accept that it's okay for some things to not work fully until you push the changes to the production environment. You shouldn't be trying to tie the Drupal permission scheme and your user account permission scheme together. Let the production Drupal stuff live in /var/www/html or wherever, with all the permissions that make Apache/PHP/Drupal happy. Let your development tree be owned by you. Whenever you finish work on a new feature for the web site, use some sort of synchronization tool to push the changes from dev to production, incidentally getting new permissions along the way. Personally, I use rsync for this. That has the nice advantage that the production server can be across the Internet, since tunneling rsync through ssh is trivial. That's an important feature with web development, since there are usually good reasons to host your web site on a server not on your own LAN. I use a command like this for my sites: rsync -lprtvD -e ssh --delete \ --exclude \*.swp \ --exclude .svn \ --exclude GNUmakefile \ ./ [email protected]:/var/www/html That command will make the files be owned by the www user on www.mysite.com, decoupling the dev permission scheme from production. It sounds like you want to use SVN instead, which is fine. You just have to make it so the dev and production boxes can both see the SVN server. As with rsync, you want to be tunneling the SVN protocol through ssh here, for security. When it's time to push a change to production, check it into SVN, then check it out on the production box. Actually, I'd recommend using svn export instead of svn checkout to avoid scattering .svn subdirectories all over your web server tree. The rsync method avoids that with --exclude rules.
svn and webserver files ownerships
1,401,435,560,000
I'm implementing some CTF challenges. The flags are in some text files, that get read from the programs. To protect the flags I have changed the owner of the files, but have set the setuid to the executables to be able to read the files. It works when I run my programs outside gdb, and the flags are read, but inside gdb I get Permission denied. I'm running the exercises inside a Linux virutal machine in VirtualBox. I have created a normal user that is not in the sudoers file, and the flags files belong to root. -rwsr-xr-x 1 root user 15260 Mar 13 13:22 exercise6 -rw-r--r-- 1 user user 3270 Mar 13 06:10 'Exercise 6.c' -rwsr-xr-x 1 root user 15700 Mar 14 03:28 exercise7 -rw-r--r-- 1 user user 4372 Mar 13 06:10 'Exercise 7.c' -rwS------ 1 root root 28 Mar 13 06:10 admin_flag.txt -rwS------ 1 root root 20 Mar 13 06:24 exercise1.txt -rwS------ 1 root root 27 Mar 13 06:24 exercise2.txt -rws------ 1 root user 18 Mar 13 10:34 exercise3.txt -rwS------ 1 root root 22 Mar 13 06:24 exercise4.txt -rwS------ 1 root root 19 Mar 13 06:10 user_flag.txt
The security contract of setuid¹ is that it grants the executable program extra privileges. Those privileges are only granted to the program. They must not allow the invoking user to do anything that the program won't do. This makes setuid incompatible with tracing (the ptrace system call on most Unix variants). If the invoking user can observe the internal operation of the program, that gives them access to any confidential data that the program has access to. But this may be confidential data that the user shouldn't be allowed to see, which the program doesn't normally reveal. Perhaps more obviously, if the invoking user can change what the program is doing (also ptrace), this could allow them to completely have all the privileges of the setuid user, which completely defeats the objective of only granting permission to run one specific program. Tracing is the functionality that a debugger such as GDB uses to inspect and control the execution of the program. As an example, consider the program unix_chkpwd, whose job is to check the password of the invoking user. This program must be able to read confidential data (the password hash database). But the invoking user must not be allowed to read the whole database. The invoking user must only be able to query the entry for that user, and only with a yes/no answer (no extraction of the password hash itself), and with a rate limitation to prevent brute-force cracking. If you could run gdb unix_chkpwd and print out the content of the password hash database, it would completely break the security of that database. In order to maintain security: When a program is already being traced when it starts, the setuid bit is ignored. The executable starts with no extra privileges. Only root is allowed to trace a program that was started with extra privileges. ¹ This also applies to setgid, setcap or any other similar mechanism to run a program with elevated privileges.
Permission denied when opening a file in gdb
1,401,435,560,000
Here's my situation: I have a user storageUser with a home directory of /storage storageUser owns /storage with full (RWE) rights Within /storage I have a directory media I'd like to create a new user mediaUser who's home directory is /storage/media with read-only permissions while maintaining storageUser's full RWE permissions When using FTP or SSH to sign into the server, I'd like storageUser to be in control of /storage with full RWE permissions, while mediaUser only being able to read /storage/media. I'd like to give access to mediaUser in the future to share my media folder without people being able to make any changes. Here's what I tried: Created mediaUser and set their password useradd mediaUser passwd mediaUser ... Created a new group storageGroup groupadd storageGroup Added both storageUser and mediaUser to the group usermod -a -G storageGroup storageUser usermod -a -G storageGroup mediaUser Changed ownership permissions so that storageUser would have permission level 7 (read-write-execute) and storageGroup would have permission level 4 (read-only) chown -R storageUser:storageGroup media chmod -R 740 Media Changed the home directory of mediaUser usermod -d /storage/media mediaUser Permissions for storageUser seem to working OK, but when I SSH into the server as mediaUser, I get this error: Could not chdir to home directory /storage/media: Permission denied mediaUser also cannot read directory contents with ls ls: cannot access '/storage/media': Permission denied What am I doing wrong?
Create Users useradd mediaUser useradd storageUser Setup Users passwd mediaUser passwd storageUser Create Group groupadd storageGroup Create Directory mkdir /storage/media Assign Users to Group usermod -a -G storageGroup {mediaUser,storageUser} Change Owner of Directory to Group chgrp storageGroup /storage/media Now everyone in group storageGroup owns the particular directory. Removing a user from storageGroup also removes access to that directory. See also man chgrp This method also removes the need for storageUser, unless you're using that user for some other reason.
Create new user with home directory inside another user's existing home directory -- both users must own the sub-directory
1,401,435,560,000
I somehow messed up the permissions of many files on my Ubuntu 22.04.2 LTS system (privately used computer, not a server), which has already caused a couple of problems. Recently, I noticed that I couldn't start Users and Groups via the GUI. It resulted in the error message: The configuration could not be loaded. An unknown error occurred. By investigating a bit I found out that the program runs again when I change the permissions of /usr/lib/dbus-1.0/dbus-daemon-launch-helper from -rwsr-xr-- (4744) to -rwsr-xr-x (4755). I used ls -l /usr/lib/dbus-1.0/dbus-daemon-launch-helper for investigating the permissions and sudo chmod +x /usr/lib/dbus-1.0/dbus-daemon-launch-helper changing the permissions. Is this safe? If not, what are my alternatives to make the programme run again?
Helpers are tools which can be expected to have improved privileges to help users or user's processes to use a feature without having the privilege to do it directly. So it's not surprising that giving back privileges restores their functionality. However. Some privileges don't require root (and thus setuid root) to be achieved: capabilities, which are subsets of what can a full root user do are sometimes enough but their flags on a file are deleted when ownership is changed. Some privileges on helpers are reserved to only a limited subset of users or processes by access rights. The later is the case for /usr/lib/dbus-1.0/dbus-daemon-launch-helper. The postinst script of dbus (which provides this file) changes its permissions and ownership like this: MESSAGEUSER=messagebus LAUNCHER=/usr/lib/dbus-1.0/dbus-daemon-launch-helper (the user/group is also created if not existing) dpkg-statoverride --update --add root "$MESSAGEUSER" 4754 "$LAUNCHER" restricting its use to processes having the group messagebus rather than to any processes like in current OP's case. So since the system is functional, the easiest is to reinstall the dbus package so it fixes the permissions: apt-get reinstall dbus or else manually: chown root:messagebus /usr/lib/dbus-1.0/dbus-daemon-launch-helper chmod 4754 /usr/lib/dbus-1.0/dbus-daemon-launch-helper You might have to check all the other affected files, especially if there are helper tools involved. Additional notes about the package's postinst metadata file: to find which package: dpkg -S /usr/lib/dbus-1.0/dbus-daemon-launch-helper which should answer: dbus: /usr/lib/dbus-1.0/dbus-daemon-launch-helper where are the package's metadata? For package FOO, until now they have always been located in various /var/lib/dpkg/info/FOO.* files (for multi-arch packages (usually libraries) they might also include :amd64 or any othe architecture too to give /var/lib/dpkg/info/FOO:amd64.*). The postinst script to check is thus: /var/lib/dpkg/info/dbus.postinst without having the package installed: cd /tmp apt-get download dbus dpkg --raw-extract dbus_*.deb /tmp/somewhere less /tmp/somewhere/DEBIAN/postinst This kind of file is often auto-generated, but for dbus it's provided in sources. Here's a link to the file for the Debian repository (it even includes a few older Ubuntu tags, anyway it's about the same content): debian/dbus.postinst
Are 4755 permissions safe for usr/lib/dbus-1.0/dbus-daemon-launch-helper?
1,401,435,560,000
I have some new files to release every day. My coworker needs to sftp/scp to my Linux server to copy these files. I don't want him to do any file delete/move/execution...etc, the only thing he can do should be copied (scp/sftp) the files back. The best is he can't switch directories. Any method to do this?
This can be solved by creating a user and a group with the necessary permissions to just read the files or folder. Here is an example of how to achieve read-only access via scp (ssh) to a folder on a Linux server. useradd <USERNAME> # no need to create a home directory, so we can skip --create-home groupadd <GROUPNAME> # create the group that will have read-only-access to the folder Now add the created user to the created group usermod -aG <GROUPNAME> <USERNAME> Now create the folder somewhere on your system that the user should have access to: mkdir <FOLDERNAME> -m rwxr-x-r Now change the group of that folder to the created group with chgrp <GROUPNAME> </PATH/TO/FOLDER> Now, when you add files in that folder, make sure that they are also owned by the created group with the necessary permissions: chmod 744 <FILENAME> chgrp <GROUPNAME> <PATH/TO/FILE> With that, the user should be able to access the folder via scp like this: scp -r user@<IP>:/path/to/folder /local/path/ EDIT Adding a group with 744 permission can be skipped, since the default permissions for others are already 744 (read-only). Thanks @symcbean for pointing that out.
How to let user can only read files?
1,401,435,560,000
There are two accounts user1 and user2. I wish to share and give rwx access to my user1 /home/user1/Documents/ folder with user2. To do this, I have made a new group called sharedDocs. These are the commands I executed in order: groupadd sharedDocs usermod -aG share user1 usermod -aG share user2 chgrp -R sharedDocs /home/user1/Documents sudo chmod -R g+rwX /home/user1/Documents From here, I switch to user2 to access the documents. su to reload. su user2 user2: touch 1.txt This command works, if prior to su I was in the /home/user1/Documents folder. However, the following commands don't work, and I cannot return to the directory once I left it. user2: touch /home/user1/Documents/1.txt touch: cannot touch '/home/user1/Documents/1.txt': Permission denied user2: cd /home/user1/Documents/ bash: cd: /home/user1/Documents: Permission denied I have followed these two guides: How to allow folder permission for another user in Linux? Allowed group can't access a folder
You need to have execute permission to enter the /home/user1/ folder and any subfolders in it, or to access any files in it. By default linux sets user home folder to 750, or rwxr-x---, meaning users which are not owner of the folder or in the group that owns the folder are not allowed to enter that folder. It is not enough to have permissions to the subfolder or a files inside user1 home directory you also need to have permission to enter/passthrough that directory to get to objects inside it. Execute permission on a file gives you permission to run the file it it is a script or an application, execute permission on a directory gives you permission to enter that directory or pass through it to get to files and folders inside it. You can either put user2 in a group that owner /home/user1, or use setfacl command to set additional permission to give execute permission to just user2 on /home/user1 so that he can enter the folder to get to /home/user1/Documents something like this would give execute permission to user2 on /home/user1 setfacl -m user2:x /home/user1/ You can then use getfacl command to see acl rules on the folder getfacl /home/user1 For directories read permission means that the user may see the contents of a directory. Write permission means that a user may create files or folders in the directory. Execute permission means that the user may enter the directory.
Allow user in group to access shared folder from another user
1,401,435,560,000
I want to access with QEMU this USB stick: $ lsusb | grep Kingston Bus 001 Device 011: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102/2.0 / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick The problem is that I need to change the group from root to kvm: $ LC_ALL=C ls -l /dev/bus/usb/001/011 crw-rw-r-- 1 root root 189, 10 Feb 3 22:25 /dev/bus/usb/001/011 $ sudo chgrp kvm /dev/bus/usb/001/011 $ LC_ALL=C ls -l /dev/bus/usb/001/011 crw-rw-r-- 1 root kvm 189, 10 Feb 3 22:25 /dev/bus/usb/001/011 How can I make the group change persistent? Alternatively, are there better ways to fix permissions? This is the command I use: qemu-system-x86_64 \ -enable-kvm \ -m 4G \ -smp 2 \ -hda myVirtualDisk.qcow2 \ -boot d \ -cdrom linuxmint-21.1-cinnamon-64bit.iso \ -netdev user,id=net0,net=192.168.0.0/24,dhcpstart=192.168.0.9 \ -device virtio-net-pci,netdev=net0 \ -vga qxl \ -device AC97 \ -device usb-ehci,id=ehci \ -usb \ -device usb-host,bus=ehci.0,vendorid=0x0930,productid=0x6545
This solution works on Linux Mint 21 (derivative of Ubuntu 22.04): # echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0930", ATTR{idProduct}=="6545", OWNER="root", GROUP="kvm", MODE="0666"' > /etc/udev/rules.d/99-usb-stick.rules # udevadm control --reload-rules && udevadm trigger More info about this solution: How to make a USB device available to a QEMU guest? Writing raw images safely to USB sticks
USB Stick access permission problems with QEMU
1,401,435,560,000
I have a dual boot Linux/Windows system with the two systems sitting on entirely separate physical hard-drives (yes, it is that old). On the Linux system, there is a sub-directory in /media/myusername called windrive. I mount the Windows partition using: sudo mount -t ntfs -o nls=utf8,umask=0000 /dev/sda2 /media/myusername/windrive so that I end up with the Linux system mounted on /dev/sdb1 and the Windows partition mounted on dev/sda2. Most read/write operations on the Windows partition work OK but a few do not. For example (and please note, this is only an example), I can copy the file nameOfFile.txt from my Linux desktop to my Windows desktop using: cp ~/Desktop/nameOfFile.txt /media/myusername/windrive/Users/myusername/Desktop However, moving the file only partly succeeds because of a problem with permissions. Specifically, mv ~/Desktop/nameOfFile.txt /media/myusername/windrive/Users/myusername/Desktop results in the error: mv: preserving times for '/media/myusername/windrive/Users/myusername/Desktop/nameOfFile.txt': Operation not permitted As a one-off solution, I can simply use sudo mv instead of mv ... but is there a way of mounting the Windows partition so that this problem does not arise at all? As a follow on, if this is possible and I do it, are there any significant risks involved? Added: I am specifically interested in a general way of overcoming the issue about preserving times. I have used cp and mv merely as illustrations of what does, and does not work. The problem arises whenever I have a library that is on the Windows partition and shared between a Linux and Windows app.
Since you don't care about preserving times or permissions and want to avoid the error message: Operation not permitted when using mv (as well as to avoid using sudo) you need to mount the drive specifying a user (and agroup if you want) by using uid and gid in the mount options: sudo mount -t ntfs -o nls=utf8,umask=0000,uid=1000,gid=1000 /dev/sda2 /media/myusername/windrive Where uid=1000 and gid=1000 might be different according yo your needs.
Permissions problem with dual-boot Linux/Windows
1,401,435,560,000
I have run exa --long --extended on a folder containing some wallpapers and I noticed that it returns a strange security.selinux (len 37) tag on several of my files. I'd like to know what it is and how to get rid of it. I assume it's something that got passed when I backed up my files from my old Fedora install, but I've since moved from Fedora to Arch and I have switched to apparmor due to the better support for it on latter. Here is what I'm talking about: drwxrwxr-x@ - MYUSER 29 juni 19:09 wallhaven_wallhaven_cc_search_q_yosemite_categories_100_purity_110_atleast_2560x1440_sorting_relevance_order_desc └── security.selinux (len 37)
I found out how to do it. If anyone experiences the same, you can run find /path/to/dir/ -type d,f -exec setfattr -x security.selinux {} \;
What is this strange SELinux attribute on several of my files?
1,401,435,560,000
I tried something normal: $ mv path1 path2 mv: cannot move 'path1/subfolder/' to 'path2/subfolder': Permission denied The path2 doesn't initially exist, so this should replicate the folder tree of path1 as path2. A find path1 -ls shows that I have read/write permission to all files and folders in path1. An initial diff -qr path1 path2 showed that path1/subfolder wasn't moved. However, I can recursively copy: mkdir path2/subfolder cp -r path1/subfolder/* path2/subfolder # Confirm that original subtree and copy are identical diff -qr path1 path2 # Reveals that the two are identical While I have worked around the problem, I am never happy with unexplained behaviour. Is there is simple way to poke and prod for the cause? I do mean simple, as I don't write Bash scripts. I merely use it at the command line. I am using Cygwin on Windows 10. The account is a non-administrator account. All files and folders are owned by the account. I ensured that there are no zombie processes like Office apps or Matlab that might somehow be preventing a folder from being deleted, though the problem could just as easily be read access or something else. As the workaround shows, it definitely isn't write access to the destination tree. I can also rm -r path1, so the problem isn't write access to the original tree, either. Drat. That means I no longer have path1, which makes it hard to try out any troubleshooting suggestions. I'm still open to suggestions, though.
The only reason it should happen is if both of the following conditions are correct: path1 and path2 are not on the same filesystem. You can check this by running df path1 and df path2 (or on their parent folders) and see they are not on the same partition. If they were both on the same partition, then the mv command wouldn't have tried to recursively move the entire directory tree; It would just rename path1 to path2, without moving the child files and directories. path1 doesn't have write permission for the user or the group. You said you have read/write permission to all files and folders in path1, but if you want to move path1 to another filesystem, you would need write permission to path1 by itself (or to the parent of subfolder, if the subfolder is not a direct child or path). Since you've already removed path1, we cannot confirm this now. You said that you were able to rm the folder after copying it, but you might have changed the permissions at some point in the middle, and I cannot prove this. But you wouldn't have had this problem. In general, there's probably some detail you didn't tell us, something you might have missed or didn't think was relevant, but again - now it's impossible to confirm that. Especially since you've used cp -r (which does not preserve permissions, for that you would need -a or -p), so again, we cannot see what were the original permissions of all the files and folders.
Simple steps to find why I don't have permission to "mv" a folder
1,661,603,103,000
root@photon-machine [ /mnt/data/torrents ]# touch aa touch: cannot touch 'aa': Permission denied root@photon-machine [ /mnt/data/torrents ]# ls -al total 131 drwxrwxr-x 5 1000 nasgroup 5 Aug 26 21:03 . drwxrwxr-x 23 1000 nasgroup 26 Aug 26 22:51 .. drwxrwxr-x 12 1000 nasgroup 13 Aug 27 14:11 complete drwxrwxr-x 2 1000 nasgroup 2 Aug 27 14:11 incomplete drwxrwxr-x 2 1000 nasgroup 9 Aug 27 11:11 torrents_watched_folder root@photon-machine [ /mnt/data/torrents ]# id uid=0(root) gid=0(root) groups=0(root),1000(nasgroup) According to the above I should be able to create a file in that directory. What am I missing? Does it matter that the /mnt/data is a nfs (version 3) mount from a TrueNas box? the line in /etc/fstab is the following: 192.168.1.50:/mnt/NasPool/main/Transmission /mnt/data nfs defaults 0 0 To answer the questions: @user10489: in /etc/exports the line looks like: /mnt/NasPool/main/Transmission -alldirs -quiet If I touch a file in a 777 permissions directory, I get -rw-r----- 1 nobody nasgroup 0 Aug 27 16:09 aa @telometto: if I do a ls -l on my dirs from the TrueNas box I get: drwxrwxr-x 2 acasa acasa 9 Aug 27 11:11 torrents_watched_folder and the same permissions for the other 2 folders. if I issue id acasa, I get the following: uid=1000(acasa) gid=1000(acasa) groups=1000(acasa)
The NFS protocol, to reduce security issues, "squashes" the root userid to the user nobody unless the no_root_squash option is used. (Default is root_squash.) The solution here is either to enable this option (dangerous! If you do, at least restrict it by host.) or stop using root to access this NFS share and switch to a regular user. (Note: some versions of NFS may spell this option differently.)
Permission denied when it shouldn't be
1,661,603,103,000
just copied some files from /home/user/Downloads directory and tried pasting into ntfs filesystem,and got this way "could not paste files;permissions do not allow to paste files in this directory" OS:UBUNTU 22LTS
There is one common reason why the NTFS file system is read-only The NTFS file system is 'dirty' due to Fast Startup in Windows, and Linux automount refuses to mount read/write to avoid causing damage. See this AskUbuntu link and a link from there to a tutorial how to turn off Fast Startup. If the Windows system that made the file system 'dirty' is not available, it is recommended to use some other Windows system to repair the file system. There is good old chkdsk and there are tools with graphical user interfaces for this task. Some other reason, even when NTFS is good. In this case you can unmount and mount again to set suitable ownership and/or permissions. There is a detailed description at this AskUbuntu link.
copy/paste not working in ubuntu22
1,661,603,103,000
I had a git repo on machine A. I did an rsync from machine A to machine B using the flags rsync -zvaP /media/shihab/development shihab@remote:/media/shihab/OSDisk/development Later I did some changes in machine B and did an rsync from machine B to machine A using the same flags: rsync -zvaP shihab@remote:/media/shihab/OSDisk/development /media/shihab/development During the sync, I realized that even the files without modifications were synced. Turns out both times of the sync operation, the file owner and permissions were changed. Doing a git status in the repo would tell me that user permissions were changed. To rectify this, I made changes to the git config global and local by adding core.filemode=false as: git config --global core.fileMode false git config --local core.fileMode false Furthermore, I added the flags, rsync -zvaP --no-perms --no-owner --no-group to my sync to ask rsync to forget about writing the permissions. For example: rsync -zvaP --no-perms --no-owner --no-group /media/shihab/development shihab@remote:/media/shihab/OSDisk/development However, despite that change, when I rsync from machine B to machine A, it is overwriting a file with a newer timestamp with that on machine B with an older time-stamp. I can see it if I do a --dry-run -i. The file looks like this on machine B: -rwxrwxrwx 1 shihab shihab 655 Nov 16 2021 install-i3wm.sh* While on machine A it looks like: -rwxrwxrwx 1 shihab shihab 681 Jun 22 11:06 install-i3wm.sh* when I do an rsync from Machine B to machine A as follows: rsync -zvaP --dry-run -i -t --no-perms --no-owner --no-group shihab@remote:/media/shihab/OSDisk/development /media/shihab/development I get: f+++++++++ install-i3wm.sh What am I doing wrong?
You say that rsync "is overwriting a file with a newer timestamp with that on machine B with an older time-stamp". The two files are different so the destination will be updated to match the source. That's what rsync does. If you want rsync only to update files when the source is newer than the destination you needed to tell it that's the modified behaviour that you want. In this case include -u (--update).
Rsync not considering timestamps while syncronising git repos after permissions changed
1,661,603,103,000
I have a chroot root containing some static binaries on an ARMv7l platform (Kobo eReader, see InkBox OS project), namely BusyBox. chrooting as root works fine: kobo:/kobo/mnt/onboard/onboard/.apps/Sanki# env PATH=/system-bin /tmp/chroot /data/onboard/.apps/Sanki/ /app-temp/busybox sh kobo:/# whoami whoami: unknown uid 0 #### I am root kobo:/# then I tried to login as an unpriviledged user in the chroot via the --userspec option: kobo:/kobo/mnt/onboard/onboard/.apps/Sanki# env PATH=/system-bin /tmp/chroot --userspec=user:user /data/onboard/.apps/Sanki/ /app-temp/busybox sh chroot: failed to run command ‘/app-temp/busybox’: Permission denied kobo:/kobo/mnt/onboard/onboard/.apps/Sanki# Stack trace: kobo:/kobo/mnt/onboard/onboard/.apps/Sanki# strace env PATH=/system-bin /tmp/chroot --userspec=user:user /data/onboard/.apps/Sanki/ /system-bin/busybox sh execve("/usr/bin/env", ["env", "PATH=/system-bin", "/tmp/chroot", "--userspec=user:user", "/data/onboard/.apps/Sanki/", "/system-bin/busybox", "sh"], 0x7e8f5cf8 /* 17 vars */) = 0 set_tls(0x2ad13388) = 0 set_tid_address(0x2ad13f3c) = 3925 brk(NULL) = 0x2abcd000 brk(0x2abcf000) = 0x2abcf000 mmap2(0x2abcd000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2abcd000 open("/etc/ld-musl-armhf.path", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/libacl.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_BASIC_STATS, 0x7eafe5f8) = -1 ENOSYS (Function not implemented) fstat64(3, {st_mode=S_IFREG|0755, st_size=17616, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0h\22\0\0004\0\0\0"..., 936) = 936 mmap2(NULL, 86016, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2abcf000 mmap2(0x2abe2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3000) = 0x2abe2000 close(3) = 0 open("/lib/libattr.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_BASIC_STATS, 0x7eafe5f8) = -1 ENOSYS (Function not implemented) fstat64(3, {st_mode=S_IFREG|0755, st_size=13480, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320\r\0\0004\0\0\0"..., 936) = 936 mmap2(NULL, 81920, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2abe4000 mmap2(0x2abf6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x2abf6000 close(3) = 0 mprotect(0x2abe2000, 4096, PROT_READ) = 0 mprotect(0x2abf6000, 4096, PROT_READ) = 0 mprotect(0x2abb5000, 24576, PROT_READ) = 0 prctl(PR_SET_NAME, "env") = 0 prctl(PR_SET_KEEPCAPS, 2125458926) = -1 EINVAL (Invalid argument) execve("/tmp/chroot", ["/tmp/chroot", "--userspec=user:user", "/data/onboard/.apps/Sanki/", "/system-bin/busybox", "sh"], 0x7eafecf4 /* 17 vars */) = 0 set_tls(0x2acff388) = 0 set_tid_address(0x2acfff3c) = 3925 brk(NULL) = 0x2ac75000 brk(0x2ac77000) = 0x2ac75000 mmap2(NULL, 8192, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ab4b000 mprotect(0x2ab4c000, 4096, PROT_READ|PROT_WRITE) = 0 open("/etc/ld-musl-armhf.path", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/libacl.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_BASIC_STATS, 0x7e811648) = -1 ENOSYS (Function not implemented) fstat64(3, {st_mode=S_IFREG|0755, st_size=17616, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0h\22\0\0004\0\0\0"..., 936) = 936 mmap2(NULL, 86016, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2ad00000 mmap2(0x2ad13000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3000) = 0x2ad13000 close(3) = 0 open("/lib/libattr.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_BASIC_STATS, 0x7e811648) = -1 ENOSYS (Function not implemented) fstat64(3, {st_mode=S_IFREG|0755, st_size=13480, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320\r\0\0004\0\0\0"..., 936) = 936 mmap2(NULL, 81920, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2aaf1000 mmap2(0x2ab03000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x2ab03000 close(3) = 0 mprotect(0x2ad13000, 4096, PROT_READ) = 0 mprotect(0x2ab03000, 4096, PROT_READ) = 0 mprotect(0x2ac5d000, 24576, PROT_READ) = 0 prctl(PR_SET_NAME, "/tmp/chroot") = 0 prctl(PR_SET_KEEPCAPS, 2122391093) = -1 EINVAL (Invalid argument) mmap2(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aaec000 statx(AT_FDCWD, "/data", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0x7e8119b0) = -1 ENOSYS (Function not implemented) lstat64("/data", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 statx(AT_FDCWD, "/data/onboard", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0x7e8119b0) = -1 ENOSYS (Function not implemented) lstat64("/data/onboard", {st_mode=S_IFDIR|0755, st_size=6656, ...}) = 0 statx(AT_FDCWD, "/data/onboard/.apps", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0x7e8119b0) = -1 ENOSYS (Function not implemented) lstat64("/data/onboard/.apps", {st_mode=S_IFDIR|0755, st_size=512, ...}) = 0 statx(AT_FDCWD, "/data/onboard/.apps/Sanki", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0x7e8119b0) = -1 ENOSYS (Function not implemented) lstat64("/data/onboard/.apps/Sanki", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 munmap(0x2aaec000, 16384) = 0 open("/etc/passwd", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aac0000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "root:x:0:0:root:/root:/bin/ash\nb"..., 1024) = 1024 read(3, "mail:/sbin/nologin\nntp:x:123:123"..., 1024) = 302 close(3) = 0 munmap(0x2aac0000, 4096) = 0 open("/etc/group", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac4d000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "root:x:0:root\nbin:x:1:root,bin,d"..., 1024) = 730 close(3) = 0 munmap(0x2ac4d000, 4096) = 0 open("/etc/passwd", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ab7d000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "root:x:0:0:root:/root:/bin/ash\nb"..., 1024) = 1024 read(3, "mail:/sbin/nologin\nntp:x:123:123"..., 1024) = 302 close(3) = 0 munmap(0x2ab7d000, 4096) = 0 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aac7000 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 24) = -1 ENOENT (No such file or directory) close(3) = 0 munmap(0x2aac7000, 4096) = 0 open("/etc/group", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aacc000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "root:x:0:root\nbin:x:1:root,bin,d"..., 1024) = 730 read(3, "", 1024) = 0 close(3) = 0 munmap(0x2aacc000, 4096) = 0 chroot("/data/onboard/.apps/Sanki/") = 0 chdir("/") = 0 open("/etc/passwd", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aacd000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "user::1000:1000:user:/root:/syst"..., 1024) = 42 close(3) = 0 munmap(0x2aacd000, 4096) = 0 open("/etc/group", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ab7e000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "user:x:1000:\n", 1024) = 13 close(3) = 0 munmap(0x2ab7e000, 4096) = 0 open("/etc/passwd", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac4d000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "user::1000:1000:user:/root:/syst"..., 1024) = 42 close(3) = 0 munmap(0x2ac4d000, 4096) = 0 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac4d000 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 24) = -1 ENOENT (No such file or directory) close(3) = 0 munmap(0x2ac4d000, 4096) = 0 open("/etc/group", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ab0b000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "user:x:1000:\n", 1024) = 13 read(3, "", 1024) = 0 close(3) = 0 munmap(0x2ab0b000, 4096) = 0 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0 setgroups32(1, [1000]) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0 setgid32(1000) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0 setuid32(1000) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 execve("/system-bin/busybox", ["/system-bin/busybox", "sh"], 0x7e811d3c /* 17 vars */) = -1 EACCES (Permission denied) fcntl64(1, F_GETFL) = 0x20002 (flags O_RDWR|O_LARGEFILE) writev(2, [{iov_base="chroot: ", iov_len=8}, {iov_base=NULL, iov_len=0}], 2chroot: ) = 8 writev(2, [{iov_base="failed to run command \342\200\230/system"..., iov_len=47}, {iov_base=NULL, iov_len=0}], 2failed to run command ‘/system-bin/busybox’) = 47 writev(2, [{iov_base=": Permission denied", iov_len=19}, {iov_base=NULL, iov_len=0}], 2: Permission denied) = 19 writev(2, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2 ) = 1 close(1) = 0 close(2) = 0 exit_group(126) = ? +++ exited with 126 +++ kobo:/kobo/mnt/onboard/onboard/.apps/Sanki# strace env PATH=/system-bin /tmp/chroot --userspec=user:user /data/onboard/.apps/Sanki/ /app-temp/busybox sh execve("/usr/bin/env", ["env", "PATH=/system-bin", "/tmp/chroot", "--userspec=user:user", "/data/onboard/.apps/Sanki/", "/app-temp/busybox", "sh"], 0x7ec2bcf8 /* 17 vars */) = 0 set_tls(0x2ad36388) = 0 set_tid_address(0x2ad36f3c) = 3929 brk(NULL) = 0x2abef000 brk(0x2abf1000) = 0x2abf1000 mmap2(0x2abef000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2abef000 open("/etc/ld-musl-armhf.path", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/libacl.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_BASIC_STATS, 0x7ebfe608) = -1 ENOSYS (Function not implemented) fstat64(3, {st_mode=S_IFREG|0755, st_size=17616, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0h\22\0\0004\0\0\0"..., 936) = 936 mmap2(NULL, 86016, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2abf1000 mmap2(0x2ac04000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3000) = 0x2ac04000 close(3) = 0 open("/lib/libattr.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_BASIC_STATS, 0x7ebfe608) = -1 ENOSYS (Function not implemented) fstat64(3, {st_mode=S_IFREG|0755, st_size=13480, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320\r\0\0004\0\0\0"..., 936) = 936 mmap2(NULL, 81920, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2ac06000 mmap2(0x2ac18000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x2ac18000 close(3) = 0 mprotect(0x2ac04000, 4096, PROT_READ) = 0 mprotect(0x2ac18000, 4096, PROT_READ) = 0 mprotect(0x2abd7000, 24576, PROT_READ) = 0 prctl(PR_SET_NAME, "env") = 0 prctl(PR_SET_KEEPCAPS, 2126507504) = -1 EINVAL (Invalid argument) execve("/tmp/chroot", ["/tmp/chroot", "--userspec=user:user", "/data/onboard/.apps/Sanki/", "/app-temp/busybox", "sh"], 0x7ebfed04 /* 17 vars */) = 0 set_tls(0x2ad7d388) = 0 set_tid_address(0x2ad7df3c) = 3929 brk(NULL) = 0x2ac45000 brk(0x2ac47000) = 0x2ac47000 mmap2(0x2ac45000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2ac45000 open("/etc/ld-musl-armhf.path", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/libacl.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_BASIC_STATS, 0x7eab9648) = -1 ENOSYS (Function not implemented) fstat64(3, {st_mode=S_IFREG|0755, st_size=17616, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0h\22\0\0004\0\0\0"..., 936) = 936 mmap2(NULL, 86016, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2ab0a000 mmap2(0x2ab1d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3000) = 0x2ab1d000 close(3) = 0 open("/lib/libattr.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_BASIC_STATS, 0x7eab9648) = -1 ENOSYS (Function not implemented) fstat64(3, {st_mode=S_IFREG|0755, st_size=13480, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320\r\0\0004\0\0\0"..., 936) = 936 mmap2(NULL, 81920, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x2aab3000 mmap2(0x2aac5000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x2aac5000 close(3) = 0 mprotect(0x2ab1d000, 4096, PROT_READ) = 0 mprotect(0x2aac5000, 4096, PROT_READ) = 0 mprotect(0x2ac2d000, 24576, PROT_READ) = 0 prctl(PR_SET_NAME, "/tmp/chroot") = 0 prctl(PR_SET_KEEPCAPS, 2125176375) = -1 EINVAL (Invalid argument) mmap2(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ab1f000 statx(AT_FDCWD, "/data", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0x7eab99b0) = -1 ENOSYS (Function not implemented) lstat64("/data", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 statx(AT_FDCWD, "/data/onboard", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0x7eab99b0) = -1 ENOSYS (Function not implemented) lstat64("/data/onboard", {st_mode=S_IFDIR|0755, st_size=6656, ...}) = 0 statx(AT_FDCWD, "/data/onboard/.apps", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0x7eab99b0) = -1 ENOSYS (Function not implemented) lstat64("/data/onboard/.apps", {st_mode=S_IFDIR|0755, st_size=512, ...}) = 0 statx(AT_FDCWD, "/data/onboard/.apps/Sanki", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0x7eab99b0) = -1 ENOSYS (Function not implemented) lstat64("/data/onboard/.apps/Sanki", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 munmap(0x2ab1f000, 16384) = 0 open("/etc/passwd", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aad1000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "root:x:0:0:root:/root:/bin/ash\nb"..., 1024) = 1024 read(3, "mail:/sbin/nologin\nntp:x:123:123"..., 1024) = 302 close(3) = 0 munmap(0x2aad1000, 4096) = 0 open("/etc/group", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aad2000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "root:x:0:root\nbin:x:1:root,bin,d"..., 1024) = 730 close(3) = 0 munmap(0x2aad2000, 4096) = 0 open("/etc/passwd", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aad4000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "root:x:0:0:root:/root:/bin/ash\nb"..., 1024) = 1024 read(3, "mail:/sbin/nologin\nntp:x:123:123"..., 1024) = 302 close(3) = 0 munmap(0x2aad4000, 4096) = 0 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac1d000 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 24) = -1 ENOENT (No such file or directory) close(3) = 0 munmap(0x2ac1d000, 4096) = 0 open("/etc/group", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ab47000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "root:x:0:root\nbin:x:1:root,bin,d"..., 1024) = 730 read(3, "", 1024) = 0 close(3) = 0 munmap(0x2ab47000, 4096) = 0 chroot("/data/onboard/.apps/Sanki/") = 0 chdir("/") = 0 open("/etc/passwd", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aac8000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "user::1000:1000:user:/root:/syst"..., 1024) = 42 close(3) = 0 munmap(0x2aac8000, 4096) = 0 open("/etc/group", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac1d000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "user:x:1000:\n", 1024) = 13 close(3) = 0 munmap(0x2ac1d000, 4096) = 0 open("/etc/passwd", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ab3c000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "user::1000:1000:user:/root:/syst"..., 1024) = 42 close(3) = 0 munmap(0x2ab3c000, 4096) = 0 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac1d000 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 24) = -1 ENOENT (No such file or directory) close(3) = 0 munmap(0x2ac1d000, 4096) = 0 open("/etc/group", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aaf2000 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 read(3, "user:x:1000:\n", 1024) = 13 read(3, "", 1024) = 0 close(3) = 0 munmap(0x2aaf2000, 4096) = 0 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0 setgroups32(1, [1000]) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0 setgid32(1000) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0 rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0 setuid32(1000) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 execve("/app-temp/busybox", ["/app-temp/busybox", "sh"], 0x7eab9d3c /* 17 vars */) = -1 EACCES (Permission denied) fcntl64(1, F_GETFL) = 0x20002 (flags O_RDWR|O_LARGEFILE) writev(2, [{iov_base="chroot: ", iov_len=8}, {iov_base=NULL, iov_len=0}], 2chroot: ) = 8 writev(2, [{iov_base="failed to run command \342\200\230/app-te"..., iov_len=45}, {iov_base=NULL, iov_len=0}], 2failed to run command ‘/app-temp/busybox’) = 45 writev(2, [{iov_base=": Permission denied", iov_len=19}, {iov_base=NULL, iov_len=0}], 2: Permission denied) = 19 writev(2, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2 ) = 1 close(1) = 0 close(2) = 0 exit_group(126) = ? +++ exited with 126 +++ [chroot]/etc/passwd: user::1000:1000:user:/root:/system-bin/sh [chroot]/etc/group: user:x:1000: Permissions: kobo:/kobo/mnt/onboard/onboard/.apps/Sanki# ls -ld app-temp drwxrwxrwt 2 user user 80 Jun 11 19:26 app-temp kobo:/kobo/mnt/onboard/onboard/.apps/Sanki# ls -l app-temp/ total 2660 -rwxr-xr-x 1 user user 1509048 Jun 11 18:52 busybox kobo:/kobo/mnt/onboard/onboard/.apps/Sanki# It also gives me the same 'Permission denied' error if I try to do su user -s /system-bin/sh in the chroot as root. Any idea of what's wrong? Thanks!
I found the cause of my issue: I'm using squashfuse to mount SquashFS files as the kernel on some devices I have is too old to support XZ compression. I forgot to specify the allow_other option so that the files of a mounted archive (which is where the chroot is) can be accessed by other users. Passing that mount option to squashfuse indeed solved the problem.
chroot as unpriviledged user leads to 'Permission denied' trying to run any binary
1,661,603,103,000
I've edited my root crontab to periodically execute a script: sudo crontab -e Which should execute the following script, located on a mounted USB, as root: * * * * * /mnt/usb0/fake-hwclock-cron.sh The script (1) fake-hwclock-cron.sh then runs the script (2) fake-hwclock to save the current time: #!/bin/sh echo "$(fake-hwclock save)" The script (2) fake-hwclock (located in "/sbin/fake-hwclock") then saves the time to the file (3) fake-hwclock.data on a mounted USB. The USB is automatically mounted with the following options: PARTUUID=1c921a37-01 /mnt/usb0 ext4 defaults,auto,users,rw,nofail 0 0 File Permissions: (1) -rwxrwxrwx 1 pi pi /mnt/usb0/fake-hwclock-cron.sh (2) -rwxr-xr-x 1 root root /sbin/fake-hwclock (3) -rwxrwxrwx 1 pi pi /mnt/usb0/fake-hwclock.data If I understood it correct, for the files (1) fake-hwclock-cron.sh and (3) fake-hwclock.data every user can read/write/execute. For file (2) fake-hwclock every user can read/execute. .. but ignoring these permissions for a second, isn't the cron job, which is executed as sudo, executing the script (1) fake-hwclock-cron.sh with su rights as well? And what's even more confusing: I can execute both scripts (1) / (2) without su rights in the shell, but I cant execute them with su rights as a cron job. So, can anyone explain to me why I get a "Permission denied" error? /bin/sh: 1: /mnt/usb0/fake-hwclock-cron.sh: Permission denied P.S. I hope i've managed to explain well enough; otherwise please tell me
Based on the output of the mount |grep usb0 it shows that the mount point is mounted by the noexec option and it will prevent you just executing the script but you can do execute it with shell interpreter directly like: * * * * * sh /path/to/script.sh for the later error fake-hwclock: not found, you would need to provide the full of the fake-hwclock commnad. see more about noexec.
bash script in cronjob cannot execute /sbin/fake-hwclock
1,661,603,103,000
I've installed azure storage explorer with "sudo snap install". I don't remember giving it root permissions during the installation. Now it's creating directories owned by root for downloaded files. Does it mean that if I install an application from the internet, it can do whatever it wants on my machine?
A "snap"'s permissions depends on how it is set up. As per design each Snap runs in its own sandbox. However, totally isolated packages in sandboxes don't work for a lot of use cases. Therefore there is the concept of "interfaces" which allows access to "things" outside of the sandbox. This ubuntu blog explains the concept pretty nicely. Additionally different levels of confinement exist within snaps and you can check out how your installed app is configured. The biggest problem with your questions is, that snaps don't make the user aware of very loosely set permissions and to answer your question: yes a badly designed or malicious snap could do whatever it wants to your system.
when did I give the application a root permissions?
1,661,603,103,000
I recently had this question at a test for a Linux certification. How do you do this? Copy file /etc/fstab to /tmp/fstab_bck and make sure it's owned by root and group is root. I know how to do this. Make sure user X does not have access. Make sure user Y has access to view. Make sure that all other newly created users have access to view this file.
To accomplish requirements 2 and 3, you need to use ACLs in addition to normal chmod permissions: chmod o+r /tmp/fstab_bck setfacl -m u:userx:000 /tmp/fstab_bck No need to write an ACL for User Y, since User Y is part of "other" users.
Deny access to only one user to a file
1,661,603,103,000
When running install (GNU Coreutils implementation), I'd like to know if it is possible to preserve ownership and permissions of the source files. I know that by default it installs as 755, and you can change this with -m, however is it possible to preserve the permissions and ownership to be the same as that of the source files? I am aware that cp has functionality to preserve ownership and permissions, however under my circumstances, I need to use install, if possible.
The is no option to do it. You could fake it for example by using stat to record the owner, group and mode information and using that. Something like #!/bin/sh install $(stat -c '-m %a -g %g -o %u' "$1") "$1" "$2" (Do not use this script in production, it is seriously lacking in checking, it just accepts 2 arguments, the SRC and DEST rather than all the options that install does).
Preserve permissions and ownership with install command
1,661,603,103,000
There are lots of similar questions out there, but none seems to address my problem: every time, the culprit is a legitimate permission issue, or an incompatible filesystem, none of which makes any sense here. I'm transferring a file locally, on an ext4 filesystem, using rsync. A minimal example is: cd /tmp touch blah mkdir test rsync -rltDvp blah test which returns the error: rsync: [receiver] failed to set permissions on "/tmp/test/.blah.Gyvvbw": Function not implemented (38) and the files have different permissions: -rw-r--r-- 1 ted ted 0 Sep 29 15:49 blah -rw------- 1 ted ted 0 Sep 29 15:49 test/blah I'm running rsync as user ted and the filesystem is ext4, so it should support permissions just fine. Here is the corresponding line from df -Th: Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/c--3px--vg-root ext4 936G 395G 494G 45% / I'm running rsync 3.2.3 protocol version 31 on Debian Sid, kernel 5.10.0-6-amd64.
The OP wrote, apt-get update && apt-get upgrade, which apparently upgraded rsync (to version 3.2.3-8), fixed the problem. The error was presumably caused by to a change to lchmod and fchmodat in the GNU C library.
rsync failed to set permissions for a local copy ("Function not implemented")
1,661,603,103,000
I have encountered a package which installs its binaries with permission 555 instead of usual 755 in /usr/bin, i.e. prohibiting writing for everyone. I do not understand the reason for doing so... Can assume that they want to add extra security, but not sure. My question is as follows: can having permissions 555 for binaries in /usr/bin lead to any problems with such a binary?
If the file is owned by the root user, permissions normally don't matter, the root user will be able to do anything with the file regardless. If the file is owned by a non-root user, then 555 could be pertinent to prevent the owner of the file rewriting the file (which could allow to e.g. embed malware or run some code).
is there a reason to revoke write permission for executables in /usr/bin
1,661,603,103,000
I am currently trying to automate the encryption and decryption of a collection of files. For the encryption I currently use: gpg --batch --recipient [RECIPIENT] --encrypt-files [FILES] For the decryption I use pretty much the same: gpg --batch --decrypt-files [FILES] But both during encryption as well as decryption the original file permissions are lost: $ gpg --batch --recipient aram --encrypt-files foo $ ls -l foo* -rw------- 1 aram aram foo -rw-r--r-- 1 aram aram foo.gpg $ rm foo && gpg --batch --decrypt-files foo $ ls -l foo* -rw-r--r-- 1 aram aram foo -rw-r--r-- 1 aram aram foo.gpg I am OK with it during encryption, I can set the file permissions manually. But during decryption, as well as posing a security risk, some files like ssh keys use functionality without proper permissions. Is there a mechanism that retains file permissions during batch decryption? Of course I can loop over the files, read the permission, decrypt and then set the permissions again. But that kind of defeats the point of batch decrypting. There is an open issue on gnupg.org that's 4 years old now and hasn't had much activity since then: https://dev.gnupg.org/T2945
As @a-b and @frostschutz suggested, wrapping the files in a tar file and then encrypting is an option. However, I would like to have access to the original file structure without decrypting. For now, I have resorted to aligning the file permissions after the batch decryption. This has the additional benefit of aligning permissions when the decrypted files are already lying around on disk: gpg --batch --decrypt-files $files for encrypted in $files ; do decrypted=${encrypted%.gpg} chmod --reference="$encrypted" -- "$decrypted" done Of course, the alignment can also be done after each decrypted file: for encrypted in $files ; do gpg --decrypt-files "$encrypted" decrypted=${encrypted%.gpg} chmod --reference="$encrypted" -- "$decrypted" done If you want to be absolutely sure that the decrypted file never has more permissions than the encrypted file, you can use a temporary dummy file and force gpg to overwrite it: for encrypted in $files ; do decrypted=${encrypted%.gpg} touch "$decrypted" && chmod --reference="$encrypted" -- "$decrypted" gpg --yes --decrypt-files "$encrypted" done The same mechanism can be used for aligning permissions after encryption. I have not done any performance testing, not sure if one of the options is faster. I will not accept this as an answer right away, maybe somebody comes up with a better solution than this.
How do I decrypt files with gpg / gnupg without loosing the original file permissions?
1,661,603,103,000
My local computer has Debian 10 and I'm using Dolphin on KDE. I am using it to connect to a remote computer running ubuntu 16.04. I am able to connect and browse through the files using the sftp command in Dolphin: sftp://{username[:password]}@{domain}/{path} My user on the remote computer is a sudoer. From my local computer, I can open the file on the remote computer I want to edit, but when I try to save it I get "Access is denied". The remote file's permissions are set to 674, and my user account on the remote computer is in the group that the file's group is in. I'm not sure why access is being denied. Shouldn't anyone in the group have write access?
On UNIX/Linux a directory is just a "list" of filenames and inodes. If you already got write permission to an existing file, you should be able to modify it. But to create/delete a file in a directory, one must have write permission to the directory itself. sudo seems irrelevant here, although one could call remote /usr/lib/ssh/sftp-server via sudo - eg. sftp -s '/usr/bin/sudo /usr/libexec/sftp-server' <remotehost>. From the 3rd comment I suppose the editor was using FUSE via sftp and was creating a temporary file while editing the original one, and as the author didn't have write permission for the directory it failed.
sftp permissions access denied
1,661,603,103,000
I would like to set up an account on a CentOS 7.8 that can allow/deny ping (icmp echo) "on demand". This works great logged as root, example : echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all >>> Ping on echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all >>> Ping off I have a user "limiteduser", who is member of a group called "limitedgroup" What I have tried so far : First solution - use of sysctl Based on this thread : https://askubuntu.com/questions/692701/allowing-user-to-run-systemctl-systemd-services-without-password I created a file /etc/sudoers.d/limited %limitedgroup ALL=NOPASSWD: /sbin/sysctl sysctl -w net.ipv4.icmp_echo_ignore_all=1 %limitedgroup ALL=NOPASSWD: /sbin/sysctl sysctl -w net.ipv4.icmp_echo_ignore_all=0 Unfortunately, logged as limiteduser, I'm still asked for a password: sudo sysctl -w net.ipv4.icmp_echo_ignore_all=1 [sudo] password for limiteduser: Second solution - using file /proc/sys/net/ipv4/icmp_echo_ignore_all It seems that it is not allowed to change permissions on /proc filesystem. AFAIK it is hard-coded in the kernel. Ex: [root@centOS ~]# setfacl -m u:limited:rwx /proc/sys/net/ipv4/icmp_echo_ignore_all setfacl: /proc/sys/net/ipv4/icmp_echo_ignore_all: Operation not supported I've also tried chown, chmod - no chance.
Your sudoers lines have sysctl in them twice. Try this instead %limitedgroup ALL=NOPASSWD: /sbin/sysctl -w net.ipv4.icmp_echo_ignore_all=1 %limitedgroup ALL=NOPASSWD: /sbin/sysctl -w net.ipv4.icmp_echo_ignore_all=0
Allow/Deny ICMP "on demand" from normal user (Sysctl, Sudo, /proc)
1,661,603,103,000
I have changed my windows machine to Artix linux. And I had bunch of music in the windows so I just kept them in drive and moved them over to new Artix installation. At first, the permissions of files and directories was insane, everyone had execute permissions for all directories and files(because they were coming from windows). So I changed them with runnign chmod -x {dirs and files}. Because I have done all the installation and the moving the folder over as root, obviously, the owner of the files was root. So I changed them with chown -R murad rammstein (all my music is in that folder). But when I try to cd rammstein I get cd rammstein/ Permission denied. So what is the problem? The permissions and owner of the folder drw-r--r-- 9 murad wheel 4096 Jan 31 15:54 rammstein All the other folder and files are the same, for example the directories inside of rammstein are drw-r--r-- 2 murad wheel 4096 Jan 31 15:53 rammstein-herzeleid-1995 <and 5 different folders with the same perms/owner> And the songs' permission inside of an album folder -rw-r--r-- 1 murad wheel 9688925 Jan 31 15:53 rammstein-asche-zu-asche.mp3 From here it's obvious that I can, at least, view those folders and files. But I'm not sure a simple cd gives Permission denied error.
via comments of @Uncle Billy and @waltinator: Directories should be executable in order to search it. So change the permissions of relevant directories with chmod +x <folder>
Cannot cd into directory because of permission, but directory is mine [duplicate]
1,661,603,103,000
I want all the newly created or moved files in a directory to inherit the permissions from the parent directory. For that I did: chown -R myuser:myuser /home/directory/ chmod -R 2774 /home/directory/ chmod g+s /home/directory/ So all the files inside that directory have the correct group, but not the correct permissions: 0644. Is there a way to keep that 2774 permissions for all files so the group has access to write/change files ?
Normally, the UMASK is used to for the permissions. The default UMASK is normally 0022 (these are the bits that are removed from the permission). You could change the UMASK to 0002. You can enlarge the permissions system-wide or just for a single user. The UMASK is linked to the creation, not to the filesystem. If you want the filesystem to determine the permissions, you should probably use ACLs. Personally, I'm not a fan of those (because of manageability), but setfacl -Rm g:somegroup:rwX /home/directory should do what you want. Third alternative is a cronjob that sets the permissions every minute, but I would no go there.
Linux - Inherit file permissions from parent directory
1,661,603,103,000
Hello I try to follow this Postfix/Dovecot tutorial series: https://www.youtube.com/watch?v=njiNRppQNJw&list=PLibQjquhfgjjosRrZxlDepXfehDXuQJu_&index=5 When I run dovecot: sudo service dovecot restart sudo service dovecot status I get: Active: failed Unlike postfix who is active normally. I tried: dovecot -F to see what has failed. (suggested in: https://stackoverflow.com/questions/8319151/how-to-start-dovecot) And it said: doveconf: Fatal: Error in configuration file /etc/dovecot/conf.d/10-ssl.conf line 12: ssl_cert: can't open file /etc/dovecot/private/dovecot.pem: Permission denied I tried to look at the permissions on this file: sudo ls -l /etc/dovecot/private/dovecot/pem And got: lrwxrwxrwx 1 root root 36 nov. 21 14:04 /etc/dovecot/private/dovecot.pem -> /etc/ssl/certs/ssl-cert-snakeoil.pem I tried to change those permissions: sudo chmod -R 700 /etc/dovecot/private/ But it hasn't worked out. I tried to check if I missed a curly braces while making changes in configurations files. And so far I haven't found anything wrong. Any ideas why it's not working? Thanks for you help!
as per the information you've provided above /etc/dovecot/private/dovecot.pem is a symbolic link to the file at /etc/ssl/certs/ssl-cert-snakeoil.pem . If you don´t have a certificate file in that path it will fail. To do so: sudo apt-get install ssl-cert sudo make-ssl-cert generate-default-snakeoil sudo usermod --append --groups ssl-cert yyuu ls -l /etc/ssl/certs/ssl-cert-snakeoil.pem as mentioned here: https://gist.github.com/yyuu/4335041
Dovecot Active:failed because of ssl_cert: can't open file /etc/dovecot/private/dovecot.pem: Permission denied. Why?
1,661,603,103,000
I am glad I found this workaround, but maybe someone can explain this to me. I became so frustrated with it that I even explicitly spelled out the pathname each time. I cannot remove files with a command run from a shell script which works fine if run directly in the CLI … For … security reasons? … Maybe? I don't know. There's no error message either – it seems like a success. But nothing happens. #!/bin/bash sudo chown -R $USER:$USER "/home/user/project/uploads" sudo chmod -R 777 "/home/user/project/uploads" sudo rm -rf "/home/user/project/uploads/media/*" # ‹——— But if I do the same with moving it works fine ¿!?¡ #!/bin/bash DIR="/home/user/project/tmp/media" if [ ! -d "$DIR" ]; then mkdir "$DIR" fi sudo mv "/home/user/project/uploads/media" "/home/user/project/uploads/delete-me-manually" sudo mv "/home/user/project/tmp/media" "/home/user/project/uploads/media" Where's the sense in that? Why is remove not working in the first place? The file permissions are correct [1] and the paths don't contain spaces or other characters. What else could be the issue? Would be nice if my script wouldn't leave behind trash that I have to manually delete. File permissions and ownership of script are: -rwxr--r-- 1 user user 26K Nov 19 16:23 my-script.sh Shell matches file shebang: echo $0 bash Script is called such (not prefaced with bash or sh): $ ./my-script.sh File permissions and ownerships of dir are: drwxr-xr-x 8 user user 4,0K Jul 22 21:02 /home/user/project/ drwx------ 8 user user 4,0K Nov 19 10:44 /home/user/project/tmp/ # At start of script drwxr-xr-x 9 www-data www-data 36K Nov 19 16:35 /home/user/project/uploads/ drwxr-xr-x 65 www-data www-data 4,0K Nov 19 11:11 /home/user/project/uploads/media/ # After changing it. drwxrwxrwx 9 user user 36K Nov 19 16:35 /home/user/project/uploads/ drwxrwxrwx 65 user user 4,0K Nov 19 11:11 /home/user/project/uploads/media/ CLI user and script user are identical (as tested with whoami).
You're not doing the same thing with mv as with rm. Look at the path arguments you give to them: rm -rf "/home/user/project/uploads/media/*" mv "/home/user/project/uploads/media" ... "/home/user/project/uploads/media/*" is quoted, so the * is not special, and will be passed to rm as is. It goes on to remove a file literally called /home/user/project/uploads/media/*. There probably isn't one. You don't get an error message because you used the -f flag, which tells rm to "Ignore nonexistent files and missing operands, and never prompt the user." (as the GNU manual puts it). The POSIX spec is even more explicit about -f inhibiting any error or warning messages: For each file the following steps shall be taken: If the file does not exist: a. If the -f option is not specified, rm shall write a diagnostic message to standard error. b. Go on to any remaining files. If you didn't use -f, it would say something like: rm: cannot remove '/home/user/project/uploads/media/*': No such file or directory Or, if you did the same with mv, as in mv "/home/user/project/uploads/media/*" ..., it would complain, even with mv -f. Even unquoted, /home/user/project/uploads/media/*, isn't the same as /home/user/project/uploads/media. The other expands to a list of all files in directory (except dotfiles, usually), while the other names the directory itself. Apart from dotfiles, there's the difference that rm -r .../media/* would leave the directory media itself, while rm -r .../media would remove it, too. You didn't show how you did run it interactively, but I'm betting you didn't quote the glob there.
Can move but cannot remove from shell script
1,661,603,103,000
I need to connect to a remote Linux server over SFTP and read the entire folder structure of the server. I would like to list all directories, even directories with no read permissions, and preferably without changing the permissions of the directories. I would like to avoid using root, and I think that a good solution could be to create a "read only" root. When searching for a solution online, I found the CAP_DAC_READ_SEARCH capability. However, capabilities require me to specify a filename, and I don't think I would like the capability to apply to the SSHD process. How can I create a user with the needed permissions?
sftpsrv=/usr/libexec/openssh/sftp-server cp -a ${sftpsrv} ${sftpsrv}.super chmod 500 ${sftpsrv}.super chown someuser ${sftpsrv}.super /sbin/setcap cap_dac_read_search+ep ${sftpsrv}.super You'll need to connect to your server this way: sftp -s /usr/libexec/openssh/sftp-server.super address And it works! ls -la /tmp | grep TEST drwx------. 2 root root 60 Oct 29 13:08 TEST sftp -s /usr/libexec/openssh/sftp-server.super localhost user@localhost^s password: Connected to localhost. sftp> cd /tmp/TEST sftp> ls 123 /tmp/TEST is owned by root and has 700 permissions. Here's a possible untested solution in case your client is unable to request a custom sftp-server binary: Match User someuser Subsystem sftp /usr/libexec/openssh/sftp-server.super
Creating a user with read permissions to all directories in a Linux server
1,661,603,103,000
I'm trying to make my website, hosted on my CentOS 8, load up background.png file that is located on the same directory as rest of the website (/var/www/html) but the website refuses to load it and when I go directly to localhost/background.png I get an access denied -error. On the error log I get "AH00132: file permissions deny server access". My stylesheet and PHP files on the same directory work fine. I've looked up different ways to solve this online but I just can't seem to fix it and it has gotten really frustrating. I should only need to use one image (at least for now) for my website so I could theoretically use one that is hosted online but for a couple of reasons I prefer not to. Things I've tried: Used chmod 755 to the .png file and even used chown/chmod --reference from an accessible file have mod-mime "AddType image/png .png" don't have .htaccess other than some password related stuff for my phpmyadmin added "AllowOverride All, Allow from all, Require all granted" on the httpd conf under the /var/www/html -directory bracket restarted httpd cleared the browser Any other ideas? Outside of basics I'm a newbie when it comes to Linux so don't use fancy terms pls :p EDIT: Issue was on SELinux. After following this https://superuser.com/a/988862 guide I managed to let SELinux allow read access to the file. Thanks for the help!
You should check if SELinux is enabled on that server and in that case if it may be the one blocking access to Apache. You should look how was the file tagged, then fix the configuration or relabel the file.
Apache permission issue with accessing an image (CentOS)
1,661,603,103,000
I've mounted a samba share to /mnt/nas with an fstab entry. I can read everything, but sudo is required to write to it (permission denied on touch test.txt but not sudo touch.txt). I tried: chown -R user:user /mnt/nas and chown -R user /mnt/nas of course as root and with my username. When I don't specify the group, I get an error about being unable to read lost+found, which I don't think I should care about. ls -l does not show write permissions for my user either way. The question Samba non-root user can't write to share 's accepted answer just tells me to change permissions, which is unhelpful. This: Mount issues with Samba under non-root user just tells me to read man pages, which I have tried. I have been unable to find an answer. I assume there's nothing magical about my SMB share and I'm just doing a bad job with the chown command. What should I be doing differently?
I found the following on the mount man page: Mount options for smbfs Just like nfs, the smbfs implementation expects a binary argument (a struct smb_mount_data) to the mount system call. This argument is constructed by smbmount(8) and the current version of mount (2.12) does not know anything about smbfs. Which lead me to the smbmount man page: WARNING: smbmount is deprecated and not maintained any longer. mount.cifs (mount -t cifs) should be used instead of smbmount. Which lead me to the mount.cifs man page: mount.cifs mounts a Linux CIFS filesystem. It is usually invoked indirectly by the mount(8) command when using the "-t cifs" option. File And Directory Ownership And Permissions The core CIFS protocol does not provide unix ownership information or mode for files and directories. Because of this, files and directories will generally appear to be owned by whatever values the uid= or gid= options are set, and will have permissions set to the default file_mode and dir_mode for the mount. Attempting to change these values via chmod/chown will return success but have no effect. When the client and server negotiate unix extensions, files and directories will be assigned the uid, gid, and mode provided by the server. Because CIFS mounts are generally single-user, and the same credentials are used no matter what user accesses the mount, newly created files and directories will generally be given ownership corresponding to whatever credentials were used to mount the share. If the uid's and gid's being used do not match on the client and server, the forceuid and forcegid options may be helpful. Note however, that there is no corresponding option to override the mode. Permissions assigned to a file when forceuid or forcegid are in effect may not reflect the the real permissions. When unix extensions are not negotiated, it's also possible to emulate them locally on the server using the "dynperm" mount option. When this mount option is in effect, newly created files and directories will receive what appear to be proper permissions. These permissions are not stored on the server however and can disappear at any time in the future (subject to the whims of the kernel flushing out the inode cache). In general, this mount option is discouraged. It's also possible to override permission checking on the client altogether via the noperm option. Server-side permission checks cannot be overriden. The permission checks done by the server will always correspond to the credentials used to mount the share, and not necessarily to the user who is accessing the share. This explains why your attempts to chown don't do anything. I've never actually mounted or configured an smb share, so I'm kind of guessing, but it seems like the fstab entry should probably look something like this: //SERVER/sharename /mnt/mountpoint cifs _netdev,username=myuser,password=mypass,uid=xxx,gid=xxx 0 0 Where you populate the uid with your user's ID, and the GID with your user's id. (NOTE that you may need forceuid and forcegid) The username and password options are used for authentication to the samba share. Another (and probably the best) option would be to setup a proper usershare: Arch Wiki - Samba Usershare
Unable to write to mounted dir (after chown)
1,661,603,103,000
I have a problem, I need to give an access to someone, but the only way to connect to the database is via SSH, so if I have understood everything correctly, I need to create him a linux account (on a Debian 10 machine), the user created doesn't have any right to write in folder, so I guess he can't break anything. But the problem is that he can read any file in the filesystem, I don't really know what is the best practice, I know chmod could fix everything but I don't know if it is a good practice to remove all rights from others and changing the group of every single file to my main linux account. I guess I should remove all the execution rights of the command under the /bin folder and change the group of the file? Thanks for reading! I hope I was clear.
What you asked for... What you are looking for is chroot. This will set the / root of the filesystem to a location of your choice. If you chroot to /home/bob for the user bob this location will look like / for bob. He will not see the rest of the filesystem. Because of this you want to place any programs he needs to run below this folder. As we now know of chroot we can then find plenty of answers and guides: How can I chroot ssh connections? Chroot users with OpenSSH: An easier way to confine users to their home directories Chrooted SSH/SFTP Tutorial (Debian Lenny) What you want... If the database is accessible from the Debian machine and that is all what is needed then you are looking for a SSH tunnel. You still need to have a user account but this can be locked totally down. The important SSH settings are: AllowTcpForwarding yes - we are allowed to have a tunnel ForceCommand /bin/false - if you try to log in via ssh you will not get a shell ChrootDirectory /opt/dummy_location/%u - If you somehow get a shell anyway we have limited view of the filesystem to an empty location With this knowledge we can again find plenty of prior art: ssh tunneling only access How to restrict an SSH user to only allow SSH-tunneling? The above handles the ssh connection. If the user has physical access to the server then remember to set the shell for the user as well: usermod -s /bin/false userbob With the above in order then you can search around to see how to connect with any database client. As all the magic with SSH happens on the network layer this can work for all clients! When the tunnel is up it looks like the database is running on the local machine. Some clients are aware of SSH tunnels and make your life a little easier. A common client would be HeidiSQL - see How to connect to a MySQL database over a SSH tunnel with HeidiSQL. If you go the tunnel route then please please please test with a regular account first to make sure it works before you start to lock down the tunnel user! And finally you should be using SSH keys instead of passwords. But this combined with the complexity of chroot is best left as the last thing to implement.
Removing commands from a specific user
1,661,603,103,000
So I have a MacBook, running macOS Catalina (which is Unix compatible BSD based). I am buying a new Mac and I want to copy a lot of photos and other bits (like GPG keys, SSH keys, etc) to an external hard-drive, and then when my new machine arrives, copy the files over to the same machine. Currently files look like this: .rw-r--r-- 1 312 john staff 13 Dec 2019 gpg.keys If I copy this to an external disk with cp -a (which is effectively cp -pPR), and later to the new MacBook (to the same home folder with the same name, assuming I set up a john user on my new Machine), will everything be ok with permissions, or would the two john users be 'incompatible' from a permissions perspective. Maybe I'm over-complicating this, but I want to make sure files have the right permissions... Maybe one further illustration, if I copy a file with permissions for John from a local machine, to an external FAT32 drive, then back to a user Dave on a new machine, how does cp handle that?
You can do that. Both John accounts need the same UID. Look for the UID in the old machine (in /etc/passwd 1st field with numbers after john) and then set up the new computer with john and the same UID. Say we found john had uid 1234 on the old computer. to add the user john with ID 1234 to the new computer useradd -u 1234 -c "John The Ripper" john The other thing you could do so you dont have to match UID's is when the files get to the new computer as root do a recursive chown to get the files owner set to the new john. Then you wont have to match the UID in the two computers. chown -R john:john /path/to/drive/ Either method will work and give you the same results. About your 2nd question. When you copy (cp) a file the owner is changed to the user that copied it. If you move (mv) a file the attributes and owner stay the same. so to answer your question if you copied the file as dave it will have the owner dave. If you move the file it will keep the original owner john. if you copy files as root then root will own them. Note the UID is what controls the file ownership. to test you can do useradd -u 2345 jimi su - jimi from root touch /tmp/jimifile ls -lah /tmp/jimi* (jimi owns jimifile now) userdel -r jimi ls -lah /tmp/jimi* (will show un-owned jimifile with user id 2345) useradd -u 2345 janis ls -lah /tmp/jimi* (now will show janis owns jimifile)
Really basic question on copying files between users and machines
1,661,603,103,000
I am making backups of all databases of MySQL into separate gnu-zip files using crontab. I also want to delete backup files older then 1 day. I am using below command to delete the old files, but it only works through terminal. If I set cronjob for same command then it does not work. I don't know what is wrong. Going on my command is below: find path -type f -mtime +0 -delete I also can't find any fault in setting up cronjob: 0 0 * * * /path/auto_delete_backup_database.sh >/path/auto_delete_backup_database.log any help will be appreciated. UPDATE as @Kusalananda mentioned i ran ls -l and result is as displayed in below screen shot So is it because .sh file does not have required permission to be executed? if so, how can I grant that permission?
According to what you are showing in the question and saying in comments, your script is not executable and does not contain a #!-line. At a bare minimum, you should make the script executable with chmod +x /path/auto_delete_backup_database.sh and give it a proper #!-line: #!/bin/sh (this needs to be the very first line of the script, with no spaces before it). When the script is not executable, it will not be able to be used as a script at all. Trying to run such a file would return a "Permission denied" error (your cron daemon may well have tried to send you email messages telling you about this). Without the #!-line telling the calling shell what shell interpreter to use to run the script, it depends on what shell is calling it what would happen. You should always have the appropriate #!-line at the start of a script. In this case, since no special bash features are used, it's enough to use /bin/sh. You could obviously also schedule the find command directly with cron: 0 0 * * * find path -type f -mtime +0 -print -delete >/path/auto_delete_backup_database.log 2>&1 I think this is appropriate for single-command cron jobs. Anything more fancy is better scheduled as part of a wrapper script. I added -print to the find command above, which will make it output the names of the files that it tries to delete (it would be silent otherwise).
can't delete files older then x days through cronjob
1,661,603,103,000
My program that's running on Ubuntu 18.04 executes a select statement into outfile into my /home/tmp directory, but all files that are created by mysql are locked. I can manually unlock them but our program needs to read the file right after they are created, so I need them to be unlocked upon creation. I've already set the folder permissions to 777, but still, any newly created files are locked. The files are owned by mysql server and have no access rights for "Others" users. I can't change these permissions as they are not owned by me. the mysql server that's running is v8.0.18 In my.cnf, I have set secure_file_priv to this /home/tmp folder path. We have the same program running with mysql server 5.7.27 on another computer and the files are not locked on there, so I'm not sure what the problem is. Please help! Thanks. EDIT: clarifications by "locked" I mean the file has a padlock symbol on the icon when viewing it in files. the error message I get when trying to open the file says "Access to "/home/tmp/filename" was denied. my select statement is something like " SELECT * INTO OUTFILE '/home/tmp/file.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM device "
You've run in to this note from the MySQL documentation (see https://dev.mysql.com/doc/refman/8.0/en/select-into.html): As of MySQL 8.0.17, the umask for file creation is 0640; you must have sufficient access privileges to manipulate the file contents. Prior to MySQL 8.0.17, the umask is 0666 and the file is writable by all users on the server host. So the files are only readable to whichever group MySQL is running as. You could add your user to that group, but that might give access beyond what is desired (e.g., direct access to the database datafiles). Another option, if your filesystem supports ACLs (most do) is to see if a default ACL will override the permissions MySQL is setting, try something like this (on the directory the dumps are being written to): sudo setfacl -m 'd:u:«YOUR-USER»:r' /home/tmp This sets the "default" ACL to automatically put an ACL on any files created in /home/tmp allowing «YOUR-USER» to read them. If you need to write to them as well, you'd use rw instead.
MySQL SELECT into outfile Files are Locked
1,661,603,103,000
I have the following test program: //File: egid_test.c #include <stdio.h> #include <unistd.h> int main(int argc, char** argv) { int egid = getegid(); printf("my effective group is %d\n", egid); return 0; } I run the following series of commands: $ sudo groupadd so_test $ grep so_test /etc/group so_test:x:1002: $ gcc egid_test.c $ ./a.out my effective group is 1000 $ sudo chown :so_test a.out $ sudo chmod g+s a.out $ ./a.out my effective group is 1000 I expect the result of the last line to be "my effective group is 1002". Co-workers get exactly that. I don't. Why? How do I debug what's wrong with my machine and/or configuration? (Ubuntu 16.04.6 LTS) **use sudo groupdel so_test after you try this to undo group creation Additional Info: $ ls -l a.out -rwxrwsr-x 1 ashelly so_test 8664 Nov 1 12:17 a.out $ stat a.out File: 'a.out' Size: 8664 Blocks: 40 IO Block: 4096 regular file Device: 33h/51d Inode: 23466994 Links: 1 Access: (2775/-rwxrwsr-x) Uid: ( 1000/ ashelly) Gid: ( 1002/ so_test) Access: 2019-11-01 12:17:46.149582840 -0700 Modify: 2019-11-01 12:17:08.949341154 -0700 Change: 2019-11-01 12:38:01.454109385 -0700 Birth: - $ df . Filesystem 1K-blocks Used Available Use% Mounted on /home/ashelly/.Private 660427896 45250096 581606988 8% /home/ashelly $ mount | grep /home/ashelly /home/.ecryptfs/ashelly/.Private on /home/ashelly type ecryptfs (rw,nosuid,nodev,relatime,ecryptfs_fnek_sig=<...>,ecryptfs_sig=<...>,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs) Is it the 'nosuid' flag on the encryptfs that's causing problems?
Thanks to @icarus, I realize that my home directory, unlike my co-workers', is mounted from an ecryptfs encrypted partition, which has the nosuid flag set. (Apparently to patch a security hole). This prevents the sgid bit from taking effect. If I move my program to /usr/local/bin, which doesn't have the nosuid flag, it correctly reports the effective group. At this point, what I need is a good answer to this question about ecryptfs and nosuid.
Why does getegid work for others but not me?
1,661,603,103,000
I see there is a question similar to this but that answer relates to Git, which I am not using here. I often make small scripts that I send to others with very limited command-line skills to run. Is there a way to package my script so that users don't need to change permissions for my executable? I tried to package my script such that the first executable script changes the permissions for all the others, but at this point I have been unable to find a way to ship that first script in a way such that the user does not have to give it execute permission i.e. chmod +x First_script Am I running into this wall because there is no solution?
A simple way is to make a tarball, a compressed tar archive. It you create it with root privileges and the user extracts the content also with root access, the permissions should be preserved. Examples sudo -cvzf filename.tar.gz directory # create a compressed tar archive of the directory and its content cd /to-where-you-want-it-extracted sudo -xvzf filename.tar.gz # extract the content from the archive There are details in man tar and you find good tutorials about tar via the internet.
How to ship files as executable? (no git)
1,661,603,103,000
I created a small script as the root user... #!/bin/bash cat /etc/shadow and set the setuid bit and placed it within the guest folder. When I ran the script as guest, it showed permission denied. Why? I had the root setuid bit set on it which should execute it with the root privileges as root user created the script.
The reason this doesn't work is that the SUID bit is ignored on interpreted scripts. If you wrote a C program that executed the same command, then it would work.
How to use the "setuid" bit? [duplicate]
1,661,603,103,000
I've just changed the /etc/ssh/sshd_config file on a server, where I want to deny all users except for one in a specific group. This is because I am in the disallowed group myself, but as the server's maintainer I want to be able to access it through ssh. So my problem is that, as it says in the man page, the order of processing rules is "DenyUsers, AllowUsers, DenyGroups, and finally AllowGroups", which (if I'm understanding this correctly) makes it impossible to do something like: DenyGroups student AllowUsers myself because the DenyGroups is more important than the AllowUsers. I have also tried to exclude myself from the DenyGroups by adding a specific Match User myself: DenyGroups student Match User myself AllowUsers * But that did not have any effect either, despite the manual saying "the keywords on the following lines override those set in the global section of the config file". How would I go about disallowing the whole group of students except for myself?
As @muru has pointed out, when the manual says "the keywords on the following lines override those set in the global section of the config file", it means you have to use the same keyword, so you can do the following: DenyGroups student Match User myself DenyGroups none This worked for me.
How to allow only one user in a group in sshd_config
1,661,603,103,000
I want to mount all text files without execute permission to eliminate the (Run in Terminal - Display - Run) message, which appears every time I open a text file in Linux Mint. I have the following line in my fstab: /dev/sda7 /media/myname/Programs ntfs-3g defaults,uid=1000 0 0 I tried to add umask=111 but all files had the permission displayed as -????????? and I lost the access to all files.
MS-Windows sets the execute bit on every file. (One of the reasons for its poorer security). noexec is the option to disable excitability. Using the umask will stop directories from being traversable, because directories need execute permission. Therefore mount with option noexec.
Removing mount default execute permission of text files
1,560,005,118,000
It is possible for a program to inherit or be passed an open file descriptor, for a file it would not otherwise be permitted to read (or write). For example: (sudo -u nobody echo "hello world") > ~/test-file (sudo -u nobody cat) < ~/test-file Question: If you inherit a current directory (or root directory) which your user would not otherwise be permitted to access, are you allowed to access it?
No. # sudo -u nobody ls . ls: cannot access '.': Permission denied # sudo -u nobody ls -d . ls: cannot access '.': Permission denied # chmod o-rwx /chroot # chroot --userspec=nobody:nobody /chroot chroot: failed to run command ‘/bin/bash’: Permission denied The same is also true for write access to the current directory (or root directory). If it was not, I suspect it would be a source of security bugs :-). Similar behaviour applies to file descriptors opened with O_PATH on Linux. POSIX (which does not define O_PATH) implies that openat(fd, path, ...) and similar functions will re-check permission to access the open directory fd, unless fd was opened with O_SEARCH. Linux does not support O_SEARCH.
Can you still access the current directory (or root directory), if your user does not have permission on that directory?
1,560,005,118,000
Sometimes on old Linux systems, I experience that find doesn't support -writable and -readable tests, which test whether the file or directory is writable/readable resp. for the current user. Say, I want to express -writable; then -perm -0002 would not be equivalent, since it doesn't test whether the user has write permissions by means of owner/group. How can I express find's -writable test by means of find's other tests (e.g. -perm)?
There's no convenient way. That's why GNU find added -readable and friends. You can build an expression that approximates the permission test by enumerating the groups that the user is in. Untested. can_access="( -user $(id -u) -perm -0${oct}00 -o (" for g in $(id -G); do can_access="$can_access -group $g -o" done can_access="${can_access% -o} ) -perm -00${oct}0 -o -perm -000${oct} )" find … $can_access -print This doesn't give the correct result in some cases, for example if there are access control lists, or in edge cases such as -rw----r-- to deny access to a group. You can check for the edge cases with the same technique as above, but the expression gets even more complex. For access control lists, you need to invoke a tool that supports them. Languages such as Perl and Python provide easy access both to the access(2) function and to the functionality of find. In Perl, with File::Find and -r/-w/-x (which use the effective uid and gid of the Perl process — use -R/-W/-X to check with the real uid/gid like access(2), and use the filetest 'access' pragma if your Perl isn't too ancient to have it to support things like ACL): use File::Find; use filetest 'access'; find(sub { if (-r $_) { print "$_ is readable\n"; } }, '.'); In Python, with os.walk and os.access (which uses the real uid and gid of the Python process, like access(2)): import os for dirpath, dirnames, filenames in os.walk('.', ): for filename in filenames: filename = os.path.join(dirpath, filenames) if os.access(filename, os.R_OK): print(filename + ' is readable\n') The only fully reliable way is to try to open the file. This requires an external utility, so it'll be slower. To test for readability of a regular file: find … -exec sh -c 'exec 2>/dev/null; : <"$0"' {} \; … To test for writability, use : >>"$0" (this opens the file for appending, so it'll fail if the file isn't writable, but it doesn't actually modify anything, and in particular won't update the modification time). To test a directory for readability, use ls -- "$0" >/dev/null. To test a directory for executability, use cd -- "$0". There's no passive test for executability of a regular file, for writability of a directory, or for access to most non-regular files.
How to express `find`'s -writable and -readable tests, when they are not available?
1,560,005,118,000
Here's the folder: drwxrws--- 2 smmsp smmsp 4096 May 25 22:47 mqueue-client/ So I did this... usermod -a -G smmsp www-data # groups www-data www-data : www-data smmsp But I still get this error in mail.log sendmail[13152]: NOQUEUE: SYSERR(www-data): can not chdir(/var/spool/mqueue-client/): Permission denied What's your recommendation?
Purging and reinstalling sendmail was the solution. And turns out I didn't need Postfix, so that might have been part of the problem too. I'm not exactly sure though. apt-get purge sendmail sendmail-cf m4 postfix In any case, it wasn't necessary for me to modify the www-data user.
NOQUEUE: SYSERR(www-data): can not chdir(/var/spool/mqueue-client/): Permission denied
1,560,005,118,000
I have a script file that is currently in sudoers, and for security I want this file to be read only... so I issued the following chmod: chmod 555 test.sh Now the permissions on this file are -r-xr-xr-x However, when I go to vi this file, even though it says W10: Warning: Changing a readonly file, I can still do "w!" to force save it. How can I also disable force saving so that a regular user wont be able to write to this file at all?
On Linux systems, set the immutable file attribute with chattr. sudo chattr +i file A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute. Use lsattr to list a file's attributes. lsattr -l myfile myfile Immutable The downside of doing this is that you won't be able to write to the file even as the superuser (root). You will need to remove the immutable attribute first: sudo chattr -i file On macOS, the chflags command is used to set and reset the immutable flag. To set: chflags uchg file and to unset, or clear: chflags nouchg file These operations may be performed by either the owner of a file or the superuser. With macOS, using the -Ol flags with ls show the immutable flag as uchg when set.
stop force save on a file with read only permission
1,560,005,118,000
I have my computer start secure shell in a chroot system at boot. (All the normal directories are bind mounted in the chroot system /run, /dev, /dev/pts, /sys, /proc). After logging in to the chroot environment and trying to start screen, I receive the error. Directory '/run/screen' must have mode 775 So I set chmod 775 /run/screen in my start scripts. Everything was working fine, but now I've run into a new problem. When I try to run screen on my computer host system, I receive the error. Directory '/run/screen' must have mode 777 Mode 777 is the default permission at boot. So the permissions screen requires for the host and chroot are different for some reason. How can I get screen to run in both host and chroot environment? Note: The host is Ubuntu Mate 18.04 LTS Bionic (graphical desktop), and the chroot is Debian 9 Stretch (headless personal server).
This sounds similar to this screen bug detailed for Ubuntu. You are sharing the /run directory between your host and chroot, but I suspect they are running different versions of screen and the the Ubuntu one is exhibiting this bug and should be updated to a version that does not have this problem. If that does not help fix things, post the versions and permissions of both of your screen binaries as well as the actual permissions of the shared /run directory.
GNU Screen requires different permissions for chroot environment? /run/screen
1,560,005,118,000
Created file1 and gave 000 permission. [root@localhost ~]# ls -ltr file1 ----------. 1 root root 0 Jan 28 08:09 file1 Gave "test" user rw permission using access control lists: setfacl -m u:test:rw file1 file1 permission for selinux is correct [root@localhost ~]# getfacl file1 # file: file1 # owner: root # group: root user::--- user:test:rw- group::--- mask::rw- other::--- but when i see file permission it's showing 060 [root@localhost ~]# ls -ltr file1 ----rw----+ 1 root root 0 Jan 28 08:09 file1 Question : from where this 060 permission coming ?
For files that have acl(5) extended attributes, the 3 group bits from the file mask may have a different meaning -- they're the ACL_MASK, ie the maximum access rights that can be granted by the ACL_USER, ACL_GROUP_OBJ and ACL_GROUP permissions stored in the ACL extended attribute. Quoting from the acl(5) manpage: There is a correspondence between the file owner, group, and other permissions and specific ACL entries: the owner permissions correspond to the permissions of the ACL_USER_OBJ entry. If the ACL has an ACL_MASK entry, the group permissions correspond to the permissions of the ACL_MASK entry. Otherwise, if the ACL has no ACL_MASK entry, the group permissions correspond to the permissions of the ACL_GROUP_OBJ entry. The other permissions correspond to the permissions of the ACL_OTHER_OBJ entry Since you have given the test user rw permissions, and did not use the -n option of setfacl(1) ("do not recalculate the effective rights mask"), the ACL mask has been correctly set to rw.
Access Control Lists -- wrong permission?
1,560,005,118,000
For reasons I can't determine, within the last two days the "man" command stopped working on my linux server (Ubuntu 18.04). When attempting to run man <anything> I end up at a blank instance of vi (presumably because it's using vimpager somewhere in the background)... once I quit out of the vim instance I see the following errors on the console: lwobker@lwobker-vms:~$ man ls cat: /tmp/vimpager_4620/cols: Permission denied cat: /tmp/vimpager_4620/lines: Permission denied head: cannot open '/tmp/vimpager_4620/stdin' for reading: Permission denied sed: can't read /tmp/vimpager_4620/stdin: Permission denied mv: cannot move '/tmp/vimpager_4620/stdin.work' to '/tmp/vimpager_4620/stdin': Permission denied cat: /tmp/vimpager_4620/stdin: Permission denied /usr/bin/pager: 242: /usr/bin/pager: cannot open /tmp/vimpager_4620/stdin: Permission denied /usr/bin/pager: 239: [: Illegal number: This happens regardless of whether I'm running at a "regular" user, or if I do sudo man <anything> or if I do sudo bash and run it that way. Clearly there's a permissions issue somewhere but I'll be damned if I can figure out where. All the /tmp directories mentioned in the error messages are present and have read permissions set, so I can't quite figure out why all these commands are complaining. lwobker@lwobker-vms:/tmp$ ll vimpager_4234/ total 60 drwx------ 2 lwobker lwobker 4096 Nov 8 10:47 ./ drwxrwxrwt 24 root root 40960 Nov 8 10:56 ../ -rw-r--r-- 1 lwobker lwobker 11 Nov 8 10:47 1.vim -rw-r--r-- 1 lwobker lwobker 9664 Nov 8 10:47 stdin -rw-r--r-- 1 lwobker lwobker 0 Nov 8 10:47 stdin.work
It turns out that somehow the apparmor profiles for the /usr/bin/man executable were either corrupted or had be overwritten with the profiles from a different release, or something along those lines... so the permission denied warnings were coming from apparmor and not from the filesystem permission checks. Checking the syslog showed tons of messages like: audit: type=1400 audit(1541703091.843:4554): apparmor="DENIED" operation="ptrace" profile="/usr/bin/man" pid=8777 comm="ps" requested_mask="trace" denied_mask="trace" peer="/usr/bin/man" The solution was a nifty tool that I wasn't aware of called aa-logprof, which basically parses the errors from apparmor in your syslog and (interactively) asks if you want to adjust the apparmor profiles to fix the permissions.
man pages no longer rendering - lots of "permission denied" errors related to pager / vimpager
1,560,005,118,000
With the latest update of KDE, I am seeing these errors: Sep 26 23:07:30 desktop sddm-greeter[709]: inotify_add_watch(/etc/fstab) failed: (Permission denied) Sep 26 23:08:18 desktop kdeinit5[819]: inotify_add_watch(/etc/fstab) failed: (Permission denied) Sep 26 23:08:19 desktop kgpg[878]: Error loading text-to-speech plug-in "flite" Sep 26 23:08:19 desktop org_kde_powerdevil[897]: inotify_add_watch(/etc/fstab) failed: (Permission denied) Sep 26 23:08:23 desktop plasmashell[856]: inotify_add_watch(/etc/fstab) failed: (Permission denied) My /etc/fstab permissions are: -rw-r----- 1 root root 7182 Jun 26 21:51 /etc/fstab Is that not correct?
No, that's not correct. /etc/fstab is supposed to be world readable. A LOT of programs depend on this, and it's world readable on every standard Linux distribution. You're not supposed to put credentials or anything else that's actually sensitive in this file (see Does /etc/fstab need to be world readable? for how to avoid this), and hiding anything else in it would just be security-through-obscurity, which isn't actually secure at all.
inotify_add_watch(/etc/fstab) failed: (Permission denied)