Skip to main content

Small Commands, Issues And Guides - A Collection

This page is for commands, issues or guides which don't need to be added as a separate page. You can search for them with Ctrl + F or click the "Search" at the top.

Only Allow PublicKey Authentication Overriding Password Auth

No idea why, some systems are completely ignorant and ignoring the demand for no password auth.

Add this line to bottom of SSHD config. No idea why, but the The PA parameter is no and ChallengeResponseAuthentication is also no, but still auths with password... sigh.

AuthenticationMethods publickey

Give A MongoDB User Permission To Command "mongodump”

use admin
db.grantRolesToUser( "USER", [ "readWrite" , { role: "readWrite", db: "config" } ] )

Remove Apache2/Nginx Python3’s modules for Certbot

Apache2: python3-certbot-apache
Nginx:
python3-certbot-nginx

Remove a package that is being stubborn and will not remove

sudo dpkg --force-all -P <package-name-to-remove>

Absolute headache with MySQL 8.0 mixing with MariaDB’s installs

MySQL 8.0 has the config file in /etc/mysql/mysql.conf.d/mysqld.cnf like MariaDB has /etc/mysql/mariadb.conf.d/50-server.cnf.

BY DEFAULT MySQL binds publicly… MariaDB binds to internal localhost.

Use mysqld --verbose --help | grep bind to actually see it bind publicly on first installation…

If you mix MariaDB’s config files + MySQL’s, it’s not my.cnf, mysql.cnf, the conf.d folder entirely or any other configuration. It is literally mysqld.cnf in the mysql.conf.d folder. What utter BS.

Fixing the repository error for changing it’s “version” for updates

Example: N: Repository 'http://deb.debian.org/debian bullseye InRelease' changed its 'Version' value from ‘11.7' to '11.8'

One command: apt-get --allow-releaseinfo-change update

Taken from: https://www.reddit.com/r/debian/comments/ca3se6/for_people_who_gets_this_error_inrelease_changed/ 

The certbot command that actually works to change the email

certbot update_account –email <email>

SlimeWorldManager Installation
  • Download the latest Spigot/Paper jar you require and pop it into the main directory.
  • Put the slimeworldmanager-plugin-<version>.jar into the same place as the server.jar.
  • Update your startup command to include -javaagent:<thejar>, like the below:

Taken from: https://github.com/cijaaimee/Slime-World-Manager/blob/master/.docs/usage/install.md

Crons not running for WHMCS on cPanel - They hang and sit there doing nothing
  • Log into WHM (The admin side of cPanel)
  • Navigate to "MultiPHP INI Editor" by searching it on the left hand side.
  • Select the version of PHP that your site uses, using the editor is easier.
  • Increase the following variables:
    • "max_execution_time" - 240/300 should be fine.
    • "max_input_time" - same as above.
    • "memory_limit" - Higher than 1024M.
  • Click "Apply"
  • Repeat for all versions of PHP that are having a timeout error.
  • Restart cPanel's FPM with systemctl restart ea-php81/82-php-fpm.

Taken from: https://support.cpanel.net/hc/en-us/articles/360052237994-How-to-increase-the-Max-Execution-Time-directive-for-PHP

RAID Ubuntu 20.04

Taken from: https://kifarunix.com/setup-software-raid-on-ubuntu-20-04/  

Note - If you get error: partition length of [BIGGERSIZE] sectors exceeds the msdos-partition-table-imposed maximum of [SMALLERSIZE]

Followhttps://askubuntu.com/questions/84538/trouble-creating-3tb-ext4-partition-due-to-msdos-partition-table-imposed-error

Switching RAID 1 to RAID 0

Scroll down a bit to locate the answer from nmr, which includes removing the mirror, changing, waiting then resizing.

Taken From: https://serverfault.com/questions/915284/is-it-possible-to-convert-raid1-to-raid0-without-system-reinstalation

Remove .html/.php extension

Read the answer from Arnon, the big threaded part with explanations.

Taken from: https://stackoverflow.com/questions/38228393/nginx-remove-html-extension

Can't run a module or build a NodeJS app due to no such file and has no installation candidate

One simple command to clear out the old NPM packages already downloaded from cache.

npm clean-install

You can then go about reinstalling with yarn build or another method used.

Any NPM package doesn't install into /usr/local/bin, such as ghostcms - Updating the prefix location due to weird bug

Taken from: https://askubuntu.com/questions/1102579/using-npm-to-install-file-to-usr-local-bin 

For some weird reason, on some installs of NodeJS and then installing npm, it ends up at /usr and not /user/local to allow /user/local/bin packages to be viewable, such as GhostCMS's ghost-cli. Stupid bug, no idea why. Run the set prefix command to fix it, then install Ghost's CLI fine.

The reason why this needs doing is due to the error "Error: Cannot find module '/usr/local/bin/ghost'" and "MODULE_NOT_FOUND" which is absolutely idiotic since you literally just installed it, but in the wrong place. This will happen when trying to start the service and it fails.

root@S01:/var/www/website.com# npm get prefix
/usr
root@S01:/var/www/website.com# npm config set prefix /usr/local
root@S01:/var/www/website.com# npm get prefix
/usr/local
sudo npm install ghost-cli@latest -g
Date command in linux - Echo and crontab support

When using the date command in terminal, if you are echoing the line, you need to make sure you don't escape the percentages as it will include the slashes.

  • echo $(date +"\%d-\%m-\%Y").txt
  • echo $(date +"%d-%m-%Y").txt

However, when inside crontab, you will need to escape them otherwise cron believes it is an operand and not a variable to pass. And example is below where you also need the path in a full string for it to echo properly and understand the date variable.

You can also use -d for naming how we name things, such as "yesterday" "tomorrow" or "2 months ago".