Friday, March 5, 2010

Top Linux Admin Interview Questions asked in TOP IT industries : Question Bank 2

Top Linux Admin Interview Questions and Answers

Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 02


# What command is used to remove the password assigned to a group?

# You changed the GID of the sales group by editing the /etc/group file. All of the members can change to the group without any problem except for Joe. He cannot even login to the system. What is the problem? Choose one:
a. Joe forgot the password for the group.
b. You need to add Joe to the group again.
c. Joe had the original GID specified as his default group in the /etc/passwd file.
d. You need to delete Joe’s account and recreate it.

# You need to delete the group dataproject. Which two of the following tasks should you do first before deleting the group?
A. Check the /etc/passwd file to make sure no one has this group as his default group.
B. Change the members of the dataproject group to another group besides users.
C. Make sure that the members listed in the /etc/group file are given new login names.
D. Verify that no file or directory has this group listed as its owner.
Choose one: a. A and C b. A and D c. B and C d. B and D

# When you look at the /etc/group file you see the group kmem listed. Since it does not own any files and no one is using it as a default group, can you delete this group?

# When looking at the /etc/passwd file, you notice that all the password fields contain ‘x’. What does this mean? Choose one:
a. That the password is encrypted.
b. That you are using shadow passwords.
c. That all passwords are blank.
d. That all passwords have expired.

# In order to improve your system’s security you decide to implement shadow passwords. What command should you use?

# What file contains the default environment variables when using the bash shell? Choose one:
a. ~/.profile
b. /bash
c. /etc/profile
d. ~/bash

# You have created a subdirectory of your home directory containing your scripts. Since you use the bash shell, what file would you edit to put this directory on your path? Choose one:
a. ~/.profile
b. /etc/profile
c. /etc/bash
d. ~/.bash

# Which of the following interprets your actions when typing at the command line for the operating system? Choose One
a. Utility
b. Application
c. Shell
d. Command

# What can you type at a command line to determine which shell you are using?

# You want to enter a series of commands from the command-line. What would be the quickest way to do this? Choose One
a. Press enter after entering each command and its arguments
b. Put them in a script and execute the script
c. Separate each command with a semi-colon (;) and press enter after the last command
d. Separate each command with a / and press enter after the last command

# You are entering a long, complex command line and you reach the right side of your screen before you have finished typing. You want to finish typing the necessary commands but have the display wrap around to the left. Which of the following key combinations would achieve this? Choose One
a. Esc, /, Enter
b. /, Enter
c. ctrl-d, enter
d. esc, /, ctrl-d

# After typing in a new command and pressing enter, you receive an error message indicating incorrect syntax. This error message originated from.. Choose one
a. The shell
b. The operating system
c. The command
d. The kernel

Top Linux Admin Interview Questions asked in TOP IT industries

Hey Guys, AFRAID of interviews

DONT Worry prepare the following questions before Interview. I have managed to prepare some questions sets. Practice this and i'm sure you would crack a L1/L2/L3 Linux Administrator Job Easily. All the questions are taken from the top IT brands interviews.

Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 01

# You attempt to use shadow passwords but are unsuccessful. What characteristic of the /etc/passwd file may cause this? Choose one:
a. The login command is missing.
b. The username is too long.
c. The password field is blank.
d. The password field is prefaced by an asterick.

# You create a new user account by adding the following line to your /etc/passwd file. bobm:baddog:501:501:Bob Morris:/home/bobm:/bin/bash Bob calls you and tells you that he cannot logon. You verify that he is using the correct username and password. What is the problem? Choose one:
a. The UID and GID cannot be identical.
b. You cannot have spaces in the line unless they are surrounded with double quotes.
c. You cannot directly enter the password; rather you have to use the passwd command to assign a password to the user.
d. The username is too short, it must be at least six characters long.

# Which of the following tasks is not necessary when creating a new user by editing the /etc/passwd file? Choose one:
a. Create a link from the user’s home directory to the shell the user will use.

b. Create the user’s home directory
c. Use the passwd command to assign a password to the account.
d. Add the user to the specified group.

# You create a new user by adding the following line to the /etc/passwd file bobm::501:501:Bob Morris:/home/bobm:/bin/bash You then create the user’s home directory and use the passwd command to set his password. However, the user calls you and says that he cannot log on. What is the problem? Choose one:
a. The user did not change his password.
b. bobm does not have permission to /home/bobm.
c. The user did not type his username in all caps.
d. You cannot leave the password field blank when creating a new user.

# When using useradd to create a new user account, which of the following tasks is not done automatically. Choose one:
a. Assign a UID.
b. Assign a default shell.
c. Create the user’s home directory.
d. Define the user’s home directory.

# You issue the following command useradd -m bobm But the user cannot logon. What is the problem? Choose one:
a. You need to assign a password to bobm’s account using the passwd command.
b. You need to create bobm’s home directory and set the appropriate permissions.
c. You need to edit the /etc/passwd file and assign a shell for bobm’s account.
d. The username must be at least five characters long.

# You have created special configuration files that you want copied to each user’s home directories when creating new user accounts. You copy the files to /etc/skel. Which of the following commands will make this happen? Choose one:
a. useradd -m username
b. useradd -mk username
c. useradd -k username
d. useradd -Dk username

# Mary has recently gotten married and wants to change her username from mstone to mknight. Which of the following commands should you run to accomplish this? Choose one:
a. usermod -l mknight mstone
b. usermod -l mstone mknight
c. usermod -u mknight mstone
d. usermod -u mstone mknight

# After bob leaves the company you issue the command userdel bob. Although his entry in the /etc/passwd file has been deleted, his home directory is still there. What command could you have used to make sure that his home directory was also deleted? Choose one:
a. userdel -m bob
b. userdel -u bob
c. userdel -l bob
d. userdel -r bob

# All groups are defined in the /etc/group file. Each entry contains four fields in the following order. Choose one:
a. groupname, password, GID, member list
b. GID, groupname, password, member list
c. groupname, GID, password, member list
d. GID, member list, groupname, password

# You need to create a new group called sales with Bob, Mary and Joe as members. Which of the following would accomplish this? Choose one:
a. Add the following line to the /etc/group file: sales:44:bob,mary,joe
b. Issue the command groupadd sales.
c. Issue the command groupadd -a sales bob,mary,joe
d. Add the following line to the /etc/group file: sales::44:bob,mary,joe
Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Checking if MYSQL is 32Bits or 64Bits?

Do you know MYSQL installed on your system is MYSQL 32Bit or MYSQL 64Bit.


You can achieve this in Different Ways. The best command i found was "file"

Find the MYSQLD location

# which mysqld
/bin/mysqld


# file /bin/mysqld
/bin/mysqld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped


FOR 64 Bit this would show

# file /bin/mysqld
/usr/sbin/mysqld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped


The other way to find is using mysql to find it
MYSQL on 32 Bit System

mysql> SHOW GLOBAL VARIABLES LIKE 'version_compile_machine';
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| version_compile_machine | i686 |
+-------------------------+-------+
1 row in set (0.00 sec)


MYSQL on 64 Bit System
mysql> show variables like 'version_compile_machine';
+-------------------------+--------+
| Variable_name | Value |
+-------------------------+--------+
| version_compile_machine | x86_64 |
+-------------------------+--------+


We can also check if the mysqld binary are linked to which library
MYSQL on 32bit System
[root@localhost ~]# ldd /bin/mysqld
linux-gate.so.1 => (0x00df0000)
libpthread.so.0 => /lib/libpthread.so.0 (0x007cf000)
libdl.so.2 => /lib/libdl.so.2 (0x007c9000)
librt.so.1 => /lib/librt.so.1 (0x007fd000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x0490d000)
libnsl.so.1 => /lib/libnsl.so.1 (0x0032e000)
libm.so.6 => /lib/libm.so.6 (0x007a0000)
libc.so.6 => /lib/libc.so.6 (0x0065a000)
/lib/ld-linux.so.2 (0x00637000)


MYSQL on 64 Bit System
# ldd /usr/local/mysql/libexec/mysqld
linux-vdso.so.1 => (0x00007fff6d5ff000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007ff3650d3000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007ff364ebc000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007ff364bb0000)
libdl.so.2 => /lib/libdl.so.2 (0x00007ff3649ac000)
librt.so.1 => /lib/librt.so.1 (0x00007ff3647a3000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007ff36456b000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00007ff364353000)
libm.so.6 => /lib/libm.so.6 (0x00007ff3640d0000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007ff363eb9000)
libc.so.6 => /lib/libc.so.6 (0x00007ff363b66000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff3652ef000)


Another Method is using "ELFREAD"
MYSQL on 32 Bit System

[root@localhost ~]# readelf -h /bin/mysqld
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x81805a0
Start of program headers: 52 (bytes into file)
Start of section headers: 39507760 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 9
Size of section headers: 40 (bytes)
Number of section headers: 44
Section header string table index: 41


MYSQL on 64 Bit System

[root@localhost ~]# readelf -h /bin/mysqld
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x4e5a30
Start of program headers: 64 (bytes into file)
Start of section headers: 7548008 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 32
Section header string table index: 31

Monday, February 22, 2010

How to start Python Simple Httpd Server for Simple File Sharing

Do you want to share a file and dont have any prior knowledge of setting up WebServer or FTP Server or even dont know about other file sharing protocols knowledge. This Issues can be resolved using Python Language.

How to Do that?

1. As Root go to the location which you want to Share to the External Users.

[root@localhost ~]# cd /tmp

2. Run the Python Command with a Defined port or default will be used (Port 8000).

[root@localhost tmp]# python -m SimpleHTTPServer 19000 &

Note :
a) To Run the Command in background use "&" at the end.
b) In the above case the Port number is set to be 19000.

3. From the Remote System In the browser Type in the IPaddress:Portno you have used. Now you can see the contents of the /tmp directory
http://ip.addr.ess:19000

4. Yeppie Thats it !!!! you are now sharing your files without setting up WebServer or any FTP Server or any knowledge of system administration.

How to sent Message through Terminal to a Login users In Fedora, Centos, RedHat, Ubuntu.

You can broadcast a message using WALL -- How to broadcast a Message through Terminal to Login users How To but what if you want to sent message to only a particular user logged into the system or different Messages to Different users. Yes its possible using write command.

Before using write command Check if it is avaliable in you system. From the terminal Run

[root@localhost ~]# which write

which should give
[root@localhost ~]# which write
/usr/bin/write


If write is not installed Install bsdmainutil package

Once Installed to sent message to a particular user we need to know which users are currently logged into the System

[root@localhost ~]# w

USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ashwin :0 - 15Feb10 ?xdm? 7:56m 0.21s /usr/bin/gnome-session
ashwin pts/1 :0.0 11:34 22.00s 1.08s 0.01s gnome-terminal
demo1 pts/2 :0.0 11:58 11.00s 1.07s 1.2s gnome-terminal
demo2 pts/3 :0.0 01:58 8.00s 0.16s 1.8s gnome-terminal
ashwin pts/4 :0.0 12:58 1:47 4.02s 0.02s bash


Now you have the list of users logged in.

METHOD 1
[root@localhost ~]# write ashwin pts/4
Your Message 1
Your Message 2
Your Message 3
Once Done

“Terminate the write by ctrl+D.”


The User "ashwin" would see the message into the console as

[ashwin@localhost ~]$
Message from ashwin@localhost (as root) on pts/2 at 12:49 ...
Your Message 1
Your Message 2
Your Message 3
EOF


METHOD 2
[ashwin@localhost ~]$ echo "Test Message Using Write from http://linuxmaza.com" > /dev/pts/3

The above command will display a message to User "demo2" on the console.

Write Command Runs on all linux distros and installed by default in Fedora, Centos. Please refer the documentation if it is not installed under you linux distribution.

How to broadcast a Message through Terminal to Login users In Fedora, Centos, RedHat, Ubuntu

Do you want to sent message to all logged in users in your system (This works great when you are a System Administrator and many users are logged into same System)?

If you are Running Any Linux Distribution like Fedora, Centos, RedHat, Ubuntu you can send or broadcast message to all user logged in using "WALL" command. To use it on the command line / Terminal.

METHOD 1
========

[root@localhost ~]# wall "Your message Goes here"


Now all users can see the Message Broadcasted by You

[ashwin@localhost tmp]$
Broadcast message from root (pts/2) (Mon Feb 22 12:10:35 2010):

Your message Goes here


METHOD 2
========
[shankar@localhost ~]$ wall [Press Enter]
Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished


Press Ctrl + D for EOF (End of File)

[root@localhost ~]#
Broadcast message from shankar (pts/3) (Mon Feb 22 12:14:55 2010):

Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished


All Users can view the Message on their Terminal as below

[root@localhost ~]#
Broadcast message from shankar (pts/3) (Mon Feb 22 12:14:55 2010):

Write You Message Here.
Testing Wall OutPut On All Terminals.
Finished


Limitations of Wall :
1. The total length of the message is limited to 22 lines.
2. Broadcasted Messages are limited to The System Itself.

Advantages of Wall
1. During an Activity / Crisis on the system all users can be notified immediately
2. No need to Send Email to the users who are Logged into the System.

Wednesday, February 17, 2010

Mounting SSH Server Using FUSE

FUSE which stands for Filesystem in Userspace has brought a host of features to mount a remote filesystem using various protocols like SSH, FTP. FUSE allows non privileged users to develop their own filesystem without even modifying the Kernel, basically fuse is module which play a role of bridge between user space and the kernel.

To Mount a remote partition locally. Run the Command (You Dont Need To be Root User to Run this Command).

root# sshfs user@hostname:path_of_directory_to_be_mounted mount_to_point

root# sshfs ashwin@192.168.1.10:/home/ashwin /mnt/

If You are using a specific port for connecting to your SSH Server use -p Option

root# sshfs -p 10234 ashwin@192.168.1.10:/home/ashwin /mnt/

where 10234 is the port running SSH Service
Important Note : To Mount other Partition like /var, /opt, /root you have to mount being a root user ofthe remote machine.

root# cd /mnt

root# ls

msrv2826d0.1.tmp
keyring-0sIxHo keyring-K0zJSJ msrv2832d0.1.tmp
keyring-16cIRa keyring-kJqkFX mysqlbin.000085
keyring-1h8sea keyring-kzkqpE mysqlbin.000086
keyring-1M5nUH keyring-lyNVMO mysqlbin.000087
keyring-2i7woO keyring-m0dxjd mysqlbin.000088
keyring-4hSFtb keyring-m1xNam mysqlbin.000089
keyring-68PwBN keyring-mTgrKf mysqlbin.000092
keyring-7JY4q3 keyring-NDLFUc mysqlbin.000093
keyring-7zjMDV keyring-nt2Ygk mysqlbin.index


Enjoy, you have mounted a remote directory locally that to on secured transmission.