Skip to content

Help on Linux

Command to display linux version information

lsb_release -a

Command to add a new user with home directory and bash shell

sudo useradd -m <user_name> -s /bin/bash

Command to set (or) reset password for a user

sudo passwd <user_name>

Command to modify the default shell of a user (for example bash)

sudo usermod -s /bin/bash <user_name>

Alternative command to change the default shell of a user (for example bash)

chsh -s /bin/bash

Command to check the current shell

echo $0

Command to check the PATH variable

echo $PATH

Command to update the PATH variable

export PATH=<new-path>

Command to add a user to sudo group

sudo usermod -a -G sudo <user_name>

Command to check the groups to which a user belongs

sudo groups <user_name>

Command to add firewall rule to iptables

sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT 
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p udp --dport 8080 -j ACCEPT

Command to display firewall rules from iptables

sudo iptables -L -n

Check list to verify after linux upgrade

  • Verify the firewall rules in iptables

Command to configure time zone

sudo dpkg-reconfigure tzdata

Command to check the running status of DHCP server

sudo service isc-dhcp-server status

Command to restart the DHCP server

sudo service isc-dhcp-server restart