Chris on 14 Feb 2004 16:40:03 -0000 |
8. How do you create a file that even root can't remove? Not true. Trick question. How is the users setup? 5. How do you setup multiple IP address on one NIC (Network Interface Card)...assume ethernet. Not all linux or unix dist use /etc/sysconfig I think you need to put more detail into these questions. And it's a good idea to throw in $? Instead of just || echo "Error on server $i Are these questions supposed to be focused on a low end admin? Or a high position admin? -chris www.jynx.net -----Original Message----- From: plug-admin@lists.phillylinux.org [mailto:plug-admin@lists.phillylinux.org] On Behalf Of Mike Chirico Sent: Saturday, February 14, 2004 11:09 AM To: plug@lists.phillylinux.org Subject: [PLUG] Interview Questions: System Admin Here's a list of common interview questions that I've come across. 1. You have 20 servers that need to be updated named server01,server02...server20. Write a bash script to update all the computers, assuming they all use ssh, with the account bozo. Ans: #!/bin/bash user="bozo"; updatecmd="ls -l"; # put in rpm command here errorfile="updatelog"; for i in `seq -w 20` do ssh "${user}@server$i" $updatecmd || echo "Error on server $i >> $errorfile"; done The command seq -w 20 pads with the necessary zeros (01,02,03...09). The || executes only the left side on success. However, if the ssh fails, the right side is executed and an error message to piped to the file. 2. How do you findout whether a command is an aliases, bash function, built-in like cd and type, or executable program? Ans: type -all yourcmd 3. What is a zombie process and how do you find them? Ans: When a process creates a child process "fork() command" and that child process terminates, information about the child process (CPU time, memory, etc.) exists for the parent to fetch. The parent can use the "wait" or "waitpid" to fetch this signal. The child process becomes a zombie as soon as it finishes; but, the SIGCHLD hasn't been caught. ps -aux, will show all processes. Look for "Z" in that stat and defunct under the command. Note: wait may still produce zombies. This can happen of child A terminates, and it's signal has been caught. While this signal is being process child B terminates. Since these signals won't queue, child B could stay in the zombie state. It's safer to use the waitpid call. 4. How do you find the version of Linux running and the version of gcc used? Ans: cat /proc/version 5. How do you setup multiple IP address on one NIC (Network Interface Card)...assume ethernet. Ans: Normally, /etc/sysconfig/network-scripts/ifcfg-eth0 is the setup for the first card. To add additional IP addresses, create another file "ifcfg-eth0:1" with the new IP address information in it. 6. What is an inode? Ans: The inode contains information about the file size, file location, ownership, etc. Plus, it contains a pointer to the first few blocks of data in the file. 7. What's the difference between a hard link and a soft link? Ans: hard link is created by the following command $ln fileA fileB fileA and fileB have the same inode. How do you know this? Issue the stat command "stat fileA" and "stat fileB". soft link is created by the following command ln -s fileA fileC Here fileC has a different inode than fileA. However, this "different inode" points to the same data as fileA. One important note about hard links. Editors like emacs will create a new inode for a file. So if you edit the fileB above, you won't see the changes in fileA. Instead, that inode becames the backup. 8. How do you create a file that even root can't remove? Ans: You't can't really; but, the "chattr +i file" command can make a file immutable. This file can't be removed until "chatt -i file" is performed. True, even root can't remove a file with the immutable attribute set. But, root can unset this attribute, then, delete the file. 9. How do you find all the programs, and there location, using sockets or pipes on your computer? Ans: "netstat -na" will give a list of listening connections; but, it doesn't do an adequate job of listing the programs. Instead, use "lsof" 10. How do you create directory and subdirectories when the parent directory may exist, in one command? In other words, create the following directory structure. /home/user/one/two The command should work whether /home/user exists or not. Ans: mkdir -p /home/user/one/two The -p or "parents" makes the parent directory as needed. Personal note: You want interviewers to ask good questions. If you get the job it's a sign you'll be working with knowledgeable people. And, if you don't get the job, you'll at least learn from the interview process. Other items to know: What is a superblock and what kind of data is in it? If someone talks about ext2 and ext3 filesystems, what are they most likely running Debian or Redhat? Using the find command, how do you find all files with the immunitable attribute set? How do you create a directory that's sharable to a group, that by default, will have each file created as sharable to a group. What's an effective UID and how is it set? How do you pass and use a command variable to an awk script? How can you easily print quotes in an awk script? Using a sed script print only the data betwee "<start>.....</start>" in a file. How do you keep cron jobs from sending mail on output? How do you create a C like for loop in Bash? How do you find the length of an array in bash? Using the find command how do you find directory names that "do not contain" a particular file? Is the speed of light constant in a vacuum and does light travel in a straight line? Careful on this last one..don't let your formal education throw you off. Regards, Mike Chirico ________________________________________________________________________ ___ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|