3 ms·
You cannot use `sudo cat` to open a file with root privileges, because `sudo cat > foo` means "open file foo with your current privileges, then run `sudo cat`
by ben0x539 5y ago
You cannot use `sudo cat` to open a file with root privileges, because `sudo cat > foo` means "open file foo with your current privileges, then run `sudo cat` passing the file to it", and the whole root thing only happens after you already tried and failed to open the file.
I seem to get this wrong roughly once a week.
- gorgoiler 5y ago… | sudo tee foo
- readme 5y agosudo sh -c "cat > file"
- deleted 5y ago[deleted]
- icedchai 5y agoI knew a person who would give something like this as a sysadmin / devops interview question. It was framed as "'sudo cat >/etc/foo' is giving a permission denied error! what's wrong?" Usually the interview candidate would go off on a tangent...