Ubuntu Cheat Sheet


  • system and kernel info:  uname -a
  • ubuntu version info:  lsb_release -a
  • ubuntu version info:  head -n1 /etc/issue
  • distro and release info:  cat /etc/*release

ubu14.04 services

ubu16.04 services

  • list all services:  systemctl list-units --type service --all
  • enable/disable service: sudo systemctl [enable/disable] nameofservice.service
  • show service status:  systemctl status foo.service
  • Check whether a service is enabled or not:  systemctl is-enabled foo.service; echo $?


  • sudo iwlist wlan0 s
  • sudo ifdown -a
  • sudo ifup -a
  • ifconfig
  • sudo lshw -C network
  • netstat -i
  • ip link show
  • lsusb


  • deleting all zero length files in dir: find . -type f -empty -delete


  • sudo htpasswd /etc/apache2/.htpasswd nextuser



  • do action on result of grep
    ls | grep pattern |while read -r line ; do echo “$line”; done
  • recursive grep lists only filenames and searches resulting files for Get command even if they’re binary
  • grep -lra X-Geo_contents|while read -r line ; do grep -a GET $line; done
  • copy files when list is too long – mkdir logbac/202002 ; for x in logs.2.bac/202002*;do mv $x logbac/202002/ ;done
  • for x in *.log;do sudo rename ‘s/’ $x ;done
  • zip all folders (not files) in a dir – one zip each
    for i in */; do zip -r "${i%/}.zip" "$i"; done