Saturday 1 December 2012

How to prompt first three lines of the file?


How to show first three lines of the file?


head command is the answer



Lets show usage of this command on file.txt example



Example of head command usage in ubuntu

head -n X file.txt

where X is number of last lines which we want to prompt

head -n 3 file.txt

This is an example how to use head command in Ubuntu os.




Monday 26 November 2012

How to use tail command in ubuntu

How to use tail commands in Ubuntu?


How to prompt last 3 lines of the file?

Lets show it on the example file: file.txt

How to show last three lines of the text file in ubuntu with tail command

One of the methods is to use tail command

tail -n X file.txt

where X is number of last lines which we want to prompt

tail -n 3 file.txt



How to prom[t last 3 lines of file in ubuntu with command tail

Wednesday 21 November 2012

How to mount usb stick in ubuntu?

How to mount usb drive in ubuntu


First of all plug the usb stick/drive to usb port in your computer

Type in the following command to list the accessible memories:

sudo fdisk -l

You will be given with the similar output:

Screen showing how to mount usb stick with use of command line interface in ubuntu

So now we know which device we want to mount

In this case it is /dev/sdb1 which is 4007MB (4GB) usb stick

Create directory where the file will be mounted

mkdir /media/usb_stick/

And mount your device in ubuntu to that directory

mount /dev/sdb1 /media/usb_stick/

And that is it!

Now you can browse the content of your usb stick just by entering this directory:

cd /media/usb_stick/

Friday 16 November 2012

How to change computer name in ubuntu?

How to change host name in ubuntu?


Get root privileges:

sudo -s

Open the following file:

vim /etc/hostname

Type in the host name in the opened file

Example of how to change the hostname in Ubuntu operating system - computer name.







Now save the changes and exit the file
 :wq

Sunday 11 November 2012

How to setup /etc/network/interfaces file in ubuntu

How to setup interfaces file in ubuntu?


Open interfaces file with text editor (I use vim)

sudo vim /etc/network/interfaces

Now you have two ways to setup your interface

1) setup int to DHCP - in this case interface is eth0:

auto eth0
iface eth0 inet dhcp


2) Setup interface with static IP address:
 
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.254



 Example on /etc/network/interfaces file in Ubuntu terminal - command line interface.

Penetration testing best company?



Sunday 4 November 2012

How to copy a file over the network

How to copy a file over the network?

 

To copy the files over the network in ubuntu the first step is to determine the ip address of the ubuntu machine where we are sending file to:

192.168.0.25

or the DNS name of this computer, for example:

bill-server


Then we have to know the username and password of the user on the destination machine where we are going to copy the files to:

username: chris
password: ****

Then we use scp  command. The structure of the command looks as follow:

scp /path/to/the/file username@IP.ADD.OF.HOST:/path/to/the/destination/directory/

for example:

scp /home/phil/Desktop/CV.pdf chris@192.168.0.25:/home/chris/Desktop/

Then we are asked to type in the password for user chris on 192.168.0.25

chris@192.168.0.25's password:

In case if working DNS the situation in similar, but instead of using IP address we use DNS name of the remote host:


scp /path/to/the/file username@NAME-OF-REMOTE-HOST:/path/to/the/destination/directory/

for example:

scp /home/phil/Desktop/CV.pdf chris@bill-server:/home/chris/Desktop/

Thursday 1 November 2012

How to check directory size


How do check directory size in ubuntu?

Run this simple command:

du -hs /path/to/the/directory/

For example:

du -hs /home/filip/Desktop/Music

Directory size command in Ubuntu exectuted in command line

Monday 29 October 2012

How to find and kill process

How to find and kill process in ubuntu


First step is to find a process which we want to kill.

To do this type command:

ps aux

This will give us the whole list of processes

If you know the name of the process that you want to kill type:

ps aux | grep NAMEofTHEprocess

for example

ps aux | grep firefox

The output will look like:

user  14585  8.8  1.9 544200 161520 ?       Sl   16:27   1:23 /usr/lib/firefox/firefox

I underlined number of the process which we need ...

...to kill the process

kill 14585

If the owner of the process is root then you have to become root first and then run the 'kill' command

sudo -s 

kill 14585

Good luck with killing!

This example shows how kill command looks like in ubuntu terminal.



Friday 26 October 2012

Vim find and replace command

How to search and replace entries in vim?

vim find and replace command looks as follows:

:%s/one/two/g
Looks for 'one' and changes it to 'two' in the whole file

:%s/one/two/gc
Searches strings 'one' and replaces with 'two'. 'c' option means that vim is asking for confirmation first.

:%s/one\/two/gc
This command is changing 'one' to 'two' only if word 'one' matches completely

:%s/one/two/gi
Substitutes 'one' with 'two' with case insensitive option

:%s/one/two/gI
Find and replaces 'one' with 'two' with case sensitive option

Example of find and replace command in vim text editor.



Tuesday 23 October 2012

How to set up ntp

Ubuntu how to set up ntp?


First of all update all your repositories:

apt-get update

Next run the following command

sudo dpkg-reconfigure tzdata

 Choose you location:

NTP server setting up the location - country

NTP server setting up your city

As a confirmation you should get the following information:

Current default time zone: 'Australia/Sydney'
Local time is now:      Fri Oct 19 11:30:48 EST 2012.
Universal Time is now:  Fri Oct 19 00:30:48 UTC 2012.


Next step is to update the address of ntp server. In this case we will use ubuntu ntp server. Open ntpdate file:

sudo vim /etc/cron.daily/ntpdate

and put this line into the file:

ntpdate ntp.ubuntu.com

The last step is to change permissions on the ntpdate file so that they can be read by the system to every user:

sudo chmod 755 /etc/cron.daily/ntpdate

Now you can check in the time is set properly on your ubuntu. Run this command:

date

And that is it!



Saturday 20 October 2012

How to install Network Connect on ubuntu

how to install Network Connect on ubuntu



NC installation on ubuntu is pretty straightforward if you have fresh system:

update all the repositories:

sudo apt-get update


Install the following packages required to make network connect work:

sudo apt-get install -y openjdk-7-jre; apt-get install -y openjdk-7-jdk; apt-get install -y icedtea-7-plugin


And then reboot

sudo reboot

Need IT penetration testing?

If your network connect does not work then execute the following command:

sudo update-alternatives --config java 


and pick opensource java version:

/usr/lib/jvm/java-6-openjdk-i386/jre/bin/java



Now starting network connect from your web browser should work.

Wednesday 17 October 2012

What is ubuntu


Ubuntu  is a standalone linux operating system.

It is designed to be used in the office as well as at home.

The whole project is sponsored by Canonical Ltd. and Ubuntu foundation.

Name 'Ubuntu' comes from language of two south africal tribals: Zulu and Xhosa.

Ubuntu means humanity towards others.

The main goal of this linux distribution is to provide users with complete, user-friendly, stable and open-source operating system.

Ubuntu is released every 6 months.


The main features of Ubuntu are:

- default settings and automatic hardware detection

- simplified administration with use of sudo, apt-get and GUI (graphical user interface)

- Ubuntu is based on the GNOME graphical environment

- Ubuntu Software Center - an easy way to install new applications

- disabled people support software

- multilingual distributions

- according to participate in Debian family Ubuntu has got huge variety of software available and tested

- LTS (Long Term Support) ubuntu version is distributed every two years in October. The support is
provided for another 5 years including security and software updates

- for Ubuntu 12.04 minimum hardware required is 1GHz Pentium4 512Mb RAM and 5Gb HDD


- server version available


Ubuntu is the most popular distribution of Linux operating system in the world and third most popular operating system right after Windows and MacOS.

You can  download ubuntu from here.


And this is probably the best ubuntu forum ever.