Latest Entries »

Easily you can edit the file:

gedit ~/.config/nautilus/servers

You can edit the file and remove some entries or if you just want to delete all history you can remove this file:

rm ~/.config/nautilus/servers

Check Ubuntu Version

Check Ubuntu version from terminal:

Step 1: Open the terminal.

Step 2: Enter the lsb_release -a command.

netstat – a command-line tool that displays network connections, routing tables, and a number of network interface statistics.

$ sudo netstat -plnt

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN  1158/mysqld
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 5390/redis-server 1
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 699/smbd
tcp 0 0 0.0.0.0:9391 0.0.0.0:* LISTEN 4938/openvassd: Wai
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2218/dnsmasq
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 1345/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1029/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 7420/cupsd
tcp 0 0 127.0.0.1:5943 0.0.0.0:* LISTEN 1320/teamviewerd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 1271/postgres
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 2140/master
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 699/smbd
tcp6 0 0 :::139 :::* LISTEN 699/smbd
tcp6 0 0 :::9390 :::* LISTEN 4962/openvasmd
tcp6 0 0 :::9392 :::* LISTEN 5442/gsad
tcp6 0 0 :::80 :::* LISTEN 2367/apache2
tcp6 0 0 :::22 :::* LISTEN 1029/sshd
tcp6 0 0 ::1:631 :::* LISTEN 7420/cupsd
tcp6 0 0 :::25 :::* LISTEN 2140/master
tcp6 0 0 :::443 :::* LISTEN 5201/gsad
tcp6 0 0 :::445 :::* LISTEN 699/smbd

Export table structure

pg_dump -U username -d db_name -t table_name –exclude-table-data table_name > table_structure.sql

Here is the Command:

grep -rnw 'directory' -e "pattern"

-r or -R is recursive
-n is line number
-w stands match the whole word
-l (letter L) can be added to have just the file name.


							

Rename File Extension

Change .jpeg to .jpg

rename ‘s#\.jpeg$#.jpg#’ *.jpeg

Chang .jpg to .JPG

rename ‘s#\.jpg$#.JPG#’ *.jpg

Basic Format

grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'

Example

grep -rl 'windows' ./ | xargs sed -i 's/windows/linux/g'

<html>
<head>
<script type="text/javascript">

var slideimages = new Array() // create new array to preload images
slideimages[0] = new Image() // create new instance of image object
slideimages[0].src = "firstcar.gif" // set image object src property to an image's src, preloading that image in the process
slideimages[1] = new Image()
slideimages[1].src = "secondcar.gif"
slideimages[2] = new Image()
slideimages[2].src = "thirdcar.gif"

</script>
 </head>
<body>
<a href="javascript:slidelink()"><img src="firstcar.gif" id="slide" width=100 height=56 /></a>

<script type="text/javascript">

//variable that will increment through the images
var step = 0
var whichimage = 0

function slideit(){
 //if browser does not support the image object, exit.
 if (!document.images)
  return
 document.getElementById('slide').src = slideimages[step].src
 whichimage = step
 if (step<2)
  step++
 else
  step=0
 //call function "slideit()" every 2.5 seconds
 setTimeout("slideit()",2500)
}

function slidelink(){
 if (whichimage == 0)
  window.location = "link1.htm"
 else if (whichimage == 1)
  window.location = "link2.htm"
 else if (whichimage == 2)
  window.location = "link3.htm"
}

slideit()

</script>
</body>
</html>

source: http://www.javascriptkit.com/howto/show3.shtml

Backuping a single table from a database

pg_dump -U username -d database1 -t table_name > /home/backups/table_name.sql

Restoring the table into another database

psql -U username -d database2 < /home/backups/table_name.sql