While studying for the RHCE, I came across a situation where stdin redirection does not work in bash:
# file /tmp/users.txt
/tmp/users.txt: cannot open `/tmp/users.txt' (No such file or directory)
# semanage login -l > /tmp/users.txt
# file /tmp/users.txt
/tmp/users.txt: empty
However, this works:
# file /tmp/users.txt
/tmp/users.txt: cannot open `/tmp/users.txt' (No such file or directory)
# semanage login -l >> /tmp/users.txt
# file /tmp/users.txt
/tmp/users.txt: ASCII text
Why is this the case?
Update:
Permissions:
# ls -ld /tmp
drwxrwxrwt. 8 root root 4096 Jul 17 15:27 /tmp
ACLs (not an ACL mount but just in case):
# getfacl /tmp
getfacl: Removing leading '/' from absolute path names
# file: tmp
# owner: root
# group: root
# flags: --t
user::rwx
group::rwx
other::rwx
And I'm performing all commands as root (hence the bang prompt).