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 [2026/06/23 12:59] – mikehelpful_ubuntu_commands [2026/09/02 19:57] (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. ===
Line 41: 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/
      
 +=== Copy a directory and all its subdirs to another directory ===
 +  rsync -av /path/to/source/ /path/to/destination/
 +
 === 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 54: Line 61:
   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 72: Line 75:
 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 ==== ==== Ansible/Automation Related Info ====
      
-=== Generate password hashes (useful for Ansible playbooks amongst other things) ===+=== Generate password hashes (useful for Ansible playbooks, Ansible Vault, amongst other things) ===
   mkpasswd --method=sha-512   mkpasswd --method=sha-512
  
 === Generate random keys === === Generate random keys ===
-  openssl rand -base64 48 +  openssl rand -base64 48     
-    +
 === Example of referencing an Ansible Vault === === Example of referencing an Ansible Vault ===
   ansible-playbook playbook.yml --vault-password-file ~/.ansible_vault_pass   ansible-playbook playbook.yml --vault-password-file ~/.ansible_vault_pass
Line 108: Line 115:
 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 127: Line 134:
   sudo netplan apply   sudo netplan apply
      
 +  Update the /etc/hosts file accordingly
 +
 +=== Changing the server's IP address from DHCP to static ===
 +
 +1. Disable cloud-init networking to avoid overwriting the new configuration:
 +  echo "network: {config: disabled}" | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
 +
 +2. cd into /etc/netplan and edit the file that is there.  Replace the contents with the following (supplying the specific IP address/etc where required):
 +
 +  network:
 +    version: 2
 +    renderer: networkd
 +    ethernets:
 +        ens18:
 +            dhcp4: false
 +            addresses:
 +              - 192.168.1.xx/24
 +            nameservers:
 +              addresses:
 +                - 192.168.1.1
 +            routes:
 +              - to: default
 +                via: 192.168.1.1
 +
 +3. Execute ''netplan apply'' to apply immediately or reboot to verify reboot survivability.
 + 
 === Changing the server's host name === === Changing the server's host name ===
   hostnamectl set-hostname [new host name]   hostnamectl set-hostname [new host name]
helpful_ubuntu_commands.1782244772.txt.gz · Last modified: by mike

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki