I am preparing for a Systems Admin(linux) role for a big company(top 10 companies) and one of the requisite is knowledge of a language like perl, python or Ruby. I have a phone interview which involves sharing a editor with the interviewer, now what kind of coding exercise can I expect on a phone interview or a regular interview?
I have used shell for most of my day-to-day tasks and occasionally Perl and python for bigger tasks. Now I don't expect them to ask
Write a script that syncs AD users to LDAP.
I don't think data structures, algorithms or sorting questions apply to me role? Can you give me any examples of SysAdmin related coding questions?
Why don't you think that? Mabe not knowing the differences betwen O(n) and O(1) and O(log n) but writing good code - and scripts are code - definatly needs a basic understanding of those three things.
When I intervied for my current job I was asked at least the below quesiotns (I may have forgotten some) I was allowed to use the language of my choice.
Some sysadmin specific things:
I don't like interviews to feel like exams. It should be more about figuring out if the person is overall a good fit for the position and for the organization, and not so much about putting the interviewee on the spot. Now, sure, a good sysadmin has to be able to whip up a useful script under pressure, but it's not the same kind of pressure.
Therefore, rather than asking a series of questions, I'd be more inclined to chat a bit about scripting language preferences, culture, and so on. (This should be particularly effective for Python, Perl, or Ruby!) Generally, this should be enough to get a feel for the interviewee's engagement with the language or languages of choice, which is more important than the ability to answer some carefully-selected clever question right there on paper.
You can always ask for sample scripts to be e-mailed after the interview. (And then you can Google bits of the code to see if it's plagiarized....)
In my experience sysadmin questions in interviews tend to often be based on file processing. For example, "take this logfile and extract the unique IP addresses along with a count of each" is something I was asked in an interview not too long ago.
The FizzBuzz test remains one of favorite programming questions too.
Other folks have provided some great examples of exercises you might encounter, so I'll leave that as handled. I want to mention, though, that as important as getting the code running is making it maintainable - this is maybe more important in sysadmin-land than anywhere else, since we're the kind of people who tend to write a script and then forget about it for years until something breaks it, unlike application developers who spend a lot of time in close contact with their codebase and can get used to its idiosyncrasies. I've hired for sysadmin positions, and that clarity is something I look for in code samples.
Intelligible variable names following a consistent naming scheme; sufficient commenting; separating configuration from code (a lot of my perl-programming coworkers have the very bad habit of storing their script configuration in big comma-delimited inline string scalars, a typo in which turns what should have been a warning into a full-on messy die); etc. I heartily recommend Damian Conway's 'Perl Best Practices' as a reference in this area. Hope it helps; good luck with your interview!