Ubuntu Cheat Sheet

General

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

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 $?

Networking

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

Files

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

Apache

  • sudo htpasswd /etc/apache2/.htpasswd nextuser

apt

bash

  • 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/10.8.0.34/10.8.0.29/’ $x ;done