CentOS, Ubuntu, Kali Linux Useful Commands

The commands that work on most version of Linux environment are listed below.

1. Identify OS Version

$ lsb_release -a   //Identify exact version of OS

$ uname -a      //Identify 64 or 32 bit version

 

2. Identify Open ports

$ sudo lsof -i -P -n

$ sudo lsof -i -P -n | grep LISTEN

 

3. Restart or Reboot server

$ sudo reboot

$ sudo shutdown -r //command restarts server

$ sudo shutdown -r +30 //command restart server in another 30 mins

 

4. Vi Text Editor – How to save the changes and quit the editor?

  1. After making changes, press Esc Key
  2. Press : (colon). You will notice your cursor appearing at the lower left corner of the screen beside a colon prompt.
  3. Enter any of these options as per your need.

wq! = write the changes to file and quit

q! = exit without writing the changes.

w! = write the changes to file without exiting

 

5. Disable IPv6

Step 1: “ip address” command shows that IPv6 is unnecessarily enabled on the interfaces.

server@it:~$ ip 

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:7e:46:8d:63 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.1 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::215:5dff:fe64:8d36/64 scope link
valid_lft forever preferred_lft forever

Step 2:  use editor to add configurations to disable IPv6

server@it:~$ sudo nano /etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

Step 3: reload sysctl

server@it:~$ sudo sysctl -p

Step 4: review interfaces

server@it:~$ ip a

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:7e:46:8d:63 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.1 scope global eth0
valid_lft forever preferred_lft forever

 

6. List Status of all installed services

$ service –status-all

 

7. UFW – Uncomplicated Firewall

$ sudo service ufw {status | start | stop | restart | force-reload}

 

8. Purge vs Remove

$ apt remove <package_name>         //Command uninstall the package however the configuration files remain on the system.

$ apt purge <package_name>            //Command uninstall the package and removes all the configuration files except those exist in home folder (/home/bob)

You may also like...

Thank you for visiting us. To continue receiving updates, please Subscribe to our Social Media Channels.

Menu Title