Tuesday, 5 July 2016

Most frequently asked interview questions on linux

Here are some of the linux interview questions and answers that would help you to crack some of the most important and difficult interviews as a beginner.
1. What is the basic difference between Linux and Unix?
Linux is an open source operating system while Unix is a proprietary operating system. Linux is therefore, available for free to download but Unix is a paid OS (most of the versions
2. How can you find the active connections through terminal?
Using the netstat command, it is possible to find the active internet connections with the current machine. It is a command line network utility tool.
3. What is the minimum partition requirement in Linux and enlist them.
There should be minimum two partitions that every Linux distribution should have and these are as follows:
  1. Swap Partition
  2. Root Directory
4. What is the SU command used for in Linux?
The SU command in Linux is used to switch from one user account to another user account. You just need to type sudo su and enter the password to switch to another user account in your Linux system.
5. Tell the command to shut down the system.
The command to shutdown the OS is shutdown -h time. In place of time, you can add a number representing the seconds after which you need to shutdown the system.
 6. What is fork()?
fork() is a system call primarily. It is sued to create a new process from an already active process in the system memory. Therefore, the primary process is called the parent process and the newly created process is called the child process.
7. How many run levels modes are available in Linux operating system?
There are a total of seven run level modes available in linux operating system.
8. What do you mean by Open Source System Softwares?
Open Source Softwares are the ones that are freely available for use. They generally come under the GPL License which enables us to view the source code, manipulate it and use it. However, we cannot resell them.
9. How can you list all the running programs in your Linux system?
The TOP Command can be used to enlist all the running processes in your Linux system. You can types TOP in Linux terminal and you’ll get the details of the current processes in your system.
10. What is the difference between BASH and DOS?
BASH is a Unix shell and a command language. DOS is an abbreviated form for Disk Operating System. It is used in Microsoft systems for Command Line Interface. DOS commands are not case sensitive whereas BASH commands are case sensitive.
11. How can you view the current Swap and RAM memory in your Linux system?
There is a command that can be used in the terminal in Linux operating system. The command is FREE. It enables you to view the currently active RAM and Swap memory in the system.
12. Is it legally acceptable to edit the source code of Linux Ubuntu?
Definitely Yes. Linux Ubuntu currently has a large community who regularly edits the source code for modifications and send it to the Linux team. These changes are reviewed by the core team and implemented in the next version. So, it is possible to edit the source code as it comes under GNU GPL License.
13. Which command is used to enlist the files in a particular directory?
To view the existing files in the current directory, you can use the LS command. It is an abbreviated form for LIST.
14. What is Kernel in Linux?
A Kernel in Linux is an essential part of an OS. It is the core of Linux OS. The Kernel provides basic services and interacts with the User Commands. It is fetching your commands and then retrieving the results from the OS and again sending back to the User.
15. Enlist the types of Kernels.
There are various types of Kernels listed as follows:
  1. Monolithic Kernel
  2. Micro Kernel
  3. Hybrid Kernel
16. Which Program is used to securely login in Linux Operating System?
Secure Shell is used to remotely login in Linux OS. It is also known as SSH. SSH is an encrypted or cyrtographic network protocol. SSH is a good replacement of Telnet, which was previously used in Linux OS for Login purpose.
17. Name the Partition that stores the system configuration files in Linux system.
The partition that stores the system configuration files in Linux OS is /etc.
18. Who is the creator of Linux Operating System?
Linus Torvalds has created the Linux Operating System.
19. Enlist the distributions of Linux.
The different types of Linux distributions are listed as follows:
  1. Linux Mint
  2. Ubuntu
  3. Mandriva
  4. Arch
  5. Slackware
  6. Debian
  7. Fedora
20. Where is the user password stored in Linux Operating System?
The User passwords are stored in the directory /etc/passwd
21. In Linux OS, which Daemon controls the Printer Spooling process.
The Line Printing Daemon, also known as LPD controls the Printer Spooling Process.
22. Enlist the filesystems supported in Linux OS.
The filesystems supported by Linux are as follows:
  1. XFS
  2. EXT3
  3. NFS
  4. RAMFS
  5. EXT4
  6. AUTOFS
  7. NTFS
23. What is GNU GPL License?
The GNU General Public License is a Free Software License. This License enables the Users to share, copy, manipulate the code of the software. Therefore, the software code is available for free.
24. Which command is used to delete the files in Linux through command line?
The command used to delete the files in linux is rm.
25. Name the command used to remove the directory.
The command used to remove the directory is rmdir.
26. What should be the size of Swap memory in Linux?
Usually, the size of the Swap memory in Linux Systems should be equal or more two times that of RAM.
27. Explain SE-Linux.
SE – Linux is an abbreviated form for Security Enhanced – Linux. It has been developed to prevent Illegal Daemons and Server Misconfigurations. It provides access control implementation. It implements access authorities to daemons, programs for the files that they can access. The Security Enhanced – Linux provides Security Policy formation.
28. Who is the inventor of Unix Operating System?
The Unix Operating System is created by Dennis Ritchie and Ken Thompson at Bell Labs in 1969.
29. What is the default text editor for Linux?
The default editor for text files in Linux operating system is VI Editor. It can be used to edit any ASCII Text.
30. Name the argument to extract the files from archives using Linux Terminal.
To extract the files from archives, there can be a combination of multiple commands. If you’re trying to extract using TAR Command, then you have to use -x argument with it.
31. What is a Package Manager?
A Package Manager in Linux is a collection of softwares which provides Upgradation, Modification, Removal, Installation and Deletion of programs from the Linux Operating System. It is also known as Package Management System. It is especially developed to automatically install and update the system softwares.
32. What is the name of the Boot Loader in Linux Ubuntu Operating System?
The Boot Loader in Linux Ubuntu OS is called as GRUB Boot Loader.
33. How do you move from one directory to another directory in Linux Operating System?
By using the CD command in Linux Terminal, the user can move from one directory to another one. CD is an abbreviated form of Change Directory.
34. What is Sudo Command?
Sudo command is used to provide highest level access authority to the users. If you use a command in the Linux terminal, you may get an Access Denied output. If you want to make the terminal process a command, you can use the prefix SUDO to get administrator rights for the same.
35. What is Shell?
The Shell is basically an interface between the User Commands and the Operating System. Whatever the user types in is interpreted by the Shell and is then sent to the Operating System Kernel for fetching the results. It converts them to the System Calls.
36. Enlist boot files in Linux Operating System.
The files that are loaded a boot time in Linux OS are as follows:
/etc/fstab
/etc/init.d/rc.d/rcN.d
/boot/grub/grub.conf
/etc/initab
37. How can you find the Run – Level of Linux Operating System?
By using the runlevel command from the Linux Terminal, you can find the Run Level of your Linux  system.
38. Enlist the command to install any software in Linux Ubuntu OS.
The command to install any software in Linux OS is as follows:
sudo apt install application-name
39. How can you terminate a currently executing process in Ubuntu terminal?
The key combination Ctrl + Z allows you to terminate a currently executing process in the Linux Ubuntu Terminal.
40. Which command can be used to monitor Linux ports?
The Nmap localhost command is used to monitor ports in Linux Operating Systems.
41. Enlist the Run Level Modes in Linux.
The Run Level Modes in Linux are as follows:
  1. Halt
  2. Reboot
  3. Single User Mode
  4. Undefined
  5. Multi – User Mode
  6. X11
  7. Multi User Mode with Networking
42. What is the core of Linux OS?
The Linux Kernel is the core of Linux Operating System.

Friday, 1 July 2016

RIOT: An Operating System for the IoT

There are only a few operating systems that are suitable for Internet of Things (IoT) applications. RIOT OS, which is free and open source, is specially designed to meet the particular needs of the IoT, with features like a low memory footprint, high energy efficiency, real-time capabilities, a modular and configurable communication stack, and support for a wide range of low-power devices.
The Internet of Things (IoT) is used with heteregenous devices, which range from 8-bit to 32-bit microcontrollers from different manufacturers. Traditional operating systems or the conventional embedded OSs may not suit the requirements that these tiny devices demand (low power, a small size and low memory footprint). The RIOT operating system is a free and open source architecture that is friendly to IoT applications, and has proved to be a perfect OS for IoT systems.
Developed in 2008 as an OS for wireless sensor nodes, it was later fine tuned for IoT systems.
Features of RIOT
The OS is actively developed and maintained.
  • There are no new programming environments. C or C++ can be used directly with existing tools like gcc, gdb, etc
  • Less hardware dependent code
  • Supports 8-,16- and 32-bit microcontroller platforms
  • Energy efficieny is maintained
  • Less interrupt latency, so real-time capability is ensured
  • Multi-threading is enabled
  • Supports the entire network stack of IoT (802.15.4 Zigbee, 6LoWPAN, ICMP6, Ipv6, RPL, CoAP, etc)
  • Both static and dynamic memory allocation
  • POSIX compliant (partial)
  • All output can be seen in the terminal if hardware is not available; however, there is a visualisation tool called RIOT-TV that is provided

Figure 1: Components of the IOT
Figure 1: Components of the IOT


Figure 2: Network stack for IOT
Figure 2: Network stack for IOT
Architecture, board and driver support
It supports various architectures like
  • MSP430
  • ARM7
  • Cortex-M0, M3 and M4
  • x86, etc
It also supports the native port, where one can simulate the output within the OS it is running. So RIOT is supported in Linux as well as OS X.
There are in-built drivers for the following sensors (without the need for hardware, these sensors can be modelled in native mode also):
  • Radio receivers
  • Environmental sensors for humidity, temperature, pressure, alcohol, gas, etc
  • Accelerometers
  • Gyroscopes
  • Ultrasonic sensors, light and servo motors
Most of the sensor boards like TelosB, ST, Zolertia, MSP 430, Arduino and Atmel have support from this OS (and the list is quite long). RIOT also supports virtualisation, where the code and application can run as a simple UNIX process. It also uses Wireshark for packet sniffing.
Comparisons with Contiki OS and Tiny OS
There are two other OSs, called Contiki OS (already featured in OSFY) and Tiny OS, which are suitable for IoT applications. But RIOT fares better when it comes to memory usage and support.

Table 1
Table 1: A comparison of various OSs for their IOT suitability
Figures 1 and 2 represent the block and network stack diagram of the IoT. Except for RPL, all modules have support from the RIOT OS (for RPL alone, there is partial support from RIOT).
Installation of RIOT in Linux
The OS used for installation is Linux Mint 17.2 and Ubuntu 14.04.2, while the architecture used is 64-bit OSs. The pre-requisite packages for installing RIOT are:
  • msp 430 GCC compiler
  • msp 430 libraries
  • avr utils
  • arm based gcc
  • gcc multi-library, etc
Assuming that you have installed all just now, follow the steps shown below to install RIOT:
pradeepkumar $] sudo apt-get update
pradeepkumar $] sudo apt-get install libc6-dev-i386 build-essential binutils-msp430 gcc-msp430 msp430-libc libncurses5-dev openjdk-7-jre openjdk-7-jdk avrdude avr-libc gcc-avr gdb-avr binutils-avr mspdebug msp430mcu autoconf automake libxmu-dev gcc-arm-none-eabi openocd git bridge-utils gcc-multilib socket
The OS can be downloaded as a zip file from Github (https://github.com/RIOT-OS/RIOT/archive/master.zip); else, you can clone it using the following command:
pradeepkumar $] git clone https://github.com/RIOT-OS/RIOT.git
The folder RIOT/ or RIOT-Master/ contains various sub-folders:
->boards: This folder has all the drivers for the boards that are supported by the OS
->cpu: This folder contains the architecture supported by RIOT
->cores: This has the core of the OS, like kernel, modules, etc
->doc: This folder contains documentation
->examples: Some examples like ‘hello world’, border router, Ipv6 formation, etc
->drivers: This one has drivers’ for all the sensors, etc

A simple example
These types of OSs can be learnt and understood only through the examples given within the source code of the application. RIOT has some examples in the examples/ folder, and one can go through the source code and run it using the following method. There are more examples available in the Github of RIOT (https://github.com/RIOT-OS).
If sufficient board or hardware is not available, then the code can be run in the terminal itself (native mode).
To run the ‘hello-world’ example from the examples folder, use the following code:
pradeepkumar $] cd RIOT-Master/examples/hello-world
pradeepkumar $] make flash
pradeepkumar $] make term
-----OUTPUT-----
/home/pradeepkumar/RIOT-master/examples/hello-world/bin/native/hello-world.elf
RIOT native interrupts/signals initialized.
LED_GREEN_OFF
LED_RED_ON
RIOT native board initialized.
RIOT native hardware initialization complete.
main(): This is RIOT! (Version: UNKNOWN (builddir: /home/pradeepkumar/RIOT-master))
Hello World!
You are running RIOT on a(n) native board.
This board features a(n) native MCU.
Press Ctl+C to quit the application
make flash will compile and show the text and the size of the data occupied by the memory. Since this application is run under native mode, the output can be viewed using the make term command (refer Figures 3 and 4).

Figure 4
Figure 4: The ‘hello world’ applicatio being run in the terminal


Figure 5
Figure 5: POSIX socket application in RIOTCommand
Networking applications in RIOT
There are a few applications available in RIOT. One such app is a socket application, which works with the POSIX API with UDP as the protocol. All the relevant source code is available in the directory itself.
pradeepkumar $ ] cd RIOT-Master/examples/posix-socket/
pradeepkumar $ ] make flash
pradeepkumar $ ] sudo make term
output of the above command
/home/pradeepkumar/RIOT-master/examples/posix_sockets/bin/native/posix_sockets.elf tap0
RIOT native interrupts/signals initialized.
LED_GREEN_OFF
LED_RED_ON
RIOT native board initialized.
RIOT native hardware initialization complete.
main(): This is RIOT! (Version: UNKNOWN (builddir: /home/pradeepkumar/RIOT-master))
RIOT socket example application
All up, running the shell now
> help
udp            send data over UDP and listen on UDP ports
reboot         Reboot the node
ps             Prints information about running threads
random_init    initializes the PRNG
random_get     returns 32 bit of pseudo randomness;
ifconfig       Configure network interfaces
txtsnd         send raw data
ncache         manage neighbor cache by hand
routers        IPv6 default router list
Figure 5 shows the above configuration; routers can be configured, text messages can be sent and details about running processes can be searched using this application.
There are only a limited number of OSs available for IoT sensors and, among these, RIOT really has a well-documented API with huge support for most of the boards, architecture and sensors. Its main advantages are that it is actively developed and maintained, and there is an incremental version every month. Students and electronics hobbyists/enthusiasts are using Arduino and Raspberry Pi for their IoT applications these days, and RIOT really helps these boards and sensors to achieve a low memory footprint and high energy efficiency without any compromises on the performance of the IoT systems.

References
[1] http://www.riot-os.org/
[2] http://www.riot-os.org/docs/riot-infocom2013-abstract.pdf
[3] http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5355049
[4] https://hal.inria.fr/hal-00768685/