====== Helpful Ubuntu/Linux Commands and Procedures ======
----
=== Disable Ubuntu Pro "Ads", Etc. ===
First implemented in my network 03/20/2025; monitoring for effectiveness
sudo pro config set apt_news=false
=== List hard drive serial numbers ===
lsblk --nodeps -o name,serial
=== List processes and the ports they are listening on ===
netstat -tulpn | grep LISTEN
=== Reload systemd manager configuration after changes made ===
sudo systemctl daemon-reload
=== List all installed packages ===
apt list --installed
=== Search for available packages ===
apt-cache search
=== Changing default editor for visudo ===
sudo update-alternatives --config editor
=== Disable GUI screen lock ===
Settings -> Privacy -> Screen Lock
=== Disable GUI screen blanking ===
Settings -> Power -> Blank Screen
=== Create Samba User ===
sudo smbpasswd -a
=== List Samba Users ===
sudo pdbedit -L
=== Determine the date the system was installed (not 100% reliable) ===
tune2fs -l /dev/vda2 | grep ‘Filesystem created:’ (replace vda2 with device where root filesystem is located)
=== Finding largest files/directories ===
du -a /dir/ | sort -n -r | head -n 20 (replace 20 with the # of lines you wish to have returned)
=== Disable colors in the vi editor by default ===
Create (or edit, if it exists) ~/.vimrc; into this file add the command syntax off, and save the file.
**Overwrite/blast the boot block on the hard drive (ONLY when you want to re-install the operating system!)**
dd if=/dev/zero of=/dev/sda count=1 bs=512
=== Find files consuming the root file system ===
mkdir /tmp/rootbind
mount --bind / /tmp/rootbind
du -d 1 -h /tmp/rootbind
=== Solution for Linux systems not visible in the "Network Neighborhood" on Windows machines ===
apt install wsdd
=== View video resolution capabilities ===
xrandr -q
=== Converting OTA DVR recordings to .MP4 ===
OTA DVR recordings are saved as **.ts** files, which are not compatible with DaVinci Resolve (my video editor of choice). For this reason, we must convert the files into a format that “DR” can comprehend. We can do this on linux using the ffmpeg package:
ffmpeg -i -vcodec copy -acodec copy
=== Generate password hashes (useful for Ansible playbooks amongst other things) ===
mkpasswd --method=sha-512
==== Cookbook for passing client IP address to systems behind a reverse proxy ====
=== On the reverse proxy: ===
Ensure that websockets support is enabled
=== On the host: ===
Create /etc/apache2/conf-available/remoteip.conf with the following contents:
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy x.x.x.x (replace w/ IP address of trusted proxy)
Execute the commands:
ln /etc/apache2/conf-available/remoteip.conf /etc/apache2/conf-enabled/remoteip.conf
ln /etc/apache2/mods-available/remoteip.load /etc/apache2/mods-enabled/remoteip.load
Edit ''/etc/apache2/apache2.conf'' and find the **LogFormat** lines. Change each occurrence of **%h** to **%a**.
Restart apache.
=== Create new GPT disk partition ===
sudo into an elevated shell and then perform the following:
parted /dev/sdX (where X is the letter of the drive to be manipulated)
mklabel gpt
Acknowledge the warning if one is given
unit TB
mkpart primary 0.00TB 2.00TB (or 3.00TB, 4.00TB, etc. depending on the size to be created)
print (to view the new partition)
quit (to exit parted)
Then proceed to format the new drive, i.e. **mkfs -t ext4 /dev/sdb1**