Bash: Networking Commands

less than 1 minute read

Description:

These commands have to do with networking in Linux distros.

Networking Commands

To check your IP address

ifconfig -a

To test connections to another network node

ping (ip)
ping google.com

To see a path a packet takes to its destination

traceroute google.com

To query a DNS server

dig -a google.com
host google.com

To connect to a SSH server

ssh (username@hostname) [command]

To download from any site

wget www.example.com/example.tar.gz

To check open ports on a remote server without telnet (Used often!):

# this will check if port 22 is open on 10.10.80.1
curl -v telnet://10.10.80.1:22

To transfer files between linux boxes or Windows running WSL and a linux box (Used often!):

# transfer foo.txt from current directory to remote /root/ location
scp foo.txt  root@remotehost:/root/

# transfer foo.txt from Windows c:\scripts to remote /root/ location
scp /mnt/c/scripts/foo.txt  root@remotehost:/root/foo.txt

# this also works in reverse! Transfer files from remote location locally
scp root@remotehost:/root/foo.txt /mnt/c/scripts

To view a list of ports that are listening

netstat -a

# Checks to see if ssh is running
netstat -antp | grep sshd