Hot answers tagged

18

You can modify your umask to allow (for most implementations) more read/write privileges, but not executable, since generally the requested permissions are 0666. If your umask is 022, you'll see touch make a 0644 file. Interestingly, POSIX describes this behavior in terms of creat: If file does not exist: The creat() function is called with the ...


16

Traditional unix permissions only allow user, group, other permissions as you've found. These can result in some awkward combination of groups needing to be created... So a new form of ACL (Access Control Lists) were tacked on. This allows you to specify multiple users and multiple groups with different permissions. These are set with the setfacl command ...


5

I don't think there is any faster way. You could come up with a script that copies the ownership info from a working installation, but writing the script would probably take more time than creating a new instance and starting from scratch.


3

No particular meaning, they're just treated literally. It just checks whether the last line contains exactly %%EOF. That happens to be the end marker in PostScript or PDF documents (try tail -n 1 somefile.pdf). perl expands scalar ($var) and list (@list) variables inside double quotes but not hashes/associative arrays (%hash). Note that that code is ...


3

stat(1) can show many file associated attributes by specifying special format strings to it's -c option. In your case, use stat -c '%a' ~/.ssh/authorized_keys to receive the same file mode in octal, 600. See it's manual page for a full list of supported format modifiers.


2

rename is expected to be atomic: it either completes fully or not at all. Renaming A to take the place of B is supposed to leave you with either both A and B intact (it didn't happen at all); or with only A's contents under the name B (it completed fully). As long as the system doesn't crash, that'll happen regardless of fsync (etc.) calls. If the system ...


2

The code is legal but "naive". The problem is exactly that of what happens during a crash There's a potential risk that the new data won't have space allocated to it before the directory updates, and so runs the risk of a data loss. A good app will call fflush() and fsync() to ensure the data is flushed to disk. The auto_da_alloc routines are an ...


2

Yes, ACL:s allow freely setting different rights to different users or groups. IIRC the usual group permissions limit the set of permissions that groups and users can have through ACL:s (shown as mask in getfacl), but setfacl should deal with that if you add permissions. But in some cases you need to ask if the set of permissions makes any sense. I have ...


1

You can't modify sys.stdout like that; sys.stdout is just a TextIOWrapper around real standard output, which is actually file descriptor 1. The result is that things like print (or anything that writes to file descriptor 1 directly) will totally ignore what you've done. In order to achieve true redirection, you have to do something like this: # Copy ...


1

If you don't have any lines longer than 2GB, you can use split --line-bytes=2GB From the info manual: ‘--line-bytes=SIZE’ Put into each output file as many complete lines of INPUT as possible without exceeding SIZE bytes. Individual lines or records longer than SIZE bytes are broken into multiple files.


1

Since you cannot use any of the file timestamps, you have to use another approach. These are the usual alternatives: use a naming convention (embedding the timestamp in either the filenames, or the directory names), or storing a timestamp in a related file, e.g., a hidden (dot-file) in the same directory which can be checked with a script maintain a ...


1

GNU du --max-depth=1 directly translates to BusyBox du -d 1. There's no equivalent of xargs -d; you can translate newlines to null bytes if xargs -0 is supported. du -d 1 -k | sort -nr | cut -f2 | tr '\n' '\0' | xargs -0 du -sh BusyBox has a lot of compilations to tune the compromise between size and features. If you don't have du -d, you can use du | ...


1

The BSD install found on OpenBSD systems has this piece of code in it (from src/usr.bin/xinstall/xinstall.c): if (!S_ISREG(to_sb.st_mode)) errc(1, EFTYPE, "%s", to_name); This emits the error install: /dev/fd/4: Inappropriate file type or format when it's discovered that /dev/df/4 is not a regular file. (There's a separate earlier check for /dev/...



Only top voted, non community-wiki answers of a minimum length are eligible