Difference between revisions of "Networking & remote access"
Jump to navigation
Jump to search
(Created page with "The following are common and useful commands and utilities in Linux for managing networking, networking related functions, and remote access. == General networking== {| c...") |
m |
||
Line 82: | Line 82: | ||
|- | |- | ||
| ip address add ''IP_address'' || Used under interface eth0 to assign an IP address. | | ip address add ''IP_address'' || Used under interface eth0 to assign an IP address. | ||
+ | |- | ||
+ | | ip r || Show IP addresses for local host (same as 'route') | ||
|- | |- | ||
| lsof -i || Established Connections | | lsof -i || Established Connections | ||
Line 111: | Line 113: | ||
| quit || Logout from a remote connection. | | quit || Logout from a remote connection. | ||
|- | |- | ||
− | | route -n || Display kernel IP routing table | + | | route, route -n || Display kernel IP routing table (local host IP addresses) |
|- | |- | ||
| route add -net ''IP'' || Tell other systems which network to route a system on | | route add -net ''IP'' || Tell other systems which network to route a system on |
Latest revision as of 11:29, 7 January 2024
The following are common and useful commands and utilities in Linux for managing networking, networking related functions, and remote access.
1 General networking
Command | Function |
---|---|
/etc/network/interfaces | Location of network interface information |
cd dir | Access a directory called dir_name on a remote computer. |
curl -O URL | Download contents of a webpage |
curl URL | Get or display file from URL |
curl ifconfig.me | Find one’s external IP address |
dig | Query DNS servers for information on a domain |
dig -x IP_address | Check DNS for reverse lookup an active IP address |
dig domain | Find DNS information and configuration on an active domain name. |
dig@IP domain -t AXFR | DNS Zone Transfer |
echo "nameserver /etc/resolv.conf | Add DNS Server |
echo "1" /proc/sys/net/ipv4/ip forward | Enable IP Forwarding |
ethtool eth0 | Query or control network driver and hardware settings |
export MAC=MAC_address | Change MAC Address |
get file | Download a file from a remote computer to the local machine |
host -I hostname | Display the local IP address of a specified hostname with other information. |
host -l domain nameserver | DNS Zone Transfer |
host IP | Domain Lookup IP |
host domain | Display DNS ip address for domain |
hostname -i | Display the network address of the host name. |
hostname -I | Display all local IP addresses |
hostname -I | Display IP address |
hostnamectl set-hostname hostname | Manage hostname (/etc/hostname) without restarting |
ifconfig | Display the IP and MAC address of a system |
ifconfig -a | Display all network interfaces and IP addresses |
ifconfig interface IP/CIDR | Set IP and netmask |
ifconfig interface mtu size | Change MTU size |
ifconfig eth0 | Display eth0 address and details |
ifconfig eth0 IP up | Activate eth0 with specified IP address |
ifconfig eth0 down | Deactivate eth0 |
ifconfig eth0 up | Activate eth0 |
ifconfig eth0:1 IP/CIDR | Set virtual interface |
ifconfig int hw ether MAC_address | Change MAC Address |
ifdown interface | Down an interface |
ifup interface | Up an interface |
ip a | Display all system IP addresses |
ip addr add IP_address dev eth1 | Add a temporary IP address to interface eth1 |
ip addr show | Display network interfaces and their related IP addresses |
ip address add IP_address | Used under interface eth0 to assign an IP address. |
ip r | Show IP addresses for local host (same as 'route') |
lsof -i | Established Connections |
mail -s 'mail_subject' -c 'cc-mail_address' -b 'bcc-mail_address' 'to-mail_address' | Send an email from the terminal |
nc -vz host port | Scan port in host |
netstat -ant | TCP connections |
netstat -anu | UDP Connections |
netstat -nutlp | Display listening tcp and udp ports and corresponding programs (a netstat command) |
netstat -pnltu | Display all listening ports (a netstat command) |
netstat -r -v | Prints network routing, information, and connections |
netstat -tuln | All tcp and udp listening ports |
netstat -tulpn | Connections with PIDs |
ping -c hostname | Ping an IP address and stop after a specified number of replies |
ping domain/IP | Ping a host by domain name or IP (send ICMP echo request) |
ping host-ip | Check connectivity between two hosts |
quit | Logout from a remote connection. |
route, route -n | Display kernel IP routing table (local host IP addresses) |
route add -net IP | Tell other systems which network to route a system on |
route add default gw IP | Add a default gateway |
route add default gw IP | Set Default Gateway |
share user IP c$ | Mount Windows Share |
smb://IP/sharename | Access Windows SMB Share |
ss -tuln | All tcp and udp listening ports |
ssh -i | Grants user access to openSSH client. |
SSH user@ip_address OR host | Enables SSH login or sign-in to a remote Linux machine by specifying the machine's username and IP address. |
tcpdump | Dump network traffic |
telnet | Grants access to the Telnet protocol user interface. |
traceroute | Show places where packets travel to reach an address |
watch ss -tp | Network Connections |
wget --random-wait -r -p -e robots=off -U URL | Download an entire website |
wget -c file | Continue an interrupted download |
wget URL | Download file from a URL, http://domain.com/file |
whois domain | Show whois information for a domain |
2 Networking: Remote access
Command | Function |
---|---|
/etc/ssh/sshd_config ‘’OR’’ ssh_config | SSHD configuration file (e.g., to change login options or assigned port numbers) |
get file | Download a file to a local computer |
put file | Upload a file to a remote computer |
rsync -a /home /backups/ | Synchronize /home to /backups/home |
rsync -avz /home server:/backups/ | Synchronize files/directories between the local and remote system with compression enabled |
scp -r server:/var/www /tmp | Copy all files and directories recursively from server to the current system's /tmp folder. |
scp file" server:/tmp | Copy file to a remote server (e.g., into the tmp folder) |
scp file" server:/tmp | Secure copy file.txt to the /tmp folder on server |
scp user@host:remote local | Copy file from host to local machine |
scp server:/var/www/*.html /tmp | Copy *.html files from server to the local /tmp folder. |
ssh -i | Open an SSH client; grant user access to SSH client |
ssh -p [port user@host | Connect to a remote machine or server through a specified port. |
ssh -V | Display SSH version installed on the machine |
ssh user@host | Connect to host as user |
ssh user@host | Connect to a remote machine or server based on a valid username and hostname or IP address. |
SSH user@ip_address OR host | Enables SSH login or sign-in to a remote Linux machine by specifying the machine's username and IP address. |
ssh host | Connect to host as user via SSH port (default port 22) |
ssh-copy-id -i .ssh/keyfilename.pub user@hostname | Copy public SSH key to remote server |
ssh-copy-id user@host | Add current user’s key to host to enable keyed or passwordless login |
ssh-keygen -t ed25519 -f ~/.ssh/[filename] -C “[optional comment]” | Generate SSH key on client computer |
sudo nano /etc/ssh/sshd_config, PasswordAuthentication no | Disable SSH password login (set PasswordAuthentication to ‘no’, PermitRootLogin to ‘no’, PubkeyAuthentication to ‘yes’) |
sudo systemctl reload sshd | Restart SSH server |
systemctl status sshd | Show status of SSH server on host machine |
telnet host | Uses telnet's default port 23 to connect to a target hostname, remote machine, or server. |