• What Is A Shell?

    Shell is a interface between user and the kernel. Even though there can be  only one kernel ; a system can have many shell running simultaneously . Whenever  a user enters a command  through keyboard the shell communicates with the kernel  to execute it and then display the output to the user.

  • What Are The Different Types Of Commonly Used Shells On A Typical Linux System?

    csh,ksh,bash,Bourne . The most commonly used and advanced shell used today is “Bash”.

  • What Is The Equivalent Of A File Shortcut That We Have On Window On A Linux System?

    Shortcuts are created using “links” on Linux. There are two types of links that can be used namely “soft link” and “hard link”

  • What Is The Difference Between Soft And Hard Links?

    Soft links are link to the file name and can reside on different filesytem as well; however hard links are link to the inode of the file and has to be on the same file sytem as that of the file. Deleting the orginal file makes the soft link inactive (broken link) but does not affect the hard link (Hard link will still access a copy of the file)

  • How Will You Pass And Access Arguments To A Script In Linux?

    Arguments can be passed as:

    scriptName “Arg1” “Arg2”….”Argn” and can be accessed inside the script as $1 , $2 .. $n

  • What Is The Significance Of $#?

    $# shows the count of the arguments passed to the script.

  • What Is The Difference Between $* And [email protected]?

    [email protected] treats each quoted arguments as separate arguments but $* will consider the entire set of positional parameters as a single string.

  • How Will You Find The 99th Line Of A File Using Only Tail And Head Command?

    tail +99 file1|head -1

  • Explain About “s” Permission Bit In A File?

    “s” bit is called “set user id” (SUID) bit.

    “s” bit on a file causes the process to have the privileges of the owner of the file during the instance of the program.

    Eg: Executing “passwd” command to change current password causes the user to writes its new password to shadow file even though it has “root” as its owner.

  • How Can You Find Out How Long The System Has Been Running?

    Command “uptime”

  • What Is The Difference Between $$ And $!?

    $$ gives the process id of the currently executing process whereas $! shows the process id of the process that recently went into background.

  • What Are Zombie Processes?

    These are the processes which have died but whose exit status is still not picked by the parent process. These processes even if not functional still have its process id entry in the process table.

  • How Will You Copy File From One Machine To Other?

    We can use utilities like “ftp” ,”scp” or “rsync” to copy file from one machine to other.

    Eg: Using ftp:

    ftp hostname

    >put file1

    >bye

    Above copies filed file1 from local system to destination system whose hostname is specified.

  • I Want To Monitor A Continuously Updating Log File, What Command Can Be Used To Most Efficiently Achieve This?

    We can use tail –f filename . This will cause only the default last 10 lines to be displayed on std o/p which continuously shows  the updating part of the file.

  • I Want To Connect To A Remote Server And Execute Some Commands, How Can I Achieve This?

    We can use telnet to do this:

    telnet hostname –l user

    >Enter password

    >Write the command to execute

    >quit

  • I Have 2 Files And I Want To Print The Records Which Are Common To Both?

    We can use “comm” command as follows:

    comm -12 file1 file2… 12 will suppress the content which are unique to 1st and 2nd  file respectively.

  • How Will You Connect To A Database Server From Linux?

    We can use isql utility that comes with open client driver  as follows:

    isql –S serverName –U username –P password

  • What Are The 3 Standard Streams In Linux?

    0 – Standard Input

    1 – Standard Output

    2 – Standard Error

  • I Want To Read All Input To The Command From File1 Direct All Output To File2 And Error To File 3, How Can I Achieve This?

    command <file1 1>file2 2>file3

  • What Will Happen To My Current Process When I Execute A Command Using Exec?

    “exec” overlays the newly forked process on the current  process ; so when I execute the command using exec, the command gets executed on the current shell without creating any new processes.

    Eg: Executing “exec  ls”  on command prompt will execute ls and once ls exits, the process will shut down

  • How Will You Emulate Wc –l Using Awk?

    awk ‘END {print NR} fileName’

  • Given A File Find The Count Of Lines Containing Word “abc”?

    grep –c  “ABC” file1

  • What Is The Difference Between Grep And Egrep?

    egrep is Extended grep that supports added grep features like “+” (1 or more occurrence of previous character),”?”(0 or 1 occurrence of previous character) and “|” (alternate matching)

  • How Will You Print The Login Names Of All Users On A System?

    /etc/shadow file has all the users listed.

    awk –F ‘:’ ‘{print $1} /etc/shadow’|uniq -u

  • How To Set An Array In Linux?

    Syntax in ksh:

    Set –A arrayname= (element1 element2 ….. element)

    In bash

    A=(element1 element2 element3 …. elementn)

  • Write Down The Syntax Of “for “ Loop?

    Syntax:

    for  iterator in (elements)

    do

    execute commands

    done

  • Write The Syntax For “if” Conditionals In Linux?

    Syntax:

    If  condition is successful

    then

    execute commands

    else

    execute commands

    fi

  • What Is The Significance Of $? ?

    $? gives the exit status of the last command that was executed.

  • How Will I Insert A Line “abcdef” At Every 100th Line Of A File?

    sed ‘100iABCDEF’ file1

  • Write A Command Sequence To Find All The Files Modified In Less Than 2 Days And Print The Record Count Of Each?

    find . –mtime -2 –exec wc –l {} ;

  • How Can We Find The Process Name From Its Process Id?

    We can use “ps –p Process Id”

  • What Are The Four Fundamental Components Of Every File System On Linux?

    bootblock, super block, inode block and  datablock

  • What Is A Boot Block?

    This block contains a small program called “Master Boot record”(MBR) which loads the kernel  during system boot up.

  • What Is A Super Block?

    Super block contains all the information about the file system like size of file system, block size used by it,number of free data blocks and list of free inodes and data blocks.

  • What Is An Inode Block?

    This block contains the inode for every file of the file system along with all the file attributes except its name.

  • How Can I Send A Mail With A Compressed File As An Attachment?

    zip file1.zip file1|mailx –s “subject” Recepients email id

    Email content

    EOF

  • How Do We Create Command Aliases In Shell?

    alias Alias Name=”Command whose alias is to be created”

  • What Is The Use Of A Shebang Line?

    Shebang line at top of each script determines the location of the engine which is to be used in order to execute the script.

SHARE
Previous articleLearn I2C Protocol
Next articleLearn USB Protocol
Tanmoy Deb is Founder of Equonix Tech Lab Pvt Limited, which is India's first Commercial Satellite Development Company. He is working 12+ years into embedded, electronics, product development. His designed products raised more than 10Million Dollars from different crowdfunding campaign. He is also an author on different technical books. His hobby is music, creating tools for programmers.

LEAVE A REPLY

Please enter your comment!
Please enter your name here