Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, 23 March 2021

Which of the following files includes device names

Linux
Question 1- Which of the following files includes device names, mount points, filesystem types, permissions and information about whether to mount the device at boot time?

/dev/info
/etc/fstab
/boot/info
/etc/inittab
/etc/mnt
/etc/mount

Solution:  /etc/fstab
/etc/fstab contains information about device names, mount points, filesystem types, permissions and information about whether to mount the device at boot time.

Question 2- What is the process of confirming that an authenticated user has the correct permissions to access one or more network resources?

authorization
authentication
administration
allocation
availability
assignment

Solution: Authorization
Authorization is the process of confirming that an authenticated user has the correct permissions to access one or more network resources.

Sunday, 2 February 2020

MySQL Multiple Choice Question

1. Which of the following is not one of the top databases in use today?
(a) Amazon CloudIt
(b) Microsoft SQL Server
(c) Oracle
(d) MySQL
(e) MongoDB
Solution:
A (Amazon CloudIt)

Explanation : Microsoft SQL server, Oracle, and MySQL are relational databases. MongoDB is non relational databases. Amazon CloudIt is not a database.
2. MySQL is free to use as a back-end database for a website.
(a) True
(b) False

Solution:
 True

  Explanation : MySQL is free to use as a back-end database for a website.

3. MySQL uses which TCP/IP port by default?
Solution:
MySQL uses 3306 TCP/IP port by default.

4. MySQL is primarily a relational database based on SQL.
(a) True
(b) False
Solution:
True

Explanation : MySQL is primarily a relational database based on Structured Query Language (SQL).

5. Which of the following is correct about this command: mysql -u root -p?
(a) Installs MySQL for the first time
(b) Starts the MySQL Service in Linux
(c) Starts the MySQL Service in Windows
(d) Configures MySQL to like rootbeer
(e) Connects to MySQL on localhost
Solution:
E) Connects to MySQL on localhost

Explanation : 'mysql -u root -p' command is used to connect to MySQL on localhost. To connect to remote host we have to use -h option. 'mysql -h <remote-ip> -u <user> -p
6. The MySQL Configuration file for Windows is:
(a) my.cnf
(b) mysql.prop
(c) my.ini
(d) my.conf
(e) mysql.conf
Solution:
c (my.ini)
7. The MySQL Configuration file for Linux is:
(a) my.cnf
(b) mysql.prop
(c) my.ini
(d) my.conf
(e) mysql.conf
Solution:
a (my.cnf)

Explanation : we can define most of MySQL's configuration parameters in the my.cnf file which is located in /etc/mysql folder.

Saturday, 15 July 2017

Is gettimeofday() guaranteed to be of microsecond resolution?

Question: So I find myself porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux). I have implemented QueryPerformanceCounter by giving the uSeconds since the process start up:

BOOL QueryPerformanceCounter(LARGE_INTEGER* performanceCount)
{
    gettimeofday(&currentTimeVal, NULL);
    performanceCount->QuadPart = (currentTimeVal.tv_sec - startTimeVal.tv_sec);
    performanceCount->QuadPart *= (1000 * 1000);
    performanceCount->QuadPart += (currentTimeVal.tv_usec - startTimeVal.tv_usec);

    return true;
}

This, coupled with QueryPerformanceFrequency() giving a constant 1000000 as the frequency, works well on my machine, giving me a 64 bit variable that contains uSeconds since the program's start up. So is this portable? I don't want to discover it works differently if the kernel was compiled in a certain way or anything like that. I am fine with it being non-portable to something other than Linux, however.

Solution: Maybe. But you have bigger problems. gettimeofday() can result in incorrect timings if there are processes on your system that change the timer (ie, ntpd). On a "normal" linux, though, I believe the resolution of gettimeofday() is 10us. It can jump forward and backward and time, consequently, based on the processes running on your system. This effectively makes the answer to your question no.
You should look into clock_gettime(CLOCK_MONOTONIC) for timing intervals. It suffers from several less issues due to things like multi-core systems and external clock settings.
Also, look into the clock_getres() function.