Farid Ahmadian / DevOps

Useful Commands

Public domain

Using regular expresion and sed

cat index.html | sed -e 's/<a href=".*">/" "/g'

Fromating flash storage

first we have to find flash hard link

dmesg | tail



format to FAT

sudo mkdosfs -n 'Label' -I /dev/{hard link}

format to EXT3:

sudo mkfs.ext3 -n 'Label' -I /dev/{hard link}

Display all local devices' IP

sudo arp-scan --localnet

resolve DNS from specific dns server

dig www.rangin.net @a.root-servers.net
dig www.rangin.net @

SOCKS proxy for all programs

tsocks' role is to allow non SOCKS aware applications (e.g telnet, ssh, ftp etc) to use SOCKS without any modification. It does this by intercepting the calls that applications make to establish network connections and negotating them through a SOCKS server as necessary. apt-get install tsocks Edit the file: “/etc/tsocks.conf”

server =
server_port = 1080

Syncing with help of ftp

echo 'mirror --reverse --delete  --only-newer --verbose /home/pesarkhobeee/mp3 /public_html/mp3 ' | lftp -u farid,[email protected] zanjanlug.org

Virtual terminal with help of screen

screen -S "name"
screen -ls #screen list
screen -r screen name #reattach

Request to DHCPServer

sudo dhclient eth0


You can check your current timezone by just running


Thu Mar 21 18:02:49 MST 2012

Or checking the timezone file at

more /etc/timezone


So to change it just run

sudo dpkg-reconfigure tzdata

And follow on screen instructions. Easy.

Also be sure to restart cron as it won’t pick up the timezone change and will still be running on UTC.

/etc/init.d/cron stop
/etc/init.d/cron start

The Network Time Protocol daemon

The ntp daemon ntpd calculates the drift of your system clock and continuously adjusts it, so there are no large corrections that could lead to inconsistent logs for instance. The cost is a little processing power and memory, but for a modern server this is negligible. Installation

To install ntpd, from a terminal prompt enter:

sudo apt-get install ntp


Edit /etc/ntp.conf to add/remove server lines. By default these servers are configured:

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

After changing the config file you have to reload the ntpd:

sudo /etc/init.d/ntp reload

View status

Use ntpq to see to see more info:

sudo ntpq -p

Monitor TCP traffic

tcpdump  -i eth0 -nq host

Automate Download process with help of aria2 and cronjob

touch /home/pi/Downloads/session.txt && aria2c  --save-session=/home/pi/Downloads/session.txt --input-file=/home/pi/Downloads/session.txt -x16 -s16 -k1M --dir=/home/pi/Downloads

crontab -e

0 2 * * * /usr/bin/screen -dmS filmjoo /home/pi/Downloads/download.sh

sshuttle: where transparent proxy meets VPN meets ssh

sshuttle -r [email protected]

Standalone and cli base network manager

iwlist wlan0 scan

Dont display all comments and white space line from a text file

egrep -v '^#|^ *$' /etc/sysctl.conf

BY: Farid Ahmadian
TAG: bash, network, commandline
DATE: 2017-04-23 13:30:10

Farid Ahmadian / DevOps [ TXT ]

With many thanks and best wishes for dear Pejman Moghadam, someone who taught me alot in linux and life :)