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