App-Cheats
view release on metacpan or search on metacpan
#############################################################
## Linux Commands - apt-list
#############################################################
# List trusted source lists for packages
sudo apt-key list
#############################################################
## Linux Commands - arp
#############################################################
# View all IP addresses (Debug,pi)
# Scan network
arp -a
netstat -a | findstr 172.17
# Remove arp -a cache (pi,debug)
netsh interface ip delete arpcache
#############################################################
## Linux Commands - awk
#############################################################
# Get the first line, second field (read file)
sui -u | grep "abc" | awk 'NR==1 {print $2}'
#############################################################
## Linux Commands - basename
#############################################################
# Get the basename or last file/directory of a string
basename <string>
#############################################################
## Linux Commands - cat
#############################################################
# Add line numbers to a file
cat -n <file>
# Skip the first line on the file
cat file | tail -n +2
#############################################################
## Linux Commands - chmod
#############################################################
# Set suid for a file
sudo chmod +s file
# Change permission of only the group
chmod g+w file
#############################################################
## Linux Commands - chown
#############################################################
# Fix ownership of user directory
cd home_dir/user_dir
sudo chown -Rh ${PWD##*/} `ls -A`
#############################################################
## Linux Commands - cmatrix
#############################################################
# See the matrix
cmatrix
#############################################################
## Linux Commands - cp
#############################################################
# Update all files that are less than 70 days old according to a file
# (Modified cp command)
cp -s --no-preserve=ownership $FILE `find $DIR/*/$FILE -ctime -70`
# Create a hardlinked folder.
cp -al A B
#############################################################
## Linux Commands - crontab
#############################################################
# Add new crontab
crontab -e
# Start running cron tab
crontab <cron_file>
# View all crontabs on a bench
ls /var/spool/cron/crontabs
# Schedulers
crontab
cron
at
# Crontab job in interactive mode
* * * * * DISPLAY=localhost:11.0 xterm -e 'read -p "aaa - 3"'
# crontab job sent to any particular IP address
* * * * * DISPLAY=1.1.1.1:0 xterm -e 'read -p "aaa - 3"'
# Run a task according to a step amount (say every 5 minutes, crontab)
# min hr dom mon dow command
/5 * * * * my_command
# Run crontab at 3am and 3pm (task)
# min hr dom mon dow command
* 3,15 * * * my_command
#############################################################
## Linux Commands - curl
#############################################################
# View the heading of a server response
+ driver.get('http://www.google.com');
+ time.sleep(2)
+
+ elem = driver.find_element_by_name('q')
+ elem.send_keys('ChromeDriver')
+ elem.submit()
+ time.sleep(2)
+
+ driver.quit()
# Perl script to run a simple selenium test
# Requires having the selenium to be already running:
java -Dwebdriver.chrome.driver=/usr/bin/chromedriver -jar /usr/local/lib/selenium/current.jar
#
+ #!/usr/bin/perl
+
+ use v5.10;
+ use Selenium::Remote::Driver;
+ use Selenium::Remote::WDKeys;;
+
+ my $driver = Selenium::Remote::Driver->new(
+ browser_name => 'chrome', # Default is firefox
+ );
+
+ $driver->get('http://www.google.com');
+ $driver->pause(2000);
+
+ my $elem = $driver->find_element_by_name('q');
+ $elem->send_keys('ChromeDriver');
+ $elem->send_keys( KEYS->{enter} );
+ $driver->pause(2000);
+
+ $driver->quit;
# Check if selenium service is running
systemctl status selenium.service
# Install selenium-server-standalone
# https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/
#
# Step 1 â Prerequisites:
sudo apt install -y unzip xvfb libxi6 libgconf-2-4
sudo apt install default-jdk
#
# Step 2 â Install Google Chrome:
sudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
sudo bash -c "echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list.d/google-chrome.list"
sudo apt update
sudo apt install google-chrome-stable
#
# Step 3 â Installing ChromeDriver:
google-chrome --version
#
# Download same version:
# https://chromedriver.chromium.org/downloads
cd ~/Downloads
unzip chromedriver*.zip
#
# Move it:
sudo mv chromedriver /usr/bin/chromedriver
sudo chown root:root /usr/bin/chromedriver
sudo chmod +x /usr/bin/chromedriver
#
# Step 4 â Download Required Jar Files:
# Create selenium service
#
sudo cp ~/my/git/srto/selenium/setup/_etc_systemd_system_selenium.service /etc/systemd/system/selenium.service
sudo vi /etc/systemd/system/selenium.service
+ [Unit]
+ Description=Selenium Server
+
+ [Service]
+ EnvironmentFile=-/etc/default/selenium
+ User=<USER>
+ Group=<USER>
+ Environment="PERL5OPT=-d:NYTProf" "NYTPROF='trace=0:start=no:addpid=1:slowops=0'"
+ Environment=DISPLAY=:1
+ ExecStart=/usr/bin/java -Dwebdriver.chrome.driver=/usr/bin/chromedriver -jar /usr/local/lib/selenium/current.jar $SELENIUM_OPTS
+ SuccessExitStatus=143
+
+ [Install]
+ WantedBy=graphical.target
# Selenium service environment file
#
sudo cp ~/my/git/srto/selenium/setup/_etc_default_selenium /etc/default/selenium
sudo vi /etc/default/selenium
+ SELENIUM_OPTS="-role standalone -debug"
# Enable selenium service (runs on login)
sudo systemctl enable selenium.service
sudo systemctl start selenium.service
# Run selenium test using curl (for debug)
curl -X POST http://localhost:4444/wd/hub/session -d '{ "desiredCapabilities": { "browserName": "chrome" } }'
curl -X POST http://localhost:4444/wd/hub/session -d '{ "desiredCapabilities": { "browserName": "firefox" } }'
# Type the Enter/Return key in Selenium.
perl -C -E 'say "\N{U+E007}"' î
perl -C -E 'say "\x{E007}"' î
# Make sure to use the apt firefox and not snap
# when seeing: Firefox profile not missing or not accessible.
sudo snap remove firefox
sudo add-apt-repository ppa:mozillateam/ppa
echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozilla-firefox
echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | sudo tee /etc/apt/apt.conf.d/51unattended-upgrades-firefox
#############################################################
## SQLite3 Database
#############################################################
# Install sqlite on Unix (after in zipping the amalgamation file. make sure these 3 are present:
# shell.c, sqlite3.c, sqlite3.h). rename to a.out to sqlite3
# Destroy (completely remove) a zpool
# 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
# View mounting options for ZFS (zpool)
sudo zfs get 'mountpoint,mounted,canmount' brpool/USERDATA
# zpool status is SUSPENDED
sudo zpool clear brpool
sudo zpool clear -nFX brpool # Or this
# Cleanup rpool space for zfs
zfs list -t snapshot -o name | while read f; do sudo zfs destroy -r $f; done
#############################################################
## Ubuntu - Flashdrive
#############################################################
# Make bootable flashdrive from iso file (ubuntu)
# Startup Disk Creator
# https://ubuntu.com/tutorials/create-a-usb-stick-on-ubuntu#3-launch-startup-disk-creator
# Automount external hard drive
vi /etc/fstab
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,
# Ubuntu restarted to a black screen and a blinking cursor.
# Fix:
Control + Alt + F2 # At the same time
#
# Login to PC
#
# Finish upgrade
sudo apt update
sudo apt dist-upgrade
sudo startx
#############################################################
## Ubuntu - Drivers
#############################################################
# Reload sound drivers on Ubuntu
sudo alsa force-reload
#############################################################
## Ubuntu - BIOS
#############################################################
# Check BIOS version on the command line (BIOS update).
sudo dmidecode -s bios-version
# Current: N34ET58W (1.58 )
# Old: N34ET52W (1.52 )
# Find serial number in Ubuntu (BIOS update).
sudo dmidecode -t system | grep Serial # PF2SHW37
# Update BIOS on Ubuntu Lenovo
# 1. Download iso file from here:
https://pcsupport.lenovo.com/cz/en/products/laptops-and-netbooks/thinkpad-p-series-laptops/thinkpad-p14s-gen-2-type-20vx--20vy/20vx/20vx0010ge/pf2shw37/downloads/driver-list/component?name=BIOS%2FUEFI&id=5AC6A815-321D-440E-8833-B07A93E0428C
# 2. Flash iso file to harddrive:
Downloads -> Right Click on iso file
-> Open with other
-> Disk image writer.
# 3. Restart PC -> Enter -> F12 -> Select HD.
# Run a system update on Ubuntu
sudo fwupdmgr update # Updates only the firmware.
#
sudo fwupdmgr install N34ET53W.cab
# (Can get the cat file from:
# https://pcsupport.lenovo.com/de/de/downloads/ds548904-bios-update-utility-bootable-cd-for-windows-10-64-bit-thinkpad-p14s-gen-2-p15s-gen-2-t14-gen-2-t15-gen-2
#)
# During startup would see:
Reading ME failed.
# This fixed it:
sudo fwupdmgr reinstall
( run in 0.487 second using v1.01-cache-2.11-cpan-5511b514fd6 )