Activity for alx
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Question | — |
How to change resolution of virtual terminal? How can I rescale the Linux virtual terminals (ctrl + alt + {f1, f2, f3, f4, f5, f6}), so that a high-resolution display doesn't make the letters too small? I'd like to use 1080 or even 720 resolution in virtual terminals (and only there; I want native resolution in ctrl + alt + f7). If that ... (more) |
— | about 1 year ago |
Comment | Post #290119 |
Re: `\` and `|`: I agree that the `\` is a bit ugly. However, I find it less readable if the pipe symbol goes to the right. It's usually something very important, so I prefer it as the first symbol. I wish sh(1) had mandatory semicolons like C, so that escaping newlines wouldn't have been necessar... (more) |
— | about 1 year ago |
Comment | Post #290009 |
@#57088 No problem. Nitpicking helps get even better answers, or just random useful info. :)
You may find it interesting that find(1), because of the library it uses for name filtering, is very slow, and grep(1), even with the overhead of a new fork(2), outperforms find(1) very easily. You can ... (more) |
— | about 1 year ago |
Comment | Post #290119 |
It is a standalone program (actually, a shell script) that is designed to search through C code.
Here's the source code: <https://www.alejandro-colomar.es/src/alx/alx/grepc.git/tree/bin/grepc>
I would love to see it being used by other people and get bug reports! :-)
Feel free to email me for... (more) |
— | about 1 year ago |
Comment | Post #290136 |
Since you write the code, you can tell your kernel that no program can create such files. Or maybe you can program it so that only root can create such files. Or maybe programs that have some capability (read <https://man7.org/linux/man-pages/man7/capabilities.7.html>).
Regarding the question of... (more) |
— | about 1 year ago |
Comment | Post #290136 |
If you fear that attackers may create files by physically writing 0s and 1s into your drive, you can encrypt the drive. If it's encrypted, you can remain sure that the only way to add files to your drive is via software, and only if you know the key.
This also removes the possibility that someone... (more) |
— | about 1 year ago |
Comment | Post #290136 |
While a kernel could theoretically have backdoors creating such files anywhere in the millions of lines of code, it usually only has one (or a few at most) place where filenames are validated.
We assume you trust the code in your kernel, because otherwise why would you use it? If you don't trust ... (more) |
— | about 1 year ago |
Comment | Post #290136 |
If you modify gnome, an attacker could create files by calling system calls directly.
You need to modify the kernel if you really want to block any software from creating files with certain characters. (more) |
— | about 1 year ago |
Comment | Post #290119 |
If you make it configurable, so that it is disabled by default and can be enabled for users that want it, maybe you could convince kernel maintainers to merge the feature. (more) |
— | about 1 year ago |
Edit | Post #290119 |
Post edited: |
— | about 1 year ago |
Edit | Post #290119 |
Post edited: |
— | about 1 year ago |
Edit | Post #290119 | Initial revision | — | about 1 year ago |
Answer | — |
A: How can I restrict filename characters? You could try and convince Linux kernel maintainers, but they are reticent to that. I wonder what they'll do after POSIX.1-202x (Issue 8) possibly will forbid those. Maybe you could patch your kernel. It would be an interesting thing to do, even if just for fun. I've never done such a thing, so... (more) |
— | about 1 year ago |
Comment | Post #290113 |
@#8049
Maybe a safe assumption is that it would be on Linux, given the name of the server. :) (more) |
— | about 1 year ago |
Comment | Post #290009 |
> All *nix systems accept everything except / and \0 in file names.
And great news, POSIX may outlaw `\n` (and a few more) soon: <https://www.austingroupbugs.net/view.php?id=251>. (more) |
— | about 1 year ago |
Comment | Post #288401 |
To add a bit more to this:
POSIX.1-202x (Issue 8) is considering outlawing `\n` (actually, characters 1 through 31) in filenames.
See <https://www.austingroupbugs.net/view.php?id=251>.
And the POSIX portable filename character set already limits the characters that one should want to use in ... (more) |
— | about 1 year ago |
Comment | Post #290009 |
> Why not `find . -type f -name '*-min.jpg-*' -print0` to avoid the `grep`?
Because the grep(1) is so much simpler conceptually. I don't need to remember of all the options from find(1) that can be used for file names (`-ilname`, `-iname`, `-ipath`, `-iregex`, `-iwholename`, `-lname`, `-name`, `-... (more) |
— | about 1 year ago |
Comment | Post #290009 |
> All *nix systems accept everything except `/` and `\0` in file names.
That's true for the kernels. Individual programs may or may not. When writing scripts like this one (which I do often), it helps not having to consider such insane file names. Usual *nix filters do not like non-portable fil... (more) |
— | about 1 year ago |
Comment | Post #290009 |
> And there is no reason to assume the random string will only have alphanumerical values.
That was my inductive guess from the small sample. If it's different, the regex could be adjusted to fit. The good thing of using `[[:alnum:]]` is that it self-documents, so any mismatches will be easily d... (more) |
— | about 1 year ago |
Edit | Post #289999 |
Post edited: Hardened versions |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: reorder, to put the safe version first |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: fix grep |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: Add safe version |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: Find only files |
— | about 1 year ago |
Edit | Post #290009 |
Post edited: |
— | about 1 year ago |
Edit | Post #290009 | Initial revision | — | about 1 year ago |
Answer | — |
A: Rename multiple files which have a variable suffix ```sh find . -type f -print0 \ | grep -z -- '-min.jpg-[[:alnum:]]$' \ | while IFS= read -r -d '' f; do find "$f" -print0 \ | sed -z 's/-min.jpg-[[:alnum:]]$/-min.jpg/' \ | xargs -0 mv "$f"; done; ``` Or, if you prefer a one-liner: ```sh find . -type f -print0 | grep -z -- '... (more) |
— | about 1 year ago |
Edit | Post #289999 |
Post edited: |
— | about 1 year ago |
Edit | Post #289999 |
Post edited: |
— | about 1 year ago |
Edit | Post #289999 |
Post edited: |
— | about 1 year ago |
Edit | Post #289999 |
Post edited: |
— | about 1 year ago |
Edit | Post #289999 | Initial revision | — | about 1 year ago |
Answer | — |
A: How to run a command on a list of files? In some cases, when you want to apply a pipeline or a complex command to each file, I find it useful to use `while read`: ```sh find . -type d \ | while read d; do find $d -type f -maxdepth 1 \ | head -n3; done; ``` Hardened version: ```sh find . -type d -print0 \ | while IFS= read -... (more) |
— | about 1 year ago |
Comment | Post #288436 |
`generate_lists | xargs some_program` works just as well, and it can pack several arguments into a single program invocation, being faster. In fact, find(1) is just a special case of `generate_lists`, so xargs(1) works in both cases better (the syntax is way simpler). (more) |
— | about 1 year ago |
Comment | Post #289936 |
Step 2 is conflating two functions:
- Finding all files in every dir.
- Filtering the previous step to just keep the first 3.
The former should be `find $dir -type f -maxdepth 1`.
The latter should be `head -n3`, maybe coupled with a `sort`, depending on what we understand by "first". (more) |
— | about 1 year ago |
Comment | Post #289936 |
```sh
$ dpkg -l | grep -e moreutils -e fd-find
ii fd-find 8.7.0-3+b1 amd64 Simple, fast and user-friendly alternative to find
ii moreutils 0.67-1 amd64 addition... (more) |
— | about 1 year ago |
Comment | Post #289936 |
```sh
$ find
.
./l1
./l1/l2
./l1/l2/f2
./l1/l2/f5
./l1/l2/f4
./l1/l2/d0
./l1/l2/d0/f2
./l1/l2/d0/f5
./l1/l2/d0/f4
./l1/l2/d0/f3
./l1/l2/d0/f1
./l1/l2/d0/f0
./l1/l2/f3
./l1/l2/d5
./l1/l2/d5/f2
./l1/l2/d5/f5
./l1/l2/d5/f4
./l1/l2/d5/f3
./l1/l2/d5/f1
./l1/l2/d5/f0
./l1/l2/d4
./l1... (more) |
— | about 1 year ago |
Comment | Post #289899 |
Thanks! That makes sense. (more) |
— | about 1 year ago |
Edit | Post #289933 |
Post edited: remove superfluous sort |
— | about 1 year ago |
Edit | Post #289933 |
Post edited: oops; we need to sort before head(1). |
— | about 1 year ago |
Edit | Post #289933 |
Post edited: sort last |
— | about 1 year ago |
Edit | Post #289934 |
Post edited: |
— | about 1 year ago |