My bash shell requires a temp file. Suppose filename conflict is not an issue, can I say mktemp is not as good as manually touch a temp file after umask 066?
My assumption is: mktemp is a system function, compared to manually touch a file, it still takes a little bit more resource.
I've read something about ln -s etc/passwd attack, but it looks like a story decades ago when passwords were not shadowed.
Please correct me if my understanding is wrong.
Those two commands are not destined to do the same thing.
mktempcreates a file in a flexible way, and has features to make sure it uses a unique name.touchwill modify the timestamp of a file (or create it if it does not exist), but you supply the name.If you want to create an empty file for which you already have a name, then use
touch; if you are going to write to that file right after, you do not need to create it first, just redirect to it.But if you really need to make a temporary file and ensure you will not overwrite any other file,
touchdoes nothing for you. It is "lighter", maybe, but useless in this case, and you needmktemp.