Bart Simons

Bart Simons


Thoughts, stories and ideas.

Bart Simons
Author

Share


Tags


.net .net 5 .net core Apache C# CentOS LAMP NET Framework Pretty URLs Windows Server WireGuard WireGuard.io access log add analysis android api at the same time authentication authorization automate automation azure azurerm backup bash basics batch bootstrap build capture cheat sheet chromium chroot class cli click to close code coverage code snippet command line commands compile compiling compression containers control controller controlling convert cpu usage create credentials csv csvparser curl data dd deployment desktop detect devices disable diskpart dism distributed diy docker dom changes dotnet core drivers ease of access encryption example export file transfer files fix folders framework generalize getting started ghost ghost.org gui guide gunicorn gzip html html tables icewarp igd imagex import inotify install installation interactive ios iphone itunes java javascript jquery json kiosk kotlin linux live load data loading screen lock screen loopback audio lxc lxd lxml macos manage manually message messages minio mirrored mod_rewrite monitor monitoring mstest mutationobserver mysql net 5 nexmo nginx no oobe node node.js nodejs not installing notification notifications object storage on desktop one command openssl owncloud parallels parallels tools parse perfect philips hue play port forwarding portainer.io powershell processing ps-spotify python quick raspberry pi record rip ripping rsync rtmp save save data sbapplication scraping script scripting scriptingbridge scripts security send server service sharedpreferences sms songs sonos spotify spotify api spotlight ssh stack streaming streamlink studio sudo swarm swift sync sysprep system audio systemd tables terminal testing tracking tutorial twilio ubiquiti ubuntu ubuntu 18.04 ui code unifi unlock unsplash source upnp uptime usb tethering wallpapers wasapi website websites webview windows windows 10 without itunes without oobe workaround xaml

Ubuntu Cheat Sheet

In need of a handy cheat sheet filled with commands you can use in your Linux terminal? This page has got you covered with lots of commands for lots on different use cases. Missing a command? Feel free to send me your ideas, questions and suggested commands in the comments.

Install a full LAMP stack with just one command
sudo apt install lamp-server^

Notes: this stack contains PHP5 on Ubuntu 14.04 or lower, and PHP7 on Ubuntu 16.04 or higher. Not tested with non-LTS releases.

Install PhpMyAdmin
sudo apt install phpmyadmin
Install and configure basic SMB/CIFS shared folder
sudo apt install samba
sudo smbpasswd -a bart

sudo echo "[bart]" >> /etc/samba/smb.conf
sudo echo "path = /home/bart" >> /etc/samba/smb.conf
sudo echo "valid users = bart" >> /etc/samba/smb.conf
sudo echo "read only = no" >> /etc/samba/smb.conf

sudo service smbd restart
Install security updates only
sudo unattended-upgrades -d
Upgrade to the next LTS release
sudo do-release-upgrade
Cleanup the package database and no longer needed packages
sudo apt autoremove && sudo apt clean && sudo apt autoclean
List kernel version and Ubuntu release version
uname -a && lsb_release -a
Edit and update grub settings
sudo nano /etc/default/grub
update-grub
Get unique IPs accessing your site

For Apache:

cat /var/log/apache2/access.log | awk '{print $1}' | sort -u

For NGINX:

cat /var/log/nginx/access.log | awk '{print $1}' | sort -u
Use Ubuntu as a NAT router
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p
Get bash history
cat ~/.bash_history
Get SSH login attempts that exceed set limits
cat /var/log/auth.log | grep "attempts"
Get successful local and remote login attempts
cat /var/log/auth.log | grep "systemd-logind"
Check for open, listening ports
netstat -tulpn
Get RAM usage information
free -m
Get processes currently running as root
ps aux | grep "root"
Stop and start interface
ifconfig eth0 down
ifconfig eth0 up

Note: replace eth0 with your desired network interface.

Manually set static IP on interface
ifconfig eth0 192.168.1.20 netmask 255.255.255.0 broadcast 192.168.1.255
Check for running systemd services
systemctl list-units --state=running --type=service
Check for configuration errors
jounalctl -xe
Get cron jobs

Hourly cron jobs:

ls /etc/cron.hourly

Daily cron jobs:

ls /etc/cron.daily

Weekly cron jobs:

ls /etc/cron.weekly

Monthly cron jobs:

ls /etc/cron.monthly

Other cron jobs:

ls /etc/cron.d
Hardware/software info

List PCI devices:

lspci

List block devices:

lsblk

List USB devices:

lsusb

List CPU devices

lscpu

List general HW info

lshw

List loaded kernel modules

lsmod
File/directory creation, parsing and IO

Create new file

touch new.file

Get contents of file

cat new.file

Overwrite a file

echo "Hello, dear Linux user!" > new.file

Append to a file

echo "Hello, dear Linux user!" >> new.file

Get lines containing a substring

cat new.file | grep "user"
Permissions

Set ownership of a folder, recursively:

chown -R www-data:www-data /var/www/html

Note: this sets the ownership of the /var/www/html folder to the default web server user and group.

Bart Simons
Author

Bart Simons

View Comments