Thursday 12 January 2017

5 Reasons Why Ubuntu Is More Secure Than Windows & Mac OS X




1. Linux Has Limited Default User Privileges

In Windows OS/Mac OS users get the authentication to access everything on the system as, by default, they are given administrator privileges. When viruses make their way to the system, they can easily spread and invest the rest of the system. Here is why Linux is great. On Linux the users are given lower access and hence virus can only reach to the local files and folders so the system wide damage is saved.
What that means is that even if a Linux system is compromised, the virus won’t have the root access it would need to do damage system wide; more likely, just the user’s local files and programs would be affected. That can make the difference between a minor annoyance and a major catastrophe in any business setting.

2. Linux Has Tougher Program Permissions

This sort of goes along with Linux Privileges but there is a difference. In a Mac OS or Window OS machine, if a user downloads an email with an attachment that has a virus, all the user has to do is run the file and the file can infect the system but on Linux and even Chrome OS, that’s not possible. Linux/Ubuntu would require the user to actually give the program even more permissions before it gets a chance to install anything on your machine, brilliant coding. I do hear that starting from Windows 10, Windows OS will try to follow a similar setup.

3. Linux Has A Powerful Auditing System

Linux/Ubuntu has awesome Auditing system by default. Including detailed Logs that can tell you exactly what a user/program attempted to do. Basically an internal key logger that monitors everything including failed login attempts.

4. Linux Is Open Source

This matters much more than people think. Because Linux is an open source operating system, whenever a virus or a huge bug goes public, millions of people from all over the world try their best to help patch it up. Once a user finds a way to fix the issue they can send their updated code directly to the official Linux employees and they can add it to the next update. This system works well unlike Windows OS/Mac OS X where only a few paid employees have direct access to the code hence it usually takes longer for Windows and Mac systems to fix a bug or secure an exploit. Lets hope Linux stays open source forever!

5. Linux Has Less Users That Use It

Whether we Linux people like to admit or not, not many people use Linux! Yes we know it is used by almost every web hosting company/company organization to store data etc but when it comes to the regular user, your neighbor, your girlfriend/boyfriend or your grandma, most of them will choose Windows over any other OS and this is a good thing because it means less viruses/spyware will be designed for Linux. The less popular you are, the more people ignore you, get it? Lol it’s really as simple as that.
Let me just remind you all that even though Linux/Ubuntu might be the most secure OS in the market, it doesn’t mean it is 100% hacker proof. Hell, there are a few viruses on the Linux system that’s why you still need some anti-virus apps for Ubuntu installed on your system to be safe no matter what.

source:http://www.ubuntufree.com/

25 Linux commands for System Administrators


man

The most important command in Linux, man shows information about other commands. You can start by running “man man” to find more about the man command.

uptime

This command tells you how long your system has been running for.

w

This command shows who is logged into your system and what they are currently doing.

users


This shows you the usernames of users who are currently logged in to your system.

whoami

Prints the username of the user that you are currently logged in as.

grep

Finds text in files and outputs the neighbouring text along with file names. You can recursively search in multiple files using -r. You can output only file names using -l.

less

If the case your output of a command or file contests are more your screen can accomodate, you can view it in parts using less. The output of the previous command using less is the following.

cat

This helps in displaying, copying or combining text files.

pwd

Prints the absolute path of the current working directory.

ssh


This commands helps you connect to a remote host. You can either connect as
   ssh remote_host
or
   ssh remote_username@remote_host

scp

Copy files securely and remotely over servers.

sudo

Use this to run any command as the superuser (root). It is prefixed to the commands.

service

You can use it to perform tasks on different services, which runs scripts for the corresponding services. For instance, to restart apache2 web server, we use service apache2 restart. A sudo is prefixed to run as root because all users do not have permission to run the scripts.
Do note that some do not require sudo.

locate

Find files on your system by name.

chmod

Chmod changes file permissions in Linux. You can set which users or user groups have what kind of access to a particular file. The topic of file permissions in Linux is a huge one in itself and beyond the scope of this post. You can, however, look at this thread for further reading.

chown

Change ownership of a file to a user or a user group.

pkill

Kill a process using this command.

crontab

This is a program that is used to manage cron jobs in Linux. To list existing cron jobs, run crontab -l.

alias

You use an alias when you are in need to shorten a command.
Aliases are not saved after you close the current terminal session. To do that you need to create an alias in ~/.bashrc.

echo

Display or output text. Used in making bash scripts.

cmp

This command compares two files byte by byte.

mount

Mounts a filesystem. There are different options in this command that you can use which enables you to mount even remote file systems.

pmap

This command is used to show the memory map of a process. You can get the process id (pid) by running
   ps aux | grep <process_name>
Then run pmap -x <pid>

wget

Downloads a file from a network.

ifconfig

This command is used to configure a network’s interface. Just writing the command displays the configuration.
With this, we come to the end of the list of the important commands. We hope that it was educational for you. If you have any issues, feel free to comment below!

Wednesday 11 January 2017

Write a singleton class.


package com.instanceofjava;

public class Singleton {

static Singleton obj;
private  Singleton(){
}

public static Singleton getInstance(){
if(obj!=null){
return  obj;
}
else{
 obj=new Singleton();
return obj;
}
}

public static void main(String[] args) {

Singleton obj=Singleton.getInstance();
Singleton obj1=Singleton.getInstance();

if(obj==obj1){
System.out.println("indhu");
}
else{
System.out.println("Sindhu");
}
               System.out.println(obj==obj1);

}
}


Output:
indhu
true

Find out middle index where sum of both ends are equal.


//Here first we traverse the array once to find total sum of array…. then we again start from 0th position and start subtracting value from total sum and go on adding it to leftsum and then compare leftsum and total remaining sum

public class FindMiddleIndexWhenSumOfBothSidesEqual {
 public static int findMiddleIndexMethod(int[] intArray){
int sumArray = 0;
int leftSumArray=0;
for (int i=0; i<intArray.length;i++){
sumArray+=intArray[i];
}
 for (int j=0; j<intArray.length; j++){
sumArray=sumArray-intArray[j];
 if (leftSumArray==sumArray){
return j;
}
leftSumArray+=intArray[j];
}
return -1;
}
public static void main(String[] args) {
int[] ia = {1, 5, 8, 7, 8, 1, 5};
int mi = findMiddleIndexMethod(ia);
System.out.print(“Middle index of the array when both ends sums equal: “+ia[mi]);
 }
}


Program: Find out duplicate number between 1 to N numbers


Description:
You have got a range of numbers between 1 to N, where one of the number is
repeated. You need to write a program to find out the duplicate number.

Code:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.java2novice.algos;
import java.util.ArrayList;
import java.util.List;
public class DuplicateNumber {
    public int findDuplicateNumber(List<Integer> numbers){
         
        int highestNumber = numbers.size() - 1;
        int total = getSum(numbers);
        int duplicate = total - (highestNumber*(highestNumber+1)/2);
        return duplicate;
    }
     
    public int getSum(List<Integer> numbers){
         
        int sum = 0;
        for(int num:numbers){
            sum += num;
        }
        return sum;
    }
     
    public static void main(String a[]){
        List<Integer> numbers = new ArrayList<Integer>();
        for(int i=1;i<30;i++){
            numbers.add(i);
        }
        //add duplicate number into the list
        numbers.add(22);
        DuplicateNumber dn = new DuplicateNumber();
        System.out.println("Duplicate Number: "+dn.findDuplicateNumber(numbers));
    }
}

Output:
Duplicate Number: 22

- See more at: http://www.java2novice.com/java-interview-programs/duplicate-number/#sthash.3SiB4ivV.dpuf