Process managment and DISK managment

Q: Define Process?

Ans: In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently


Q.Explain THREADS vs Processes ?.

Ans:
THREADS, LIKE PROCESSES, ARE A MECHANISM TO ALLOW A PROGRAM to do more than one thing at a time.As with processes, threads appear to run concurrently; the Linux kernel schedules them asynchronously, interrupting each thread from time to time to give others a chance to execute.

Conceptually, a thread exists within a process.Threads are a finer-grained unit of execution than processes.When you invoke a program, Linux creates a new process and in that process creates a single thread, which runs the program sequentially.That thread can create additional threads; all these threads run the same program in the same process, but each thread may be executing a different part of the program at any given time.

Threads

● Will by default share memory
● Will share file descriptors
● Will share filesystem context
● Will share signal handling
 
Processes

● Will by default not share memory
● Most file descriptors not shared
● Don't share filesystem context
● Don't share signal handling.
 

Q.What is PID?

Ans: Process (process ID, PID): All software runs within an operating system concept known as a process. Each program running on a system is assigned its own process ID (PID). Users can easily obtain a process list (using Task Manager on Windows or ps on UNIX) in order to see what is running. Key point: Trojans, root kits, and other evil software will attempt to hide themselves from the process list, either by providing replacements to the programs that list processes (like ps), or by hooking the system calls that enumerate processes.

Q. What are the different states of process?

Ans: In a multitasking computer system, processes may occupy a variety of states. These distinct states may not actually be recognized as such by the operating system kernel, however they are a useful abstraction for the understanding of processes

Process states in Linux:

Running: Process is either running or ready to run

Incorruptible: a Blocked state of a process and waiting for an event or signal from another process

Uninterruptible: a blocked state. Process waits for a hardware condition and cannot handle any signal

Stopped: Process is stopped or halted and can be restarted by some other process

Zombie: process terminated, but information is still there in the process table.  


Q. What is a zombie?

Ans:  Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table. Since this process is not alive, it cannot react to signals. Zombie state can finish when the parent dies. All resources of the zombie state process are cleared by the kernel 

Q, Explain Daemons?

Ans:  Daemons is a computer program that runs as a background process, rather than being under the direct control of an interactive user. Typically daemon names end with the letter d: for example, syslogd is the daemon that implements the system logging facility, or sshd, which services incoming SSH connections.

Q. Explain each system calls used for process management in Linux.

Ans:  System calls used for Process management:

    Fork ()  -Used to create a new process
    Exec()   -Execute a new program
    Wait()   - wait until the process finishes execution
    Exit()    - Exit from the process
    Getpid() - get the unique process id of the process
    Getppid()  - get the parent process unique id
    Nice() -to bias the existing property of process 

Q. Some Tools to see process and memory status?

Ans: top – Process Activity Command

The top program provides a dynamic real-time view of a running system i.e. actual process activity. By default, it displays the most CPU-intensive tasks running on the server and updates the list every five seconds.

vmstat – System Activity, Hardware and System Information
The command vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.

 
Q. How to put a job in background & bring it to foreground?

Ans:  we can put a job in background by putin & symbol at the end
of the line on the command prompt.
Example: #cp -r /var/* /tmp &

Q.Explain Memory management and related commands?

Ans: Linux comes with different set of commands to check memory usage. The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The vmstat command reports information about processes, memory, paging, block IO, traps, and cpu activity. Finally, you can use the top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.

Q. What is the major advantage of a hash table?

Ans: The major advantage of a hash table is its speed. Because the hash function is to take a range of key values and transform them into index values in such a way that the key values are distributed randomly across all the indices of a hash table.

Q. What are the techniques that you use to handle the collisions in hash tables?

Ans: We can use two major techniques to handle the collisions. They are open addressing and separate chaining. In open addressing, data items that hash to a full array cell are placed in another cell in the array. In separate chaining, each array element consist of a linked list. All data items hashing to a given array index are inserted in that list.


Q. Explain file system of linux. The root "/" filesystem, /usr filesystem, /var filesystem, /home filesystem, /proc filesystem.

Ans: Root "/" file system: The kernel needs a root file system to mount at start up. The root file system is generally small and should not be changed often as it may interrupt in booting. The root directory usually does not have the critical files. Instead sub directories are created. E.g. /bin (commands needed during bootup), /etc (config files) , /lib(shared libraries).

/usr filesystem : this file system is generally large as it contains the executable files to be shared amongst different machines. Files are usually the ones installed while installing Linux. This makes it possible to update the system from a new version of the distribution, or even a completely new distribution, without having to install all programs again. Sub directories include /bin, /include, /lib, /local (for local executables)

/var filesystem : this file system is specific to local systems. It is called as var because the data keeps changing. The sub directories include /cache/man (A cache for man pages), /games (any variable data belong to games), /lib (files that change), /log (log from different programs), /tmp (for temporary files)

/home filesystem: - this file system differs from host to host. User specific configuration files for applications are stored in the user's home directory in a file. UNIX creates directories for all users directory. E.g /home/my_name. Once the user is logged in ; he is placed in his home directory.

/proc filesystem :  this file system does  not exist on the hard disk. It is created by the kernel in its memory to provide information about the system. This information is usually about the processes. Contains a hierarchy of special files which represent the current state of the kernel .Few of the Directories include /1 (directory with information about process num 1, where 1 is the identification number), /cpuinfo (information about cpu), /devices (information about devices installed), /filesystem (file systems configured), /net (information about network protocols), /mem (memory usage)

Q. How do I use chmod and chown command under Linux?

Ans. Use chown command to change file owner and group information. Use chmod command to change file access permissions such as read, write etc.


Q. what is the command for finding the highest memory occupied file in Linux?
#du -sh * | sort -nr


Q. How to create swap if you don’t have free partition?
this is some what tricky question if you are new to Linux Administration here is the command to create swap if you don’t have free partition before doing this you have  switch off the swap

swapoff -a
dd if=/dev/zero of=/root/swapfile bs=1k count=1024
swapon filename

Q. How to see swap details?

Ans:
            cat /proc/swap
free

Q. How to see/get info about RAM in your system
  
Ans:
free
cat /proc/meminfo

Q. What is the difference between ext2 and ext3

Ans:

ext3=ext2+journaling
"Journaling" is an add-on to a file system that records changes as they are made.
ext2 files system is fast ,less disk writes
ext2 file system in less stable/secure .ext2 file system required to run fsck command if the  system get crashed

Q. How to convert ext2 file system to ext3?

Ans:  tune2fs -j /dev/hda1


Q. How convert ext3 file system to ext2

Ans:   tune2fs -O^has-journal /dev/hda1

Q. What is default block/chunk size for PV

 Ans: 4MB


Q. What is the command to update the disk quota on file system

Ans:  mount -o remount,rw /home

Q.What is the partition type number for swap,RAID,LVM?
  
Ans: 82(swap),fd(RAID),8e(LVM)

Q. What is RAID?

Ans: RAID, stands for Redundant Array of Inexpensive Disks. RAID is a method by which same data or information is spread across several disks, using techniques such as disk striping (RAID Level 0), disk mirroring (RAID Level 1), and disk striping with parity (RAID Level 5) to achieve redundancy, lower latency, increased bandwidth, and maximized ability to recover from hard disk crashes.

 Q. Explain RAID 0?

Ans: RAID level 0 works on “striping” technique. In RAID 0 the array is broken down into strips and data is written into strips. RAID 0 allows high I/O performance but provides no redundancy. RAID 0 Array Size is equal to sum of disks in array. If one drive fails then all data in the array is lost.


Q: - Explain RAID 1?

Ans: RAID Level 1 is based on Mirroring technique. Level 1 provides redundancy by writing identical data to each member disk of the array. The storage capacity of the level 1 array is equal to the capacity of one of the mirrored hard disks in a Hardware RAID or one of the mirrored partitions in a Software RAID. RAID 1 provides redundancy means good protection against disk failure. In RAID 1 write speed is slow but read speed is good.

Q . Explain RAID 5?

Ans: RAID Level 5 is based on rotating parity with striping technique. RAID-5 stores parity information but not redundant data (but parity information can be used to reconstruct data). The storage capacity of Software RAID level 5 is equal to the capacity of the member partitions, minus the size of one of the partitions if they are of equal size. The performance of RAID 5 is based on parity calculation process but with modern CPUs that usually is not a very big problem. In RAID 5 read and write speeds are good.


Q.What is LVM?

Ans: LVM stands for Logical Volume Manager. LVM, is a storage management solution that allows administrators to divide hard drive space into physical volumes (PV), which can then be combined into logical volume groups (VG), which are then divided into logical volumes (LV) on which the file system and mount point are created.

Q. What are the steps to create LVM?

Ans:  
A. Create physical volumes by “pvcreate” command
      #pvcreate /dev/sda2
B. Add physical volume to volume group by “vgcreate” command
                 #vgcreate VLG0 /dev/sda2
C. Create logical volume from volume group by “lvcreate” command.
     #lvcreate -L 1G -n LVM1 VLG0
D. Now create file system on /dev/sda2 partition by “mke2fs” command.
     #mke2fs -j /dev/VLG0/LVM1

Q. What is Volume group (VG)?

Ans: The Volume Group is the highest level abstraction used within the LVM. It gathers together a collection of Logical Volumes and Physical Volumes into one administrative unit.


Q.Tell me all steps to remove a LVM?

Ans: To remove a logical volume from a volume group, first unmount it with the umount command:

umount /dev/<vgname>/<lvname>
and then use the lvremove command:
lvremove /dev/<vgname>/<lvname>


Q. What is disk Quota?

Ans: Disk quota is nothing but restricting the disk-space usage to the users.

Disk quota can be implemented in two ways,
•           One on INODE
•           two on BLOCK

Soft limit - this is the disk limit where the user gets just a warning msg saying that your disk quota is going to expire. This is just a warning, no restriction on data creation

Hard limit - this is the disk limit where user gets error message, I repeat user gets error message stating that unable to create data

Q. How SSL works?

Ans: The Secure Sockets Layer (SSL) is a commonly-used protocol for managing the security for transmission of messages on the Internet. It not only encrypts the data but determines whether both client and server has the expected authentication. 


To request a secure page, the client uses HTTPS.
The server sends the client its public key and certificate.
The client checks that the certificate was issued by a trusted party (usually a trusted Certificate Authority) that the certificate is still valid, and that the certificate is related to the contacted site.
The client uses the public key to encrypt a random symmetric encryption key and sends it to the server, along with the encrypted URL required and other encrypted HTTP data.
The server decrypts the symmetric encryption key using its private key and uses the symmetric key to decrypt the URL and HTTP data.
The server sends back the requested HTML document and HTTP data that are encrypted with the symmetric key.
The client decrypts the HTTP data and HTML document using the symmetric key and displays the information.

Working of SSL:
 * Web Browser checks for the certificate to make sure that the site you are connecting to is the real site and not someone intercepting.
*Determine encryption types that the browser and website server can both use to understand each other.
*Unique codes are send to the browser & server which are used for encryption (server side) & decryption (browser side)
*The browser and Server start communicating; the web browser shows the encrypting icon and web pages are processed secured.

SSL has recently been succeeded by Transport Layer Security (TLS), which is based on SSL. The TLS protocol allows client/server applications to communicate across a network in a way designed to prevent eavesdropping and tampering.

Lets take an E.g ,You are accessing your company secured site.

When you visit your company website, the company  server will automatically redirect you to its secure site using the HTTPS protocol before you can log in. This results in your browser and the company site negotiating a secure channel using SSL.This negotiation goes a little like this (note that I've simplified it greatly). 
The browser sends a message stating what the latest version of SSL it can support and a list of symmetric algorithms it can use.The web server sends back a message with the version of SSL and the algorithm that will be used.It sends its certificate as well. The client verifies the certificate using the known certificates that came with the browser; in other words, it checks that it has been signed by a trusted CA and that it hasn't expired. If the certificate is valid, the browser generates a one-time key for the session, encrypts it with the server's public key (it's part of the certificate), and sends it to the server. The server decrypts the key, then uses that key together with the agreed symmetric algorithm for the rest of the session.Let's take stock. Your browser is certain that the server is who it says it is (your browser is trying to access Your company.com, and the certificate says it's valid for Your Company.com - and the CA agrees). The browser has generated a cryptographic key that will be used for one time only: this particular session. It'll be thrown away after you log out.The key was sent encrypted with Your Company.com's public key, which only Your company.com can decrypt with its private key. There are a couple of other messages sent that check your browser and the web server have agreed on the same key (if anything went wrong, the session is dropped).Once Your company.com has presented you with a login screen (which will be sent over HTTPS, if the company knows what it's doing) and you've filled it in, it'll know who you are. Your id and password will have been sent encrypted over the secure channel that you've both established. Eve and Mallory are completely out of the loop.SSL uses both symmetric and asymmetric encryption algorithms. Symmetric algorithms use the same key to encrypt and decrypt data. They are faster than asymmetric algorithms but can be insecure. Asymmetric algorithms use a pair of keys. Data encrypted using one key can only be decrypted using the other. Typically, one of the keys is kept private while the other is made public. Because one key is always kept private, asymmetric algorithms are generally secure; however, they are much slower than symmetric algorithms. To reap the benefits of both algorithms, SSL encapsulates a symmetric key that is randomly selected each time inside a message that is encrypted with an asymmetric algorithm. After both the client and server possess the symmetric key, the symmetric key is used instead of the asymmetric ones.
  

Working: of TLS:

A TLS client and server negotiate on various parameters used to establish the connection securily by using a handshaking procedure.

    The handshake begins when a client connects to a TLS-enabled server requesting a secure connection and presents a list of supported ciphers and hash functions.
    From this list of supported ciphers & has functions, the server chooses the strongest cipher and hash function that it can support and notifies the client about decision.
    The server sends back its identification in the form of a digital certificate. The certificate usually contains the server name, the trusted certificate authority (CA) and the server's public encryption key.
    Now the client confirms the validity of the certificate by verifing it with CA
    The client encrypts a random number with the server's public key and sends the result to the server. Only the server should be able to decrypt it, with its private key. This random number, is used for encryption (server side) & decryption (browser side)

     If any one of the above steps fails, the TLS handshake fails and the connection is not created.

TLS and SSL are an integral part of most Web browsers (clients) and Web servers. If a Web site is on a server that supports SSL, SSL can be enabled and specific Web pages can be identified as requiring SSL access. Any Web server can be enabled by using Netscape's SSLRef program library which can be downloaded for noncommercial use or licensed for commercial use. TLS and SSL are not interoperable. However, a message sent with TLS can be handled by a client that handles SSL but not TLS.

Comments

Popular posts from this blog

Docker ,MakeFile and Jenkins pipeline

Continuous Deployment - Jenkins , Capistrano And Docker.

Infrastructure As Code - Terraform and AWS.