Find file & directory, change permissions
find ./ -name 'crontab' # search for a filename in given dir find ./app/ -name '*.css'
# search for a directory find / -type d -name 'httpdocs'
#search and replace in files and subdirectory find ./ -type f -exec sed -i 's/yourDoamin.com/g' {} +
# change permissions for files and directories find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \;
Recursively Search All Files For A String using 'grep' and 'find'
# grep
#
grep -Ril "text-to-find-here" /
# i stands for ignore case (optional in your case).
# R stands for recursive following symlinks too.
# r stands for recursive.
# l stands for "show the file name, not the result itself".
# / stands for starting at the root of your machine.
#
#
# You can also specify directory name:
grep -r -l "foo" /path/to/dir/*.c
#
## Using find command to search recursively
# -type f - stands for files
# -type d - stands for directories
#
cd /path/to/dir
find . -type f -exec grep -l "word" {} +
find . -type f -exec grep -l "seting" {} +
find . -type f -exec grep -l "foo" {} +
find /search/dir/ -type f -name "*.c" -print0 | xargs -I {} -0 grep "foo" "{}"
#
## Search /etc/ directory for 'nameserver' word in all *.conf files ##
find /etc/ -type f -name "*.conf" -print0 | xargs -I {} -0 grep "nameserver" "{}"
#
## Older UNIX version should use xargs to speed up things:
find /path/to/dir -type f | xargs grep -l "foo"
#
## OR use the following OSX/BSD/find or GNU/find example:
find /path/to/dir/ -type f -name "file-pattern" -print0 | xargs -I {} -0 grep -l "search-term" "{}"
## OR ##
find /mycool/project/ -type f -name "*.py" -print0 | xargs -I {} -0 grep -H --color "methodNameHere" "{}"
## OR search all files in /etc/ dir for 'nameserver' word ##
find /etc/ -iname "*" -type f -print0 | xargs -0 grep -H "nameserver"
File permissions for TYPO3 & sticky bit
# directories
find ./typo3-12-dev-rsp -type d -exec chmod 2775 {} \;
# files
find ./typo3-12-dev-rsp -type f -exec chmod 0664 {} \;
TYPO3 www-data default group on raspberry pi4 environment & Debian 12 / Apache2
New files, created by user or typo3 will belong to the group ‘ www-data’. Take in advance, where ( folder ) the sticky bit ( e.g. chmod 2775 ) was fired.
# Add www-data group to webserver user as default-group
groupmod -a -U myuser www-data
# change permissions and group to typo3 folder
chown -R myuser:www-data ./*
Create the docker group
sudo groupadd docker
#Add your user to the docker group.
sudo usermod -aG docker $USER
wget & FTP
wget -r ‘ftp://username:password@ip/directoryname’
Directories & sizes
du -sh */ .*/ | sort -n
SAMBA Commands and Configuration
# Adding an existing user to the Samba database is a matter of running the
smbpasswd -a user
# command; this command asks for the password interactively.
A user can be deleted with # command; this command asks for the password interactively. # A user can be deleted with smbpasswd -x user # command. A Samba account can also be temporarily disabled (with smbpasswd -d user) and re-enabled later (with smbpasswd -e user). # ------ The profiles directory should be in
/home/samba/profiles ------- Start, Restart, Stop options systemctl restart smbd You can also do this way: Start sudo /etc/init.d/smbd start
Stop sudo /etc/init.d/smbd stop
Restart sudo /etc/init.d/smbd restart
######################### NEUE DOKU FÜR EINRICHTUNG BENUTZER AUTHENTIFIZIERUNG ###########
Benutzereingeschränkte Konfiguration
Dieses Konfigurationsbeispiel zeigt nun, wie Sie eine SMB-Freigabe mit Authentifizierung vornehmen. Dafür wird ein Benutzer smbuser am Debian System angelegt und in der Konfigurationsdatei smb.conf ein Share-Eintrag restricted ergänzt.
SMB-User anlegen, weitergehende Informationen dazu zeigt der Wikiartikel Samba-Server Security im Abschnitt Benutzerzugriff.
$ sudo useradd -s /bin/false smbuser
Passwort setzen
$ sudo smbpasswd -a smbuser
Eintrag in der Datei smb.conf:
[global]
workgroup = smb
security = user
map to guest = never
[homes]
comment = Home Directories
browsable = no
read only = no
create mode = 0750
[restricted]
valid users = smbuser
#Wir beschränken den Zugriff auf den User ''smbuser''
#valid users = @smbusers
#Alternativ kann auch auf eine Benutzergruppe eingeschränkt werden
path = /media/storage2/
public = no
writable = yes
comment = smb restricted share
printable = no
guest ok = no
create mask = 0600
directory mask = 0700
Diese Konfiguration verwendet den Beispiel-Mountpoint /media/storage2. Um den Zugriff auf die Freigabe möglichst stark einzuschränken, wird dieser Mountpoint /media/storage2 dem Benutzer smbuser zugeordnet und mit den Verzeichnisrechten 700 versehen, damit nur dieser Benutzer (und natürlich root) Lese- und Schreibzugriff erhalten.
$sudo chown -R smbuser:smbuser /media/storage2
$sudo chmod 700 /media/storage2
Neustart von Samba
Damit die Konfiguration übernommen wird, müssen Sie den Samba Dienst neustarten. Dies erfolgt unter Debian 8 mit systemd.
$ sudo systemctl restart smbd.service
################################################### IP DES SAMBA SERVERS #######
Windows- und Samba-Maschinen finden Sie auf der Konsole mit den Befehlen
-> smbtree
und
-> findsmb
shows :
+=LMB
IP ADDR NETBIOS NAME WORKGROUP/OS/VERSION
---------------------------------------------------------------------
192.168.178.25 DEN-BE-23 +[ SMB ]
Mounting samba from debian to debian
mount -t cifs -o username=den_raspi,password='your-password',uid=1000,gid=1000 //192.168.178.26/ssdhome /home/user/ssd_mount240
Change CLI php version
alias php=/opt/plesk/php/7.0/bin/php