Blame

119753 joris 2026-03-21 18:32:53
eerste opzet
1
# Linux commands
2
ab916d joris 2026-03-21 19:02:11
editten
3
# User management
629498 joris 2026-03-21 22:20:17
edit
4
#### create a New Group
a8480c joris 2026-03-21 18:49:11
editing
5
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.
6
> sudo groupadd mynewgroup
119753 joris 2026-03-21 18:32:53
eerste opzet
7
629498 joris 2026-03-21 22:20:17
edit
8
#### add an existing user account to a group
ab916d joris 2026-03-21 19:02:11
editten
9
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 and example username with the name of the user you want to add.
a8480c joris 2026-03-21 18:49:11
editing
10
> sudo usermod -a -G examplegroup exampleusername
11
119753 joris 2026-03-21 18:32:53
eerste opzet
12
For example, to add the user geek to the group sudo , use the following command:
a8480c joris 2026-03-21 18:49:11
editing
13
> sudo usermod -a -G sudo geek
119753 joris 2026-03-21 18:32:53
eerste opzet
14
15
remove a user from a group
a8480c joris 2026-03-21 18:49:11
editing
16
> sudo gpasswd -d user group
119753 joris 2026-03-21 18:32:53
eerste opzet
17
18
Change user
ab916d joris 2026-03-21 19:02:11
editten
19
> su backups
119753 joris 2026-03-21 18:32:53
eerste opzet
20
ab916d joris 2026-03-21 19:02:11
editten
21
Voer een comando uit als een andere user
22
> sudo -u user commando
119753 joris 2026-03-21 18:32:53
eerste opzet
23
629498 joris 2026-03-21 22:20:17
edit
24
#### ownership
ab916d joris 2026-03-21 19:02:11
editten
25
(recursive in folder)
26
> sudo chown -R syncthing:syncthing Muziek/
119753 joris 2026-03-21 18:32:53
eerste opzet
27
629498 joris 2026-03-21 22:20:17
edit
28
#### change permissions CHMOD
9927ae joris 2026-03-21 22:17:33
editen
29
chmod ...
30
ab916d joris 2026-03-21 19:02:11
editten
31
Alle folders naar 770
32
> sudo find Muziek/ -type d -exec chmod 770 {} \;
33
Alle bestanden naar 660
34
> sudo find Muziek/ -type f -exec chmod 660 {} \;
119753 joris 2026-03-21 18:32:53
eerste opzet
35
36
recursief verwijderen (niet lege) directories
ab916d joris 2026-03-21 19:02:11
editten
37
>rm -R /path-to-dir
119753 joris 2026-03-21 18:32:53
eerste opzet
38
9927ae joris 2026-03-21 22:17:33
editen
39
##### copy
119753 joris 2026-03-21 18:32:53
eerste opzet
40
You can copy the content of a folder /source to another existing folder /dest with the command
41
cp -a /source/. /dest/
42
The -a option is an improved recursive option, that preserve all file attributes, and also preserve symlinks.
43
The . at end of the source path is a specific cp syntax that allow to copy all files and folders, included hidden ones.
44
9927ae joris 2026-03-21 22:17:33
editen
45
##### find
119753 joris 2026-03-21 18:32:53
eerste opzet
46
vinden bestand (recursief):
47
sudo find -iname “naam.bestand”
48
grootte directory
49
9927ae joris 2026-03-21 22:17:33
editen
50
##### disk use
119753 joris 2026-03-21 18:32:53
eerste opzet
51
du -hs /dir
52
sudo du -hc --max-depth=1
9927ae joris 2026-03-21 22:17:33
editen
53
54
##### mounten
119753 joris 2026-03-21 18:32:53
eerste opzet
55
usb stick mounten
56
sudo fdisk -l
57
58
sudo mkdir /mnt/usb-stick/
59
sudo mount /dev/sdb1 /mnt/usb-stick/
60
9927ae joris 2026-03-21 22:17:33
editen
61
##### formateren
119753 joris 2026-03-21 18:32:53
eerste opzet
62
formateren
63
sudo umount /dev/sdb1
64
sudo mkfs.ext4 /dev/sdb1
65
9927ae joris 2026-03-21 22:17:33
editen
66
#### rsync
119753 joris 2026-03-21 18:32:53
eerste opzet
67
backup met permissies:
68
sudo rsync -auvh --progress <sourceDir>/ <destDir>
69
sudo rsync -auh /mnt/usb-stick/ /home
70
Overzicht en gebruik partities
71
sudo df -h
72
Filesystem Size Used Avail Use% Mounted on
73
udev 3.9G 0 3.9G 0% /dev
74
tmpfs 786M 11M 776M 2% /run
75
/dev/sde2 9.9G 1.9G 7.5G 20% /
76
tmpfs 3.9G 4.0K 3.9G 1% /dev/shm
77
tmpfs 5.0M 0 5.0M 0% /run/lock
78
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
79
/dev/sde1 511M 3.3M 508M 1% /boot/efi
80
/dev/sde6 27G 9.3G 16G 38% /home
81
/dev/sde3 14G 6.0G 6.5G 49% /var
82
/dev/sde5 682M 1.5M 631M 1% /tmp
83
/dev/sdb1 688G 356G 298G 55% /mnt/e03b13e7-2b23-4bad-8aed-d42606a60487
84
/dev/sda1 1.8T 743G 1.1T 41% /mnt/9f553b41-1144-4d23-9cef-f0722fc76bde
85
/dev/sdc1 2.7T 1.4T 1.2T 55% /mnt/a8966e82-2455-4fc5-bf9a-4cfcaa44277d
86
/dev/sdd1 688G 183G 506G 27% /mnt/b8827aaf-3ead-4856-a73b-2d0e4e9f7e47
87
Overzicht grootte directories
88
sudo du -sh *
89
137M allusers
90
8.8G backups
91
161M joris
92
16K lost+found
93
203M syncthing
94
Computer info
95
hostnamectl
96
Static hostname: rpi4
97
Icon name: computer
98
Machine ID: ce513f1a44ff4c9dbd382eb66e08c51e
99
Boot ID: 2f7cbe4f653c4865989fd402b50861dc
100
Operating System: Raspbian GNU/Linux 11 (bullseye)
101
Kernel: Linux 5.15.32-v7l+
102
Architecture: arm
103
104
Ssh key less login
105
@zon
106
ssh-keygen
107
@thrush
108
(id_rsa.pub plakken in authorized keys)
109
sudo nano /etc/ssh/sshd_config
110
line 57: PasswordAuthentication yes
111
sudo service ssh restart
112
@zon
113
ssh-copy-id -p 22226 joris@thrush.minded.net
114
@thrush
115
sudo nano /etc/ssh/sshd_config
116
line 57: PasswordAuthentication no
117
sudo service ssh restart
118
@zon
119
ssh joris@thrush.minded.net -p 22226
120
How to find out top Directories and files in Linux
121
Type the following command at the shell prompt to find out top 10 largest file/directories:
122
# du -a /var | sort -n -r | head -n 10
123
124
125
Nano commands
126
Delete line Ctrl + k
127
128
Journalctl
129
• Logs van de huidige boot: journalctl -b.
130
• Filteren op service: journalctl -u nginx.service
131
• Filteren op tijd: journalctl --since "1 hour ago" of journalctl --since yesterday.
132
• Prioriteit (fouten): journalctl -p err (toon alleen meldingen met prioriteit 'error' of hoger).
133
• Kernellogs: journalctl -k.
134
135
cron -N
136
Running 'cron -N' triggers a cron tick, causing all job definitions
137
to be processed immediately, and then exits. This is useful for
138
testing changes in crontabs.