Advertisement

Linux and Shell programming assignment questions

What is Open Source Technology ?

=> In simple term open-source software is software whose source code is published and made available to the public, enabling anyone to copy, modify and redistribute the source code without paying royalties or fees. Open Source code can evolve through community co-operation. These communities are composed of individual programmers as well as large companies.



Linux , Apache, MYSQL & Php are some of the open-source software service Benefits. Use gor the development and hosting of our popular BWEB content management software.



 Explain file system hierarchy ?

=> File system hierarchy standard describes directory structure and its content in unix and unix like operating system. It explains where file and directories should be located and what it should contain.  


Only linux distributions follow the fHS and that to do partially. Because every distro have their own policy due to which you may notice some differences in the directory tree structure of different distros. 


If you want to find out information about your system's FHS, enter the command 'man nier'. It will display directory structure of your system. 


Explain the following commands :- 

a) ls ---->

        ls command is used to list directory.


b)man---->

        The man command is short for manual and provides in depth information About the the requested command or allows user to search for command related to a particular world.


c)grep---->

            It scans its input for a pattern and displays lines containing to pattern, the lines number of files where the pattern occurs.

     

      grep option pattern file name (s).


d)short ---->

          Shrorting is the ordering of data in ascending or descending order. 


e)who----> 

           The 'who' command is used to get information about currently logged in 

on to system. 


f) tty---->

         Print file name or standard input's terminal.


g)head & tail---->

                         The 'head' command, as name implies, displays the top of the file. When used without an option, it display first 10 line of the code.

          head.emp.list---> shows the file 10 lines. 

                        The tail has more options the command displays the end of the file. It provides an addition method of addressing lines and like head, it display the last 10 by default. 

          tail.tll.emp. list

h)pwd---->

            pwd command shows you what your present working directory is.


i)cat and touch ----> 

 Cat command allow us to create single or multiple file, view contain of file, or concatenate file and re-direct output terminate .


Touch command is the easiest way to create new, empty file  It is also used to change timestamp on existing files and directories.

 

How can we change the permission of the file and directory?

==>  [ me linuxbox  ME ] $ls -e 


Dome-file- rw - wr - r - - 1 mE

me lo 97379 sep 26 18:48 some-file owner

--> The file some file "Some-file" is owned by user "mE"

--> User "mE" has the right to read and write this file.

--> The file owned by the group "mE".

--> Member of the group "mE" can also read and write this file.

--> Everybody else can read this file 

      { me ૬ linux me } $ ls - e|bin|besh -rwxr - xr -x1 root not 36484 teb27 200/bin/besh

--> The file|bin|bash " is owned by user "root"

--> The super user has the right to read, write and execute this file.

--> Member of the group "root" can also read , write and execute this file.

--> Every body else can read and execute this file.

ã…¡   -------> File type , "ã…¡" indicates a regular file A.

rwr  ------> Read, Write and execute permission for the owner of the file.

rwã…¡  -------> Read, Write and execute permission for members of the group owning the file.

rã…¡ã…¡  --------> Read, Write and execute permission for all other user.




chmod :----> Command is used to change the permission of a file or directory.

'    '     '         '     '     '      '    '    '

r   w  x       r    w   x     r   w  x     = 111   111    111

rwã…¡            rwã…¡   = 110     110      110

rwx             ã…¡ã…¡ã…¡         ã…¡ã…¡ã…¡ = 111   000   000


 -----> and so on. 

 rwx = 111   in binary    7

rwã…¡  = 110   in binary    6

r ã…¡ x    =  101  in binary  5

r ã…¡ã…¡  = 100   in binary   4



Draw the architecture of unix system and describe each layer ?

-> Dos, windows are one the operating system and also there's another operating system linux/ unix.

-> Linux is a free open source, linux like operating system. It is available in several different distributions, including cent os, Debian, Ubuntu and Red Hat.

         * Mostly it is used widely bt the web hosting companies and many other specialized applications.



Kernel-->

   -> It is heart of linux OS.

  ->  It is core of OS.

  ->  The karnel act as an intermediate between the computer hardware and various programs/ application shell.


Shell-->

        Shell is  a user program or it's environment provided gor user instraction. Shell is an command language interpreter that execute comments read from the execute commands read from the standard input device { keyboard} or from a file.


Karnel

How the read , write and execute permissions attached with a file are different from that attached to directory?

=> When applying permissions to directories on linux, the permission bits have different meanings than or regular files.

  • The read bit (r) allows the affected user to list the files within the directory.

  • The write bit (w) allow the affected user to create, rename , or delete files within directory, and modify the directory's attributes.

  • The execute bit (x) allows the affected user to enter the directory, and access files and directories inside.

  • The sticky bit (T, or t if the execute bit is set for others)  States that files and directories within that directory may only be deleted or renamed by their owner.
What is vi editor? Explain its modes.
=> 
  1. It is available on almost linux and unix system.
  2. 'Vi' can be used from any types of terminal.
  3. It is also called visual editor.
  4. It is like as notepad to write anything.
Starting vi--->
               The vi editor let's a user create a new files or existing files. The command to start vi  editor is vi  followed by file name.
                  For example:-   
To edit a file called temporary, you would type the vi temporary and then return.



When we start vi for the first time, you will see the screen with files (~) on left side of screen.
     "File name" 21 lines, 385 characters.
 

Modes of vi editor --->

Vi editor consist the three modes which one given below:

  • Command mode
  • Insert mode
  • Ex - mode [ execute mode ]
All of above also shown diagram ethically.

Figure modes of vi editor
Figure: Modes of vi editor 

1. Command mode  

-> In this mode, commands are used to move around and edit text objects such as letters, words, sentences and paragraphs.

-> Pressing the 'ESC' key will return us to command mode if we want to resume ourselves that we should here a beep.

-> In command mode we can use several commands. i.e. [ i, I,o,O, a, A]

-> In the command mode, the commands are case sensitive.

Insert mode ---> 

                   In this modes we insert text into a buffer. There are several commands that we can use enter this mode.

Commands which is used in this mode are given below :- 

      Append at the end of the current line.

      Insert the beginning of a line.

O     Enter insert mode in a new line above the current cursor position.

a      Enter insert mode, the characters type will be inserted after the current cursor position.

 Inserted before the cursor.

O Enter insert mode in a new below the current cursor position.

c Change to the end of the line from the current cursor position.

R Replace characters on the screen with a set of character ending with escape key.

S change an entire line.

C change until "cc" changes the current line . A count changes many time.

  Replace  one character under the cursor. 

  Substitute one character under the cursor , and goto insert mode . Specify a count to substitute a number of characters. A dollar sign ($) will be put at the last character to be substituted.

Execute mode :- 

                 The vi editor is built upon another editor, called ex editor only edits line. From the vi editor we can use the : Command such as [ ": s" and ":w" ] the range must be specifies before the command.

        : abstracting string. 

Explain the advanced editing techniques? 

=> There are a  lots of  techniques. Some of them are given below:-

  1. Making a line
  2. Vi line buffers [ yank command] 
  3. Command line.
  4. Executing Unix command in vi 
  5. Line numbers 
  6. Sorting
  7. Moving Columns , manipulating fields and awk.
  8. Source code formatting c++/ java .
  9. Text formatting
  10. Macros
  11. Double spacing
  12. Delete all lines beginning with or matching pattern.
  13. Editing multiple files.
  14. Hyper - linking to in include files.
  15. Batch execution of vi from a command file.



Explain yank and put command with the example.

     The 'vi' command is similar to the copy command in many editors. It copies the specified line from the content file using various command and put these commands to another location of the file.

          y --> Copy current character

         yy --> (yonk yonk ) copy the current line or single line defined by current cursor position in the buffer.

         yt--> use fo multiple lines. yanks from current cursor position to the marked "t".

         5yy ---> Copy [without cutting] 5 lines

         5yb ----> yank fire words back.

put command :-

The vi command is similar to the paste command in many other editors. It will paste whatever is in buffer from the previous yank command.

       p :   ---> paaste the specified buffer before the current postiong or line. It no buffer is specified the "p" uses the general buffer.

      P : ----> paaste the specified buffer the current position or line. If no buffer is specified the "p" uses teh general buffer.

What will happen on execution of following vi commands ? 

    Move cursor down one line.

control + G  Leave history searching mode without running command.

period  The period (.) is short hand for the bash built in source . It will read and execute commands from a file in the current environment and return the exit.


show the octal representation of thse file permission. 

=>    a) rwx --- x --- w

        => 111    001   010

        b) ---         ---     ---

         => 000   000  000

        =>(0,0,0)octal

        c) ---   -xr        --x

        =>        1010   001

        =>       (5,1)octal

       d) ---    rwx    ---  

     =>     111  

     => (7)octal

Explain about file security in linux. 

=> The linux security model is based on the one used on UNIX systems, and is as rigid as the UNIX security model, which is already quite robust. On a linux system, everyfile is owned by a user owner and don't belong to the group owning the file . For each category of users, read, write and execute permissions can be granted or denied.

    We already used to long option to list files using teh ls -l command, through for other reasons. This command alos displays file permission for these three user  categories; they are indicated by the nine characters that follow the first character , which is the file type indicator at the beginning of the file properties line. As seen in the example below:- 

        marise : -> -1   TO DO

          -rw-rw-r--    1 marise users 5 jan 15:39 TODO    

          marise : -> 1 s   -l/bin/ls   -rwxr-xr-x 1rorot 45948 Aug 9 15:01/bin/ls* 


What is Searching and Submitting operation ?

=> Searching:

              In case of vi-editor has two kind of searches.

                 -----   String Search

                 -----    Character Search

For string search, the \ and ? commands are used. These two commands differ only in the direction whre the search takes place.

  1.  \    command :-    The \ command searches forward  [ downwards ] in the file.
  2. ? command :- The ? command searches backwards [upwards] in the file.
  3. The 'n' and 'N' commands repeat the previous  search command in the same or opposite direction, respectively.
Submitting:- 

--> let us suppose we want to change just a few  character and not the word. The substitude command(s) by itself, replaces a single characters.

--> The  S command, as is usually the case with upper caase command.

C: Change to the end of the line from the current cursor position.

R: Replace to the end of the line from the current cursor position.

S: change the entire line.

C: change until "cc" changes the current line. A count changes that many lines.

 

What is shell ? Explain types of shell. 

=> Shell is a user program or it's environment provided for user instruction. shell is an command language interpreter that execute commands read from the standard input device {keyboard } or from a file .


shell
shell


shell is not part of system kernel, but uses system kernel to execute the program, create file.


Types of shell :- 


 To find  all available shell in your system type following command 

       $cat/etc/shell 

To find your current shell type following command

        $echo $shell

Explain features of vi editor?

=>

  •  It is available on almost all Linux and Unix system.
  • Vi can be used from any type of terminal.
  • It is also called visual editor.
  • It is like as notepad, to write anything.

Features of vi editor:

Powerful undo features:-
=> It has undo features in which user can change what he ha done.

Omni present:-
=> It is an integral part of unix and large step towards comprehending and developing a healthy understanding of unix environment.

Speed :-
=> vi editor ha good speed because vi drive the root from single line editors so that it is fast.


word and character:-
=> Number of people use the vi editor and they will goto length to support it vi user becomes a too much majority the vi editor user is grow rapidly then left out.

what is x window and window management ?
   => 
  • The x-window system makes it possible to  run graphical applications on linux. x is the responsible for the hardware related settings; for example mouse, keyboard and the monitor settings like refresh rate and resolution.
  • The applications just talk to x and tell it what they want to display. X listens to the applications and converts the applications display commands into something that  the graphics hardware can display.
  • Microsoft windows is base on graphical user interface where we can control the application by pointing and clicking . But linux, just like unix or ms-DOS , is completely trend base.
  • Because linux is text based, we run teh GUI on the top of it. In unix the GUI is called x-window system or c-for short.

figure : The architecture of x-window sytestem
fig: the architecture of x-window system.

 
Explain client and Server System? 
=> 
x-client:-
    --->The display output on separate window on the display --- n x-client is an application program that perform certain tasks, communicating with x-server using x-protocol.
    --->The operations performed with a window can hery greately depending on the type of program running.
    --->Few of the most commonly used clients are described below:-
  • The xterm client
  • The x men client
  • The x biff  client
  • The x edit client
  • The x clock client ---> It display an analogue clock on your screen.
  X-server:-
=> The x-server program must be able to handle only applications out, but its input as well as the x-sever manages the display hardware. It also receives requests from the applications to perform some graphical action.

x-clients are written to use the x-protocol, the can run on any system and communication with x-server. 

Whata is remote computing?
=>
--->We have not get taken advantage of xs  networking capabilities.
                       Remember that x-allows you to run a client on a remote machines ae generally, the results of a client program are displayed on a screen connected to the system were the client is running.
---> Once a remote client is running using the client is no different than using a locala client.
--->You can display the applicaton window on your own screen , enter input using your own keyboard. 
--> The display syntax is :-
                    -display [host]: server [screen]
 

Write all the x applications ?
  • x-term : our home base
  • starting up term 
  • scrolling 
  •  outing and posting selections.
  • choosing fonts.
  • blocks
  • smacks
  • Ghostview: Displaying post script.

how can we customize the FVMW window manager?
=> The FVMW is a virtual desktop window manager which s us to place windows on an area much larger than the actual size of teh visible display.

Features offered by the FVWM are:-
  • A simple virtual desktop, which  provides automatic desktop scrolling when the pointers reaches the screen bounding.
  • A programming interface for extensions allowing us to add new features to FVWM.
  • Fully configurable desktop means which appear when we press the mouse buttons.
 Explain the architecture of x-win client / server system with diagram. How is the different from other window.
=> X-uses a client-server model: an x sever communicates with various client programs.  The server accepts requests fro graphical output and sends back user input. The sever may function as:
  • an application displaying to a window of another display system.
  • a system program controlling the video output of a pc.
  • a dedicated piece of hardware.



X provides the place to put the windows on but does not control them, we nee additional software that takes care of handling the windows. The piece of software dealing with the window is the window manager. The window manager is just an x program itself and like the other graphical applications, it also needs the x windows in order to work.

The window manager in x is just another client, it is not part of the x window system,  although it enjoys special privileges and so there is no single window manager, many window manger which support different ways for the user to intact with windows and different styles of window layout, decoration, keyboard and colour  map focus.

The x architecture provides ways for a window manager to perform all those actions on the window, but it does not actually provide a window manger. 




Explain the x-client on a remote mahine and applications . What is  the role of window manager.
=> The x window system is also known as x , is a cross-platform  windowing system designed to operate across networks. It is standard under linux or unix and provides the basic of software and framework to build a graphical user interface(GUI). unlike other popular systems however, such a microsoft windows, x is not a graphical desktop environment, unless optional software is installed , such as gnome or KDE.  

X is based on client-server architecture with interchangeable components. x server and x client do not necessarily have to run on the same computer and can even run on different operating systems. The x application , also referred to as the x client, connects to the x server and can run on a local or remote system. Screen output and user input is manager by x server, which provides the hardware support  for your mouse, keyboard and videos graphics adapter.


Applications :-
A window manager is system software that controls the placement and appearance of window  within a windowing system in a graphical interface. In most window manager are designed to help provide a desktop environment . They work in conjunction with  underlying graphical system that provides required functionality support for graphics hardware, pointing devices and a keyboard, are often written and created using a widget toolkit.

Explain customize x-work environment.
  • The window manager provide everything we need for controlling the window on our desktop but we may want to some addition features and window manager to take care of the desktop.
  • A desktop manager takes care of whole desktop by providing and controlling additional features.
  • The two big players in the desktop manager field are KDE [K desktop environment] and GNOME [GNU network object mode environment]
  • include a single window manger which manages and control the behaviour of window .
  • KDE called applets.
What is shell ? explain different types of shell ?
=> The shell is a part of unix that is most visible  to user . It receives and interprets the command given by user. which is shown in fig:
 

some standard unix shell.
fig: some standard unix shell.
There are two major parts of shell.
i)interpreter:
It reads your commands and work with the kernel to execute them.

ii)program capabilities:
It allow you to write a shell script . A shell script is a file that contains shell commands that performed a useful functions.

What is redirection operator? Describe standard input and standard output?
=> As we know that each command may use standard input stream, standard output stream and standard error stream. These streams are preassigned to the keyboard and the monitor. We can change the standard input and output by temporarily using redirection.

Redirection means the process in which we specify that a file is to be used in the place one of the standard files.


a) Redirecting input:-
We can redirect input file by the (<) sign , the symbol < takes the input needed for a command from a file rather than from the keyboard. < Operator says that "the input for this command coming from somewhere else, not from the keyboard". 
    $cat < newfile

b) Redirecting Output:-  
The symbol > implies redirection of output. It means that is sends the output of a command to a file or a device rather than a monitor or standard output, the symbol >> adds output from without detecting the already exist information
         $ cat file1 > file2 


Explain piping operator with an example .
=> Pipes provide facility to user to connect a command to a another commands. This is very important and useful to combine two programs. It sends the output of one command to input of another command . The two commands joined using (|) pipe character.
pipe 


Points to remember about pipes:-
  • Pipes is an operator, not a command . It tells the shell to immediately take the output of first command, which must be sent to standard output and convert or turn it into input for second command which must be get its input from standard input.
  • A pipe operator receives its input from standard output and sends it to the next command through standard input.
What is redirection operator ?Describe standard input and standard output?
=> -As we know that each command may use standard input stream
, standard output stream and standard error stream. These streams are preassigned to the keyboard and the monitor. we can change the standard input and output by temporarily using redirection. 

- Redirection meand the process in which we specify thta a file is to be used in the place on eof the standard files.


a) Redirecting input :-
We can redirect input file by the (<) sign, the symbol <takes the input needed for a command from a file rather than from the keyboard. < operator says that "the input for this command coming from somewhere else , not from the keyboard". 
         $ cat <newfile
b)Redirecting Output:- 
The symbol > implies redirection of output.   It means that is send the output of a command to a file or a device rather than a monitor or standard output, the symbol >>adds output from a without deleting the already exist information .
         $ cat file1 >file2

Write all bash keyword variables?
=> Global variables are variables that can be accessed from anywhere in the script regardless of the scope . iN bash all variables by default are defined as global , even if declared inside the function.

Local variables can be declared within the function body wiht the local keyword and can be used only inside that function. you can have local variable with same name different functions. 
       Variable - scope.sh

Explain directory stack manipulation.
=>The directory stack is a list of recently visited directories. The pushed builtin adds directories to the stack as it changes the current directory, and the popd builtin removes specified directories from the stack and changes the current directory to the directory removed. The dirs builtin displays the contents of the directory stack. The current directory is always the "top" of the directory stack. 

Don't think that you knows everything about change directory(cd). There might have something you don't know. let say i can go back to my previous location after i change directory. for example I am currently at /var/www/html/ and change directory to /home/footbar/ downloads line tis 
-ch/home/footbar/downloads 
       And now I want to goes bck to /var/www/html,usually we will do this.

-   

Post a Comment

0 Comments