LINUX SYSADMIN COMMANDS (SERVER)

updated: 09.08.2020 (08-09-20)

All commands tested on Ubuntu Server 20.x.
Some of the commands may, or may not work, or be useful in desktop enviroment.

please use these tools with caution, data loss can happen.
use -h or -help if necessary.

( Example: [interface] = eth0 or ens33 )

( Example: [ip address] = 192.168.2.1 )

( Example: [ip address/subnetmask] = 192.168.2.1/24 )

( Example: [command name] = vsftp )

 

 

---

 

 

USEFUL COMMANDS

 

command description
sudo ifconfig # basic networking information
sudo dpkg --list # list all installed packages on the system
sudo nmap [ip address] # display open ports
sudo bmon # watch network traffic in realtime
sudo iftop # watch network traffic in realtime
sudo tcpdump -i [interface] # watch network traffic in realtime from your interface
# Example: Track traffic on network's device with it's ip address:

sudo tcpdump -i [host interface] host [target ip address]


# Example: Track network traffic:

sudo tcpdump -i [host interface] net [network ip address/subnet]

( Example of network address with subnet mask (class C): 192.168.2.0/24 )
sudo dhclient [interface] # renew dynamic addresses
sudo dstat # recource monitor
sudo tshark -i [interface] # capture network packets
sudo lshw −class network # network info
sudo ethtool [interface] # info of network device
sudo ip addr add [ip address/subnet mask] dev [interface] # temporary assign static ip address
sudo ip link set dev [interface] up # the ip can then be used to set the link up
sudo ip link set dev [interface] down # the ip can then be used to set the link down
sudo ip route add default via [ip address] # set default gateway address
sudo ip route show # show default gateway
sudo ip addr flush [interface] # reset network configuration
sudo /etc/init.d/networking restart # start with new configuration
sudo service vsftpd start # start vsftpd
sudo ufw status verbose # enable UFW and check its status
sudo ufw reload # restart ufw
sudo smbstatus # check is samba active
sudo service --status-all # show services installed
sudo service [service name] start # start service
sudo apt install open-vm-tools # install vmware tools terminal
sudo ip a # to quickly identify all available Ethernet interfaces
sudo lshw -class network # identify all network interfaces available to your system
sudo ip addr add [ip address/subnet mask] [interface] # to temporarily configure an IP address
sudo ip route show # to verify your default gateway configuration
sudo apt install ubuntu-mate-core # install desktop on server
sudo apt install ne # install ne text editor, vim alternative
sudo nautilus # access the filesystem with full priviledges with default gnome file manager gui
sudo aptitude # text based manager for installing software

# necessary basic UFW rules

sudo ufw allow 22/tcp
sudo ufw allow 2222/tcp
sudo ufw allow 80/tcp
sudo ufw allow 21/tcp
sudo ufw allow 443
sudo ufw allow ntp
sudo ufw allow 67:68/tcp
sudo ufw allow 53
sudo ufw allow samba
sudo ufw allow Apache

# here is a example network configuration file used by netplan to put static address:
# configuration file can be found at: /etc/netplan

network:
version: 2
renderer: networkd
ethernets:
[interface]:
dhcp4: no
addresses: [host ip address/subnet mask]
gateway4: [default gateway ip address]
nameservers:
addresses: [dns ip address,sec dns ip address]

# here is a example network configuration file used by netplan to put dynamic address:
# configuration file can be found at: /etc/netplan

network:
version: 2
renderer: networkd
ethernets:
[interface]:
dhcp4: true

 

 

---

 

 

SUBNETTING (example in yellow):

 

number of subnets:
1 2 4 8 16 32 64 128 256
number of hosts per subnet: 256 128 64 32
16 8 4 2 1
subnet mask: /24 /25 /26 /27 /28 /29 /30 /31 /32

 

 

example of original network ID: 192.168.4.0 /24 ,with 4 subnets:
network ID: subnet mask: host ID range: number of usable hosts: broadcast ID:
192.168.4.0 /26 192.168.4.1 - 192.168.4.62 62 192.168.4.63
192.168.4.64 /26 192.168.4.65 - 192.168.4.126 62 192.168.4.127
192.168.4.128 /26 192.168.4.129 - 192.168.4.190 62 192.168.4.191
192.168.4.192 /26 192.168.4.193 - 192.168.4.254 62 192.168.4.255
subnet mask: 255.255.255.192
wildcard mask: 0.0.0.63
binary subnet mask: 11111111.11111111.11111111.11000000
IP / network class type: C
CIDR notation: /26

 

Subnet masks:
CIDR subnet mask: subnet mask: binary subnet mask:
/24 255.255.255.0 11111111.11111111.11111111.00000000
/25 255.255.255.128 11111111.11111111.11111111.10000000
/26 255.255.255.192 11111111.11111111.11111111.11000000
/27 255.255.255.224 11111111.11111111.11111111.11100000
/28 255.255.255.240 11111111.11111111.11111111.11110000
/29 255.255.255.248 11111111.11111111.11111111.11111000
/30 255.255.255.252 11111111.11111111.11111111.11111100
/31 255.255.255.254 11111111.11111111.11111111.11111110
/32 255.255.255.255 11111111.11111111.11111111.11111111

 

 

 

page by: henkka.info

v1.0b