App-Cheats

 view release on metacpan or  search on metacpan

MANIFEST.SKIP  view on Meta::CPAN

\bBuild$
\b_build/
\bBuild.bat$
\bBuild.COM$
\bBUILD.COM$
\bbuild.com$

# and Module::Build::Tiny generated files
\b_build_params$

# Avoid temp and backup files.
~$
\.old$
\#$
\b\.#
\.bak$
\.tmp$
\.#
\.rej$
\..*\.sw.?$

cheats.txt  view on Meta::CPAN


#############################################################
## FTP Server/Client
#############################################################

# Create an ftp server on ubuntu.
https://linuxconfig.org/how-to-setup-and-use-ftp-server-in-ubuntu-linux
# 1. Install
sudo apt install vsftpd
#
# 2. backup original /etc/vsftpd.conf
#
# 3. Update /etc/vsftpd.conf
write_enable=YES                 # Dont forget THIS!
local_root=/home/$USER           # Not needed? Works when commented out.
local_umask=002
chroot_local_user=YES
pasv_enable=Yes
pasv_min_port=10000
pasv_max_port=10100
allow_writeable_chroot=YES

cheats.txt  view on Meta::CPAN

sub hashem { return { @_ } } # Ok.


#############################################################
## Perl Inplace Edit
#############################################################

# Print attempted change of Shebang line
perl -ple 's{^#!.*$}{#!/usr/bin/perl}' my_file

# Change Shebang line of file (without making a backup)
perl -i -ple 's{^#!.*$}{#!/usr/bin/perl}' my_file

# Change Shebang line of file (and backup the file in the same directory)
perl -i'.bak' -ple 's{^#!.*$}{#!/usr/bin/perl}' my_file

# Change Shebang line of file (and backup the file in another directory)
perl -i'Backup/*.bak' -ple 's{^#!.*$}{#!/usr/bin/perl}' my_file

# Change comment indentation for a file to 60 (some reason need to subtract 1 from the desired amount)
perl -i'.bak' -lpe 's/^(\s*+[^#]+?)\s*(#+.*$)/sprintf "%-59s %s",$1,$2/e' my_file

# Customizable inplace editing (only when desired). Undef disables inplace editing
perl -le 'local $^I = ($run == 1) ? "bak_*" : undef'

# Apply export markings to many files
#

cheats.txt  view on Meta::CPAN

    open STDERR, ">>", \$output or die $!;
    eval { App::Pod->run };
    if ( $@ ) {
        $output = $@;
        chomp $output;
    }
}

# Backup and restore STDOUT in perl.
# Backup current STDOUT
open(my $backup_stdout, '>&', STDOUT) or die "Can't duplicate STDOUT: $!";
# Redirect STDOUT to a file
open(STDOUT, '>', 'output.txt') or die "Can't redirect STDOUT: $!";
# Write to the redirected STDOUT
print "This goes to the output.txt file\n";
# Restore original STDOUT
open(STDOUT, '>&', $backup_stdout) or die "Can't restore STDOUT: $!";

# Give a name to an anonymous sub/function.
# Inside the sub.
# Single global variable.
my $code = sub {
    local *__ANON__ = 'code_name';
    ...
};
$code->();

cheats.txt  view on Meta::CPAN

snapshot_root   /media/<USER>/SRTO_BACKUP/BACKUP
no_create_root  1
#
retain  hourly  24
retain  daily   7
retain  weekly  4
retain  monthly 12
#
link_dest       1
#
backup /home/<USER>	timPC
backup /etc			timPC
backup /opt			timPC
backup /root		timPC

# Test rsnapshot configuration file
rsnapshot configtest

# Create crontab for rsnapshot
crontab -e
#
# min hr    dom   mon   dow   command
  0   *     *     *     *     /usr/bin/rsnapshot_runner.pl hourly
  50  23    *     *     *     /usr/bin/rsnapshot_runner.pl daily
  40  23    *     *     6     /usr/bin/rsnapshot_runner.pl weekly
  30  23    1     *     *     /usr/bin/rsnapshot_runner.pl montly

# Rsnapshot example
http://www.edwiget.name/2018/05/simple-rsnapshot-incremental-backups-to-removable-disks/#codesyntax_1


#############################################################
## RTCP (RBS,real time command processor)
#############################################################

# Show rtcp options (DES,DEBHAWK)
rtcp he
rtcp he options
rtcp he op2

cheats.txt  view on Meta::CPAN

# Your crypttab should contain a line like
cryptHome     UUID=26a4b17a-aad3-436a-89f4-a68a4c4c371d    none    luks,timeout=30
# with the UUID of the device you just encrypted above
# (i.e. the /dev/sdXX device). You can find it out by using
# e.g. lsblk -f (it should say "crypto_LUKS" under FSTYPE in the output).

# Ubuntu hard drive encryption.
# SKIP FOR EXTERNAL HARD DRIVES
# 5. Update your /etc/fstab file (file system mounting:
# Finally, your fstab should contain a line like
/dev/mapper/cryptHome   /home/srto-backup       ext4    defaults        0       2
#
# to mount the decrypted partition in your filesystem.
# The mapped name (cryptHome) must match the one you
# defined in the crypttab. Replace username by the name of the actual user.
#
# You could also mount it under /home, but then you will have
# all user's home directories in one encrypted drive - that
# means all of them need to know the partition's password to open it on boot.

# Originally thought these were also necessary for an external hard drive.

cheats.txt  view on Meta::CPAN

# Error mentions mount: wrong fs type, bad option, bad superblock.
#
# See disks:
lsblk
#
# If you can see your drive thats good.
# Run this to see if the system can use it:
sudo fdisk -l
#
# Run this command to attempt to repair bad superblocks on the drive.
sudo xfs_repair /dev/mapper/srto_backup
#
# Mount again after repair is done:
sudo mount /dev/mapper/srto_backup /media/<USER>/SRTO_BACKUP

# Restore corrupted USB drive.
# Warning: could not erase sector 2: Input/output error.
sudo dd if=/dev/zero of=/dev/sdb bs=1M count=40
#
# Disk repair/recovery tool.
sudo apt install testdisk


#############################################################
## Ubuntu - Hard Drive Encryption - Simple
#############################################################

# Ubuntu hard drive encryption. (simple)
#
# Create the encrypted partition:
sudo cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/DEVICE
#
# Map the encrypted container:
sudo cryptsetup luksOpen /dev/DEVICE srto_backup
#
# Wipe the partition (optional):
# Only if it has sensitive data already.
sudo shred -vfz /dev/mapper/secret-container
#
# Create a filesystem in the mapped container:
sudo mkfs.ext4 -L MY_BACKUP /dev/mapper/srto_backup
#
# Rename the drive label in gparted (optional)
sudo apt-get install gparted.
# open gparted.
# choose the thumbdrive from the dropdown in the top-right corner.
# unmount the volume (right-click on drive)
# right click and choose "label"
# click on green tick to apply changes.
#
# Find out ID by running
sudo fdisk -l
blkls /dev/<DEVICE>
#
# Or find UUID here for the device
ls -l /dev/disk/by-uuid/
#
# Can find the UUID in gparted.
#
# Add device to be auto decrypted
sudo vi /etc/crypttab
srto_backup UUID=e5dc6e53-2df1-40d8-baff-75ba4f1eacf4 none luks,noauto,size=256
#
# Need to run after updating cryptab:
sudo update-initramfs -u -k all
#
# Add device to be auto mounted
sudo vi /etc/fstab
srto_backup /media/SRTO_BACKUP auto nosuid,nodev,nofail,x-gvfs-show 0 2

# Close encrypted drive
sudo umount /dev/mapper/luks-ea444ab0-445e-4c5c-931b-27922bfa5510
sudo cryptsetup close luks-ea444ab0-445e-4c5c-931b-27922bfa5510
# file found here:
ll /dev/mapper/


#############################################################
## Ubuntu - Hard Drive Create and Delete

cheats.txt  view on Meta::CPAN

lsblk
#
# Remove signature.
sudo wipefs -a /dev/sdb
#
sudo cfdisk /dev/sdb

# Setup a new external hard drive (with Marco,ubuntu,hd)
lsblk    # To find out DEVICE name
sudo cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/DEVICE
sudo cryptsetup luksOpen /dev/DEVICE srto_backup
sudo mkfs.ext4 -L MY_BACKUP /dev/mapper/srto_backup
sudo mount /dev/mapper/srto_backup /media/<USER>/SRTO_BACKUP


#############################################################
## Ubuntu - Evolution
#############################################################

# Completely remove ubunutu evolution services.
https://askubuntu.com/questions/315640/how-do-i-completely-remove-evolution
#
cd /usr/share/dbus-1/services

cheats.txt  view on Meta::CPAN

# WILL DELETE ALL DATA INSIDE
sudo zpool destroy brpool

# Unmount a busy device
umount -l /PATH/OF/BUSY-DEVICE
umount -f /PATH/OF/BUSY-NFS (NETWORK-FILE-SYSTEM)

# ZFS list snapshots
zfs list -r -t snapshot -o name,creation

# Send snapshot backup
sudo zfs send rpool/USERDATA/tim_e5bkz1@autozsys_zh25vd | sudo zfs receive brpool/USERDATA

# Send incremental backup
sudo zfs send rpool@june15b | sudo zfs receive -Fd brpool

# Mount external hard drive with ZFS
sudo zpool list 				# Show available pools
sudo zpool import 			# Shows the brpool name
sudo zpool import brpool	# Import brpool
sudo zpool list 				# Pool now added

# Create a Snapshot with a specific text
sudo zfs snapshot rpool/USERDATA/tim_e5bkz1@june15

cheats.txt  view on Meta::CPAN

UUID=E2B4CF51B4CF273F /media/MY_BACKUP auto nosuid,nodev,nofail,x-gvfs-show 0 2
#
# Find out ID by running
sudo fdisk -l
blkls /dev/<DEVICE>
#
# Or find UUID here for the device
ls -l /dev/disk/by-uuid/

# Backup PC in Ubuntu using timeshift (not for zfs)
https://linuxconfig.org/ubuntu-20-04-system-backup-and-restore

# Allow writing to flash drives
sudo chown $USER:$USER /media/<USER>-srto/ -R


#############################################################
## Ubuntu - Update Error
N#############################################################

# Problem: Did a partial upgrade,



( run in 0.514 second using v1.01-cache-2.11-cpan-49f99fa48dc )