I edited /etc/security/limits.conf to have
root hard nofile 20000
root soft nofile 10000
And added
session required pam_limits.so
to /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive.
After reboot and relogin ulimit -n still shows 1024.
If I do su and try ulimit -n again then it shows 10000. But after a relogin it goes back to 1024.