Thursday, December 4, 2014

Linux Basic Interview Questions - Part1





1. You need to see the last fifteen lines of the files dog, cat and horse. What command should you use?
 
tail -15 dog cat horse

The tail utility displays the end of a file. The -15 tells tail to display the last fifteen lines of each specified file. 

 
 
2. Who owns the data dictionary?
 
The SYS user owns the data dictionary. The SYS and SYSTEM users are created when the database is created.

3. You routinely compress old log files. You now need to examine a log from two months ago. In order to view its contents without first having to decompress it, use the _________ utility.
 
zcat

The zcat utility allows you to examine the contents of a compressed file much the same way that cat displays a file.

4. You suspect that you have two commands with the same name as the command is not producing the expected results. What command can you use to determine the location of the command being run?
 
 which

The which command searches your path until it finds a command that matches the command you are looking for and displays its full path.

5. You locate a command in the /bin directory but do not know what it does. What command can you use to determine its purpose.
 
whatis

The whatis command displays a summary line from the man page for the specified command.

6. You wish to create a link to the /data directory in bob's home directory so you issue the command ln /data /home/bob/datalink but the command fails. What option should you use in this command line to be successful.
 
Use the -F option

In order to create a link to a directory you must use the -F option.

7. When you issue the command ls -l, the first character of the resulting display represents the file's ___________.
 
type

The first character of the permission block designates the type of file that is being displayed.

8. What utility can you use to show a dynamic listing of running processes? __________
top

The top utility shows a listing of all running processes that is dynamically updated.

9. Where is standard output usually directed?
 
to the screen or display

By default, your shell directs standard output to your screen or display.

10. You wish to restore the file memo.ben which was backed up in the tarfile MyBackup.tar. What command should you type?
 
tar xf MyBackup.tar memo.ben

This command uses the x switch to extract a file. Here the file memo.ben will be restored from the tarfile MyBackup.tar.

11. You need to view the contents of the tarfile called MyBackup.tar. What command would you use?
 
tar tf MyBackup.tar

The t switch tells tar to display the contents and the f modifier specifies which file to examine.

12. You want to create a compressed backup of the users' home directories. What utility should you use?
 
tar

You can use the z modifier with tar to compress your archive at the same time as creating it.

13. What daemon is responsible for tracking events on your system?
 
syslogd

The syslogd daemon is responsible for tracking system information and saving it to specified log files. 


14. You have a file called phonenos that is almost 4,000 lines long. What text filter can you use to split it into four pieces each 1,000 lines long?
 
split

The split text filter will divide files into equally sized pieces. The default length of each piece is 1,000 lines. 

15. You would like to temporarily change your command line editor to be vi. What command should you type to change it?
 
set -o vi

The set command is used to assign environment variables. In this case, you are instructing your shell to assign vi as your command line editor. However, once you log off and log back in you will return to the previously defined command line editor.
 

Thursday, October 16, 2014

Linux Interview Question and Answer - Mysql part 4


1. Explain the difference between BOOL, TINYINT and BIT.
    
 Prior to MySQL 5.0.3: those are all synonyms. After MySQL 5.0.3: BIT data type can store 8 bytes of data and should be used for binary data.
 
2. Explain the difference between FLOAT, DOUBLE and REAL. – 

    FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.
 
3. If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table? 

 999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
 
4. What happens if a table has one column defined as TIMESTAMP? 

 That field gets the current timestamp whenever the row gets altered.
 
5. But what if you really want to store the timestamp data, such as the publication date of the article? 

 Create two columns of type TIMESTAMP and use the second one for your real data.
 
6. Explain data type TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP  

    The column exhibits the same behavior as a single timestamp column in a table with no other timestamp columns.

7. What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do? 

  On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
         
        8. Explain TIMESTAMP DEFAULT ‘2006:09:02 17:38:44′ ON UPDATE CURRENT_TIMESTAMP. 

 A default value is used on initialization, a current timestamp is inserted on update of the row.

 9. If I created a column with data type VARCHAR(3), what would I expect to see in MySQL table? 

CHAR(3), since MySQL automatically adjusted the data type.

Monday, October 13, 2014

Linux Interview Question and Answer - Mysql part 3





1. Explain the difference between MyISAM Static and MyISAM Dynamic.

     In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record. 

2. What does myisamchk do? 

 It compressed the MyISAM tables, which reduces their disk usage.
 
3. Explain advantages of InnoDB over MyISAM? 

Row-level locking, transactions, foreign key constraints and crash recovery.   

4. Explain advantages of MyISAM over InnoDB? 

    Much more conservative approach to disk space management – each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity.

5. What are HEAP tables in MySQL?
    
    HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and <=>. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.

6. How do you control the max size of a HEAP table?
   
    MySQL config variable max_heap_table_size. 

7. What are CSV tables?

     Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed.
 
8. Explain federated tables ?
   
     Introduced in MySQL 5.0, federated tables allow access to the tables located on other databases on other servers.
 
9. What is SERIAL data type in MySQL? 

 BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT
 
10. What happens when the column is set to AUTO INCREMENT and you reach the maximum value for that table?

  It stops incrementing. It does not overflow to 0 to prevent data losses, but further inserts are going to produce an error, since the key has been used already.

 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism