Trace: bash

Linux:bash

Change file/folder permission (chown)

Using "number-mode"

print('hello world')

  • a = all
  • g = group
  • o = other
  • u = user (owner)
chmod {owner} - {group} - {other} filename 

Search for files and chown them

use “find . -type d …” for directorys): find . -type f -not \( -name “file1.txt” -o -name “file2.lol” -o -name “file3.\*” \) -print0 | xargs -0 chown [username]


Find files containing text

grep -rwl "search-string" /path/to/serch/dir

Working with external storage

Mount USB:

sudo fdisk -l
sudo mount -t vfat /dev/... 

Ejabberd

Delete chat

$ ejabberdctl remove_mam_for_user_with_peer maxmustermann your.address admin@somepi.ddns.net

Show free diskspace

$ sudo df -h

Working with .tar archives

Compress

$ tar -czvf name-of-archive.tar.gz /path/to/directory-or-file

Extract

$ tar -xzvf archive.tar.gz -C /path/to/extract

  • x extract
  • v verbos
  • f files
  • c compress
  • z use gzip compression
  • -C output path

MYSQL

Reset auto_incerement to 0

MYSQL > ALTER TABLE [YOUR_TABLE] auto_increment = 0;

IMPORT DUMP FILE

$ sudo mysql -u root -p [DATABASE] < [DUMP_FILE].sql

Show the path to database files

$ sudo mysql -u root -p -e "SELECT @@datadir;"

SHOW ALL USERS

MYSQL > SELECT User, Host, Password FROM mysql.user;