Linux commands

Add a New Group If you want to create a new group on your system, use the groupadd command following command, replacing new_group with the name of the group you want to create. You’ll need to use sudo with this command as well (or, on Linux distributions that don’t use sudo, you’ll need to run the su command on its own to gain elevated permissions before running the command). sudo groupadd mynewgroup

Add an Existing User Account to a Group To add an existing user account to a group on your system, use the usermod command, replacing examplegroup with the name of the group you want to add the user to andexampleusername with the name of the user you want to add. sudo usermod -a -G examplegroup exampleusername For example, to add the user geek to the group sudo , use the following command: sudo usermod -a -G sudo geek

remove a user from a group

sudo gpasswd -d user group

Change user su backups

CHOWN

sudo chown -R syncthing:syncthing Muziek/

sudo chmod

CHMOD find /path/to/directory -type d -exec chmod 770 {} ; find /path/to/directory -type f -exec chmod 660 {} ; ====================== sudo find Muziek/ -type d -exec chmod 770 {} ; sudo find Muziek/ -type f -exec chmod 660 {} ;

recursief verwijderen (niet lege) directories

rm -R /path-to-dir

You can copy the content of a folder /source to another existing folder /dest with the command cp -a /source/. /dest/ The -a option is an improved recursive option, that preserve all file attributes, and also preserve symlinks. The . at end of the source path is a specific cp syntax that allow to copy all files and folders, included hidden ones.

vinden bestand (recursief): sudo find -iname “naam.bestand” grootte directory

du -hs /dir sudo du -hc --max-depth=1 usb stick mounten sudo fdisk -l

sudo mkdir /mnt/usb-stick/ sudo mount /dev/sdb1 /mnt/usb-stick/

formateren sudo umount /dev/sdb1 sudo mkfs.ext4 /dev/sdb1

backup met permissies: sudo rsync -auvh --progress <sourceDir>/ <destDir> sudo rsync -auh /mnt/usb-stick/ /home Overzicht en gebruik partities sudo df -h Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% /dev tmpfs 786M 11M 776M 2% /run /dev/sde2 9.9G 1.9G 7.5G 20% / tmpfs 3.9G 4.0K 3.9G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sde1 511M 3.3M 508M 1% /boot/efi /dev/sde6 27G 9.3G 16G 38% /home /dev/sde3 14G 6.0G 6.5G 49% /var /dev/sde5 682M 1.5M 631M 1% /tmp /dev/sdb1 688G 356G 298G 55% /mnt/e03b13e7-2b23-4bad-8aed-d42606a60487 /dev/sda1 1.8T 743G 1.1T 41% /mnt/9f553b41-1144-4d23-9cef-f0722fc76bde /dev/sdc1 2.7T 1.4T 1.2T 55% /mnt/a8966e82-2455-4fc5-bf9a-4cfcaa44277d /dev/sdd1 688G 183G 506G 27% /mnt/b8827aaf-3ead-4856-a73b-2d0e4e9f7e47 Overzicht grootte directories sudo du -sh * 137M allusers 8.8G backups 161M joris 16K lost+found 203M syncthing Computer info hostnamectl Static hostname: rpi4 Icon name: computer Machine ID: ce513f1a44ff4c9dbd382eb66e08c51e Boot ID: 2f7cbe4f653c4865989fd402b50861dc Operating System: Raspbian GNU/Linux 11 (bullseye) Kernel: Linux 5.15.32-v7l+ Architecture: arm

Ssh key less login @zon ssh-keygen @thrush (id_rsa.pub plakken in authorized keys) sudo nano /etc/ssh/sshd_config line 57: PasswordAuthentication yes sudo service ssh restart @zon ssh-copy-id -p 22226 joris@thrush.minded.net @thrush sudo nano /etc/ssh/sshd_config line 57: PasswordAuthentication no sudo service ssh restart @zon ssh joris@thrush.minded.net -p 22226 How to find out top Directories and files in Linux Type the following command at the shell prompt to find out top 10 largest file/directories:

du -a /var | sort -n -r | head -n 10

Nano commands Delete line Ctrl + k

Journalctl • Logs van de huidige boot: journalctl -b. • Filteren op service: journalctl -u nginx.service • Filteren op tijd: journalctl --since "1 hour ago" of journalctl --since yesterday. • Prioriteit (fouten): journalctl -p err (toon alleen meldingen met prioriteit 'error' of hoger). • Kernellogs: journalctl -k.

cron -N Running 'cron -N' triggers a cron tick, causing all job definitions to be processed immediately, and then exits. This is useful for testing changes in crontabs.

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9