Misc
Nextcloud unencrypt all files for a user with SSE (Server Side Encryption)
This is a command for decrypting all files for a user when using SSE in Nextcloud.
Here’s a breakdown:
-
sudo -u www-data
: This runs the following command as thewww-data
user, which is typically the user that runs the web server and has the necessary permissions to access Nextcloud’s files. -
php occ encryption:decrypt-all <USERNAME>
: This is the command that actually performs the decryption.-
php occ
: This runs Nextcloud’s command line interface. occ stands for ‘ownCloud console’, as Nextcloud is a fork of ownCloud. -
encryption:decrypt-all <USERNAME>
: This is the command to decrypt all files.<USERNAME>
should be replaced with the username of the user whose files you want to decrypt.
-
MySQL Reset The Root Password (You idiot.)
This command stops the mysql server and starts a new one locally, it then logs you in as root and allows you to change the password.
-
sudo systemctl stop mysql
: This command stops the MySQL service. It’s necessary to stop the service before we can start it in safe mode. -
sudo mysqld_safe --skip-grant-tables --skip-networking &
: This command starts the MySQL service in safe mode. The--skip-grant-tables
option allows us to connect to the database without a password and with all privileges, and--skip-networking
prevents other clients from connecting to the database. -
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '<new_password>'; FLUSH PRIVILEGES;
: This command connects to the MySQL database as the root user. It then changes the password to<new_password>
, replace<new_password>
with the new password you want to use for the root user. -
sudo killall -QUIT mysql mysqld_safe mysqld
: This command tells the mysql server running to stop. -
sudo systemctl start mysql
: This command starts the MySQL service again.
Change The System Timezone
These commands are for setting your timezone
-
sudo timedatectl list-timezones
: This command lists all available timezones. -
sudo timedatectl set-timezone <timezone>
: This command sets the system timezone to some timezone. One example of a timezone isEurope/Stockholm
. -
sudo timedatectl
: This command displays the current date and time settings, including the newly set timezone.
Make all minecraft servers in a directory “online-mode=false”
A bash command to set all minecraft servers in child directories to offline mode.
-
sudo sed -i 's/online-mode=true/online-mode=false/g'
: This command usessed
, the stream editor, to find and replace all instances ofonline-mode=true
withonline-mode=false
in a file. The-i
option tellssed
to edit files in-place (i.e., change the original file). -
$( sudo find . -type f | grep server.properties)
: This command is used to find all files namedserver.properties
in the current directory and its subdirectories. Thefind . -type f
command finds all files in the current directory, andgrep server.properties
filters for files named server.properties. The output of this command (a list of file paths) is passed as an argument to thesed
command.
In the context of a Minecraft server, online-mode
determines whether the server should authenticate players with Minecraft’s account system. Setting online-mode
to false
allows players with unofficial Minecraft clients to join the server.
Combine Markdown Files Into One
This bash script combines all Markdown files in each subdirectory into a single Markdown file named after the subdirectory. It loops through each subdirectory, concatenates all Markdown files in it using cat
, and outputs the result to a new Markdown file.
Find unique values for a field in a bunch of json files
Lists all unique values for fields in all json files in the current directory.
The command is a pipeline of several commands:
find . -type f -name "*.json"
: This command searches for all JSON files in the current directory and its subdirectories. The.
specifies the current directory as the starting point for the search.-type f
restricts the search to files, and-name "*.json"
matches any file that ends with.json
.xargs cat {}
: This command reads items from the standard input (in this case, the list of JSON files found by thefind
command), and executes thecat
command for each item. Thecat
command concatenates and prints the contents of the files.jq .<name_of_the_field> -c
: This command usesjq
, a command-line JSON processor, to extract the values of the specified field from the JSON data. Replace<name_of_the_field>
with the name of the field you’re interested in. The-c
option tellsjq
to output each JSON object on a single line.sort
: This command sorts its input lines. In this case, it sorts the values extracted byjq
.uniq
: This command filters out adjacent duplicate lines from its input. In this case, it removes duplicate values from the sorted list of field values.
Example
Installing docker
The code snippet provided demonstrates the installation process for Docker, a popular platform for containerization. It showcases a command written in the Bash scripting language that utilizes the curl
utility to download a script from the specified URL and execute it.
Let’s break down the code:
The command begins with curl -sSL
, where curl
is a command-line tool used for making HTTP requests. The -sSL
options passed to curl
instruct it to work silently (-s
) and follow redirects (-L
) while downloading the script.
The URL https://get.docker.com/
points to the Docker installation script. This script is responsible for setting up the necessary components and dependencies required for Docker to run on the system.
The pipe symbol (|
) is used to redirect the output of the curl
command to the next command in the pipeline. In this case, the output is passed to the bash
command.
The bash
command executes the downloaded script, which installs Docker on the system. The CHANNEL=stable
part is an environment variable assignment that sets the installation channel to “stable”. This ensures that the stable version of Docker is installed.
Allow Docker Commands Without Sudo
This procedure grants the current user privileges to run Docker commands without using sudo
.
-
sudo usermod -aG docker $USER
: Adds the current user to thedocker
group to enable the execution of Docker commands without the need forsudo
.-aG
: Appends (does not replace) the user to the supplementary groups mentioned by-G
. This option is used to make sure that the current user is added to the group without affecting their membership in other groups.docker
: Specifies the group name that the user is being added to, which is thedocker
group.$USER
: An environment variable that represents the current logged-in user. This user gets the permission to run Docker commands without usingsudo
.
Store git credentials
This command stores your git credentials in the git config file.
git config
: This command is used to configure Git. It can be used to set configuration variables that control the behavior of Git.--global
: This option tells Git to use the global configuration file. This file is located at~/.gitconfig
on Linux and macOS, and%USERPROFILE%\.gitconfig
on Windows.credential.helper store
: This command configures Git to use thestore
credential helper. The credential helper is a program that stores credentials for Git. Thestore
credential helper stores credentials in a plain-text file on disk, which is not secure. It is recommended to use a more secure credential helper, such as thecache
credential helper, which stores credentials in memory for a configurable amount of time.