Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, 27 May 2015

linux Interview Questions and Answers for freshers and experienced


linux Interview Questions and Answers for freshers and experienced


Question: What is Linux?
Linux is an operating system based on UNIX.
First Linux was introduced by Linus Torvalds.
It is based on the Linux Kernel and can run on different hardware platforms manufactured by Intel, MIPS, HP, IBM, SPARC and Motorola etc.


Question: What is the difference between UNIX and LINUX?
Unix originally began as a propriety operating system from Bell Laboratories, which later on leads to different commercial versions.
Linux is free, open source and intended as a non-propriety operating system.


Question: What is BASH?
BASH is short for Bourne Again SHell.
Bash is the opensource version of the Bourne shell distributed with Linux and GNU operating systems.


Question: What is Linux Kernel?
The Linux Kernel is a low-level systems software whose have following:
1. Manage hardware resources for the user.
2. Provide an interface for user-level interaction.


Question: What is LILO?
LILO is a boot loader for Linux.


Question: What is a swap space?
Swap space is space used by Linux to temporarily hold some programs that are running.


Question: What is the basic difference between BASH and DOS?
1. BASH are case sensitive while DOS commands are not.
2. In BASH, / character is a directory separator and \ acts as an escape character.
In DOS, \ character is the directory separator and / serves as a command argument delimiter.
3. DOS follows a naming convention in which 8 character file name followed by a dot and 3 character for the extension. BASH does not follows such convention.


Question: Describe the root account?
The root account is administrator account, and have you full control of the system.


Question: What is CLI?
Full form of CLI is Command Line Interface.


Question: What is GUI?
Full form of GUI is Graphical User Interface.

GUI makes uses images, icon and decorated for user to easily communicating with the computer.


Question: What are symbolic links?
Symbolic links act similarly to shortcuts in Windows.


Question: What are the kinds of permissions under Linux?
Read
Write
Execute


Question: How do you change permissions under Linux?
Use + symbol to add permission.
Use symbol to deny permission.
Use u symbol for User.
Use g symbol for Group.
Use a symbol for all.
Use r symbol for Read.
Use w symbol for write.
Use x symbol for Execute.


Question: What are hard links?
Hard links point directly to the physical file on disk.


Question: What is the maximum length for a filename under Linux?
255 characters (Excluding file path).

Question: What are file-names that are preceded by a dot?
These are hidden files.

Question:What are daemons?
Daemons are services that provide functions that may not be available under the base operating system.

Question: What is the SMTP?
Full form of SMTP is Simple Mail Transfer Protocol.
SMTP is the Internet protocol for electronic mail transmission.
Technically SMTP protocol is used to sending and receiving email From one server to another server.


Question: What is Samba?
Samba is an Open Source/Free Software that provides seamless file and print services to SMB/CIFS clients.


Question: What Samba service do?
Samba is interoperability between Linux/Unix servers and Windows-based clients. So that Linux machines can connect to Microsoft network resources.


Question: In which language Samba is written?
C, C++, Python


Question: What is name of Service used with NFS to provide remote file access for UNIX systems?
NIS


Question: Which service provides searching capabilities on an intranet or domain?
Dig


Question: What is MTA?
Full form of MTA is Message Transfer Agent.
MTA is software that transfers electronic mail messages from one computer to another using a client–server application architecture.
MTA implements both side Client Side and Server Side.


Question: Which port should you open in your host firewall to run web server?
Default port is 80 and 443.


Question: Which ports should you open in host firewall for an email server?
POP3 e-mail protocol use 110 port.
SMTP e-mail protocol use 25 port.
IMAP e-mail protocol use 143 port.


Question: Which IP addressing should you use for Server?
Static IP address.


Question: Which IP address should you use for client desktop?
For client you can use both static and dynamic.


Question: What command is used to remove files?
rm filename



Question: What command is used to remove directory?
rmdir directoryname


you have to empty the directory before remove.


Question: What is the core of Linux Operating System?
Kernel is the core of Linux Operating System.


Question: What is Shell in Linux?
Shell is a command Line Interpreter in Linux.


Question: What is Terminal?
Terminal is a command Line Interface.


Question: Is it legal to edit Linux Kernel?
Yes,
Kernel is released under General Public Licence (GPL), So any one can edit as per requirement.


Question: Is Linux Operating system Virus free?
No,
Linux is known to have least number of Viruses.


Question: What is grep command?
It is used search.


Question: How do you terminate an ongoing process?
use kill command.
For example
kill #333






Monday, 18 May 2015

umask command in unix

umask command in unix

What is umask?
It is a number which define the default permissions which are not given on a file or directory.

Calculation of Umask:
You can simply subtract the umask from the base permissions to determine the final permission for file as follows.

Suppose umask 000
It means User has 0, Group has 0 and other has also 0
It means folder permission
User permission is      7-0 =7 (Read, Write and Execute)
Group Permission is   7-0 =7 (Read, Write and Execute)
Other Permission is    7-0 =7 (Read, Write and Execute)


Suppose umask 002
It means User has 0, Group has 0 and other has 2
It means folder permission
User permission is     7-0 =7 (Read, Write and Execute)
Group Permission is   7-0 =7 (Read, Write and Execute)
Other Permission is    7-2 =5 (Read and Execute)


Suppose umask 022

It means User has 0, Group has 2 and other has 2
It means folder permission
User permission is      7-0 =7 (Read, Write and Execute)
Group Permission is   7-2 =5 (Read and Execute)
Other Permission is    7-2 =5 (Read and Execute)


Suppose umask 027

It means User has 0, Group has 2 and other has 2
It means folder permission
User permission is      7-0 =7 (Read, Write and Execute)
Group Permission is   7-2 =5 (Read and Execute)
Other Permission is    7-7 =0 (No permission)


UmaskUser permissionGroup permissionOthers permission
000allallall
002allallread & execute
022allread / executeread / execute
027allread / executeNo permission

How to find out the umask value?

$ umask
0022

How to change the Umask?

$ umask 002


Wednesday, 13 May 2015

How to add user in linux terminal OR change the password of user.

While we are creating password for user OR updating password, password must be complex so that no one can guess.

Your password should contain following:
1. Lower case alphabetics (like abcde).
2. Upper case alphabetics (like ABCSD).
3. Digits 0 to 9 (like 0123456789).
4. Add Punctuation marks (like ;,'#$#!)
password length must be 6-8 character and must be different from username.


How to add user in linux terminal OR change the password of user.




How to Add user in linux terminal
1. Login with Super Admin in terminal.
2. To create a user type following commands.
user add USERNAME
Please update the USERNAME with desire username.
3. Now Add the password for new user.
passwd USERNAME
Please update the USERNAME with created username and enter key press.
4.Now screen will prompt for the password.
5. You need to give the password for two times.
6. Message will appear in console "All authentication tokens updated successfully."


How to change the password of user in linux terminal

1. Login with Super Admin in terminal.
2. To update the password, type following commands.
passwd USERNAME
Please update the USERNAME with created username and enter key press.

3.Now screen will prompt for the password.
4. You need to give the password for two times.
5. Message will appear in console "All authentication tokens updated successfully."







Thursday, 6 March 2014

Linux Access logs - List of Columns - Simple commands to view Server Logs

Linux Access logs - List of Columns - Simple commands to view Server Logs

When we run our website in Linux server, we must know about the linux access logs and error logs. Because with use of access log we get to know who is accessing our website and with use of error logs we get to know what types of error are coming in our website while running.

So, Access Logs/Error Logs are very important thing not for server admin but also for developer. Because sometimes website is very well developed by developer but due to server error, website is not performing well. If website is not working fine then it can effect the your users and directly it will decrease the annual income.

Get basic understanding of Server/Access logs. And if there is any issue with your server logs then get fixed ASAP. 

Following are the List of columns which are in Access Log

  • Remote Address – IP from which request was made
  • Remote User – Will bank for public pages
  • Date Time – timestamp as per server timezone
  • URL – HTTP request with  GET/POST/PUT/DELETE etc + Arguments + HTTP/HTTPS
  • Status – HTTP response code 
  • Response Size – size of server response in bytes
  • HTTP REFERRAL URL – Referral URL (if present)
  • User Agent – User agent as seen by server

Access log file location
cd /var/logs

Get the First column of log file
cat access.log | cut -d '"' -f1

Get the First colum of log file
cawk '{print $1}' cat access.log

Wednesday, 22 January 2014

Manage Cron Job with PHP - SSH2 Connection

Manage Cron Job with PHP - SSH2 Connection

Today, Cron play very vital role in our website. It reduce the lots of manual work like update the record, Caching the pages, Remove not-required data etc.


Following are use of Cron Job
  1. Update Database records
  2. Copy/Move data from one server to another server
  3. Caching the data for enhance the website performance
  4. Remove the Redundancy data
  5. Remove the un-necessary data.


If there are too-many cron jobs in our web application that its hard to manage the cron jobs through crontabs. Also sometimes Compmay Owner/Manger wants to mange the cron jobs through the Admin Panel.  

Here is sample code with use of which you can mange the cron jobs from PHP. Now you can add/update/delete the cron job from PHP.



        /** check ssh2 connection**/
        if (!function_exists("ssh2_connect")){
            die('ssh2 is not installed');
        }
        /** check ssh2 connection**/
        
        if (!($con = ssh2_connect("www.example.com", 22))) {
            echo "Domain Not exist";
        } else {
            // try to authenticate with username root, password secretpassword
            if (!ssh2_auth_password($con, "username", "password")) {
                echo "credentials is In-Correct";
            } else {
                // execute a command
                if (!($stream = ssh2_exec($con, "ls -al"))) {
                    echo "Execution Failed";
                } else {
                    /** Read output */
                    stream_set_blocking($stream, true);
                    $data = "";
                    while ($buf = fread($stream, 4096)) {
                        $data .= $buf;
                    }
                    fclose($stream);
                    
                    echo $data;
                     /** Read output */
                }
            }
        }



Tuesday, 31 December 2013

SVN Important Commands

SVN is a software version and revision control system distributed as free software under the Apache. Many companies like Apache Software Foundation, Free Pascal, FreeBSD, GCC, Mono, SourceForge and Google also provides Subversion hosting for their free software projects.


Following are SVN Important Commands


Get the New Checkout, It will get from root folder
$ svn checkout [URL]  

Get the New Checkout, It will get from testfolder
$ svn checkout [URL] [testfolder]  

Get the entire update
$ svn update           

Get the update for testfile.php and testfile.php
$ svn update testfile.php, testfile1.php   

Revert the testfile.php
$ svn update testfile.php

Commit with the Message
$ svn commit - m "message here"

Commit the particular file with Message 
$ svn commit - m "message here" testfile.php

Add a new file
$ svn add testFile1.php
$ svn commit -m "test message" testFile1.php

Remove the existing file
$ svn remove -m "test message" testFile1.php
$ svn commit -m "test message" testFile1.php

SVN Info
$ svn info

Get Help on commit command
$ svn help commit

Get log for a file
$ svn log testFile.php

Get log for particular revisionNumber
$ svn log -r 825

Commit a modification to the file test1.php with the commit message in a file named msg
$ svn commit -F msg test1.php





Thursday, 8 August 2013

GitHub in window 7 | GitHub Commands in Linux

GitHub in window 7 | GitHub Commands in Linux

Setup the GitHub in window machine. GitHub is most widely used repositary in development. Get to know commands to work with github.

Create repository in github
Login to your github account, If not have account please register first.
After login to your github account, Click on "Create new Repo" Icon @top right in header to create new repo.
Add "Repository name" and Description of your new repository.
Public Repository is free and private is paid. so let start with free(public repo)
After clicking on "Create repository", your repository will create.
Save the URL of your repo, It will be similar to "https://github.com/poonamc/Ansh"

Download the console for github
ate/delete files in repo
After download, Install it and Run the "Git Bash"

All command must be executed in sample folder.

Add a file in github through console(First Time)
Open "Git Bash"
Go to folder/directory where you want to keep your files @local system using "Cd" command.
Create a folder and go inside that folder
add a sample file in that folder from UI
execute following commands one by one and add your github username/password they they prompt (In Last)

git init
git add test.php
git config --global user.name "Arun"
git config --global user.name "arun@no-spam.ws"
git commit -m "test file"
git remote add origin https://github.com/poonamc/Ansh.git
git push -u origin master


Add a new file in github
add a new file in folder (suppose file name is "arun1.php")
Execute following commands one by one
git add arun1.php
git commit -m "test file arun1.php"
git push -u origin master


Update a file in the github
Change one file and save
Execute the following commands one by one
git add *
git commit -m "updated file"
git push -u origin master


Delete a file
git rm arun1.php
git commit -m "deleted file"
git push -u origin master