User Tools

Site Tools


helpful_ubuntu_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
helpful_ubuntu_commands [2025/08/20 09:50] mikehelpful_ubuntu_commands [2026/08/08 20:15] (current) mike
Line 1: Line 1:
 ====== Helpful Ubuntu/Linux Commands and Procedures ====== ====== Helpful Ubuntu/Linux Commands and Procedures ======
-----+==== Miscellaneous/General Commands ==== 
 === Disable Ubuntu Pro "Ads", Etc. === === Disable Ubuntu Pro "Ads", Etc. ===
-<color red>First implemented in my network 03/20/2025; monitoring for effectiveness</color> 
   sudo pro config set apt_news=false   sudo pro config set apt_news=false
  
Line 42: Line 42:
 === Determine the date the system was installed (not 100% reliable) === === 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)   tune2fs -l /dev/vda2 | grep ‘Filesystem created:’ (replace vda2 with device where root filesystem is located)
-  + 
 +=== Copy an existing partition to a new partition === 
 +  sudo rsync -aAXv --info=progress2 --exclude='/lost+found' /disk2/ /newdisk/ 
 === Finding largest files/directories === === Finding largest files/directories ===
   du -a /dir/ | sort -n -r | head -n 20 (replace 20 with the # of lines you wish to have returned)   du -a /dir/ | sort -n -r | head -n 20 (replace 20 with the # of lines you wish to have returned)
Line 48: Line 51:
 === Find the oldest file in a directory (and it's subdirectories) === === Find the oldest file in a directory (and it's subdirectories) ===
   find . -type f -printf '%T+ %p\n' | sort | head -n 1   find . -type f -printf '%T+ %p\n' | sort | head -n 1
 +  
 +=== Finding files by file name (or file name portion) ===
 +  find . -iname <filename to search for>  
      
 === Disable colors in the vi editor by default === === 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.   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 (<color red>ONLY when you want to re-install the operating system!</color>)** 
- 
-  dd if=/dev/zero of=/dev/sda count=1 bs=512 
-   
 === Find files consuming the root file system === === Find files consuming the root file system ===
   mkdir /tmp/rootbind   mkdir /tmp/rootbind
Line 70: Line 72:
 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: 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 <inputfile.ts> -vcodec copy -acodec copy <outputfile.mp4>   ffmpeg -i <inputfile.ts> -vcodec copy -acodec copy <outputfile.mp4>
 +
 +**Overwrite/blast the boot block on the hard drive (<color red>ONLY when you want to re-install the operating system!</color>)**
 +
 +  dd if=/dev/zero of=/dev/sda count=1 bs=512
 + 
 +==== Ansible/Automation Related Info ====
      
 === Generate password hashes (useful for Ansible playbooks amongst other things) === === Generate password hashes (useful for Ansible playbooks amongst other things) ===
   mkpasswd --method=sha-512   mkpasswd --method=sha-512
 +
 +=== Generate random keys ===
 +  openssl rand -base64 48    
 +
 +=== Example of referencing an Ansible Vault ===
 +  ansible-playbook playbook.yml --vault-password-file ~/.ansible_vault_pass
 +  
 +==== Extracting encrypted/password protected .ZIP files ====
 +.zip files that have been encrypted with AES-256 cannot be extracted via the default 'unzip' program that the distro installs.  Instead, one must install **7zip**.  Perform the following steps:
 +  apt update
 +  apt install 7zip
 +Once installed, use the **7zz** command to extract the file (you will be prompted for the password used to initially encrypt the archive if one was used):
 +  7zz x <filename>
 +
 ==== Cookbook for passing client IP address to systems behind a reverse proxy ==== ==== Cookbook for passing client IP address to systems behind a reverse proxy ====
 === On the reverse proxy: === === On the reverse proxy: ===
Line 90: Line 112:
 Restart apache. Restart apache.
  
-=== Create new GPT disk partition ===+==== Create new GPT disk partition ====
 sudo into an elevated shell and then perform the following: sudo into an elevated shell and then perform the following:
   parted /dev/sdX (where X is the letter of the drive to be manipulated)   parted /dev/sdX (where X is the letter of the drive to be manipulated)
Line 102: Line 124:
 Then proceed to format the new drive, i.e. **mkfs -t ext4 /dev/sdb1** Then proceed to format the new drive, i.e. **mkfs -t ext4 /dev/sdb1**
  
-==== Changing the server's IP address ====+==== Updating Network Settings ==== 
 + 
 +=== Changing the server's IP address ===
   sudo vi /etc/netplan/00-installer-config.yaml   sudo vi /etc/netplan/00-installer-config.yaml
   find the existing IP and change it to the desired IP; 'wq' out of the file   find the existing IP and change it to the desired IP; 'wq' out of the file
   sudo netplan apply   sudo netplan apply
      
-==== Changing the server's host name ====+=== Changing the server's host name ===
   hostnamectl set-hostname [new host name]   hostnamectl set-hostname [new host name]
      
 +=== Changing the server's DNS settings ===
 +Edit the **/etc/netplan/50-cloud-init.yaml** file appropriately (file name may vary)\\
 +Apply the changes with the **sudo netplan apply** command
  
 +=== Disabling the local DNS resolver ===
 +This becomes necessary if a DNS server is deployed on the local system, since it will conflict with the local resolver unless it is first disabled.
 +
 +Edit **/etc/systemd/resolved.conf** and change **//DNSStubListener//** to "no":
 +  DNSStubListener=no
 +
 +Update the **resolv.conf** symlink:
 +  sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
 +  
 +Restart **systemd-resolved**:
 +  sudo systemctl restart systemd-resolved
 +  
 +Validate that the system is no longer listening on port 53:
 +  ss -tulpn | grep 53
 +  
 +==== Creating SSH Keys ====
 +To create an ed25519 key -
 +  ssh-keygen -t ed25519 -C "<comment>" -f ~/.ssh/<keyname>
helpful_ubuntu_commands.1755708630.txt.gz · Last modified: by mike

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki