Category: Linux Commands

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* LISTEN  1158/mysqld
tcp 0 0* LISTEN 5390/redis-server 1
tcp 0 0* LISTEN 699/smbd
tcp 0 0* LISTEN 4938/openvassd: Wai
tcp 0 0* LISTEN 2218/dnsmasq
tcp 0 0* LISTEN 1345/dnsmasq
tcp 0 0* LISTEN 1029/sshd
tcp 0 0* LISTEN 7420/cupsd
tcp 0 0* LISTEN 1320/teamviewerd
tcp 0 0* LISTEN 1271/postgres
tcp 0 0* LISTEN 2140/master
tcp 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

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'


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

To find number of files in a directory use the following command:

ls | wc -l

To find number for rows in a csv file use the following command:

wc -l filename.csv

grep command syntax

The syntax is:

grep "text string to search” directory-path


grep [option] "text string to search” directory-path


grep -r "text string to search” directory-path


grep -r -H "text string to search” directory-path


egrep -R "word-1|word-2” directory-path


egrep -w -R "word-1|word-2” directory-path


Find  :  ctrl + W

Find and Replace :

Ctrl \
Enter your search term [press return]
Enter your replacement term [press return]
A [to replace all instances]

Select: ALT + M + A
Copy: ALT + 6 (copy as many lines as you like, and they will be pasted in the order you copied them)
Paste: CTRL + U