News for hackers. Stuff that matters.
Re:Linux Fundamentals by 16s on Tuesday October 11, 2011 @07:18PM (#3100842)
Very nice article. I like the coverage of "." (this directory or cwd) to show new users how to execute programs in /home, etc. One often over-looked feature of "." is that it can be used on non-executable files as well. For example, it can be used to removed a file named -f:

rm ./-f

That was actually a question for me during a Google phone interview. I kid you not.

Re:Linux Fundamentals by delinka on Tuesday October 11, 2011 @10:43PM (#3101274)
"." can be used any place you need to explicitly indicate a file in the current directory. Your "remove file '-f' from the current directory" is a fine example, but your "...can be used on non-executable files..." makes me cringe slightly - it won't magically execute a non-executable file (I do realize this is not what you mean to say...)

It works exceptionally well if you need variables for directories in a shell script. For example, if your script needs $PKG_HOME to be defined, it could be set as "/usr/bin/pkg_home/" or "./" to be prepended to other paths in the script. Setting it to "" would surely work as well as "./" but being explicit improves readability and communicates the author's intent more clearly.

So, absolute paths start with "/", relative paths may avoid "." and ".." and "/", but an explicit relative path would use "." and/or ".."

Re:Linux Fundamentals by getsat on Wednesday October 12, 2011 @03:08AM (#3101831)
You can easily trip up even experienced Linux users with examples (like that one) from the Unix Hater's Handbook.