⬅️ **[[§-Technik|Technik]]**
***
# Linux
## Basics
- **Upgrade SW Packages**
- `sudo apt-get update`
- `sudo apt-get --auto-remove full-upgrade` (Upgrade packages also with new dependencies and removes packages to resolve conflicts)
- `sudo apt-get clean` (clean not package cache)
- **Standard SW:**
- `sudo apt-get install vim rsync curl tree git ncdu htop iotop ethstatus samba samba-common-bin net-tools`
- **ncdu** - Dateigröße in Verzeichnis und Unterverzeichnis etc
- `sudo snap install btop`
- [Byobu](https://www.byobu.org/)
- **Change Keyboard Layout**:
- `sudo dpkg-reconfigure keyboard-configuration`
- **German - No Dead Keys Layout**
- reboot afterwards
- **Change Lokalization:** `update-locale LANG=de_DE.UTF-8`
- **Change Timezone**
- `ls -l /etc/localtime`
- `cat /etc/timezone`
- `timedatectl list-timezones`
- Change to **Europe/Berlin** `sudo timedatectl set-timezone Europe/Berlin`
- [[Ubuntu]]
- [[User Anlegen]]
- [[Linux cp & rsync]]
- [[Linux-Network]]
- [[Linux Cronjobs mit Crontab]]
- [🦅 - Udemy - Linux Security and Hardening](eagle://folder/KR87GN6RHUA94)
- [[Sudo Lecture]] für eine schöne Nachricht bei Verwendung von `sudo`
- [[Linux - Festplatten konfigurieren]]
## Specifics
- [[Proxy einrichten]]
- [[Linux Services - service systemd systemctl]]
- Netzwerk
- [[Linux - Network - Netplan]]
- [[WLAN per Linux Console]]
- [[Clone SSD HDD Festplatte]]
- [[Mit DD bootable USB Stick von iso]]
- [[Swap Size erhöhen]]
## Default Configs
- `/etc/hosts` mit Hosts und IPs füllen
- `~/.ssh/config` anpassen
- `ssh-copy-id` SSH key verwenden
- `~/.bash_profile` alias für ls -al -> ll erzeugen
- Hostname:
- **Change Hostname** `hostnamectl set-hostname home-pi`
- `/etc/hostname`
## FAC
- install all Updates and Upgrades
`sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get -f install`
- Check Graphics Card `lspci | grep VGA`
| Command | Tipps |
|:--------------------------------------------------------------- |:---------------------------------------------------------------------------------------------------------------------------------------------------- |
| date | [Date Examples + Format](https://www.thegeekstuff.com/2013/05/date-command-examples/) |
| tree | Tree View of current folder |
| [locate](https://wiki.ubuntuusers.de/locate/) | DB über alle Verzeichnisse -> Index -> dadurch schnelle Suche von Dateien |
| tar -czf abc.tar /Path/to/files | Create .tar Archive AND Compressed |
| tar -xf abc.tar | Extracts .tar Archive |
| `sudo` without password | Add in `/etc/sudoers` e.g. `tobi ALL=(ALL) NOPASSWD:ALL`. |
| Autostart with `/etc/rc.local` and start script as specifc user | Inser `su minecraft -c '/home/minecraft/Minecraft/scripts/startServer.sh'` Source: [Execute script from rc.local as user instead of root][rc.local] |
| | |
## Linux Dateisystem
| Folder | Bedeutung |
|:------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| / | = Wurzelverzeichnis ("root"; Vergleichbar mit c: unter Windows) |
| /bin | = In diesem Ordner befinden sich alle ausführbaren Systemdateien. |
| /boot | = Hier befinden sich alle Dateien die zum Booten des Systems benötigt werden ( Kernel und Bootmanager) |
| /dev | = Unter Linux werden alle Geräte über Dateien angesprochen, welche im /dev liegen. |
| /etc | = Beinhaltet die Konfigurationsdateien für Systemprogramme. |
| /home | = In diesem Verzeichnis werden alle Benutzer und ihre Daten gespeichert (vergleichbar mit "Dokumente und Einstellungen" / "Users" bei Windows XP / Windows Vista), Ausnahme: root Verzeichnis |
| /root | = /root ist das Verzeichnis des Users "root" und befindet sich, anders als bei anderen Benutzern, nicht im /home Verzeichnis. Nicht zu verwechseln mit dem root-Verzeichnis . |
| /lib | = Systembibliotheken sind hierin enthalten. |
| /lost+found | = Beinhaltet, nach z.B. einem Absturz, wiederhergestellte Dateien. Diese kann der "root" mit "file" wiederherstellen. (Funktioniert nur unter ext3). |
| /media | = Media enthält Unterverzeichnisse für Laufwerke wie CD/DVD-Rom und Floppy (abhängig von der Distribution). |
| /mnt | = Wird meist für temporäres Mounten von Dateisystemen benutzt. |
| /opt | = Enthält optionale Software-Pakete. |
| /proc | = Beinhaltet Informationen über laufende Prozesse. |
| /sbin | = Hier befinden sich vom System benötigte ausführbare Dateien (Sind oftmals nur als root ausführbar). |
| /srv | = Daten von verschiedenen Diensten (z.B. vom Webserver oder FTP-Server) sind in diesem Verzeichnis abgelegt. |
| /tmp | = In diesem Ordner befinden sich temporäre Dateien, die während des Betriebs entstehen. |
| /usr | = Verzeichnis für Anwendungen mit dazugehörigen Bibliotheken. |
| /var | = In /var werden Dateien, die im Betrieb entstehen, gespeichert. Diese werden für den nächsten Ablauf aufbewahrt (beinhaltet meistens viele Log-Dateien). |
| | |
## Main Functions
### Run scripts with another user
> Source: https://serverfault.com/questions/422950/execute-script-from-rc-local-as-user-instead-of-root
Running `sudo su user01` in a script does not mean the following commands are sent to the resultant shell. In fact, it likely means a new shell is spawned as user01, which never exits!
Two things:
- You can execute a command as another user either by passing the `-c 'command...'` argument to su, like `su user01 -c '/etc/init.d/script start'`.
- Starting a service that uses /etc/init.d from rc.local isn't the correct thing to do. You want to use enable the service at startup using your distribution tools, like `chkconfig` or `update-rc.d`. You also don't want jobs in /etc/init.d that shouldn't be started as `root`. The jobs themselves can feel free to fork to another user account, but should be invoked by root.
### Monitoring
- top - Prozesse (Basic)
- htop - Prozesse (Advanced + Nice)
- iotop - (IO Monitor)
- [ethstatus](https://wiki.ubuntuusers.de/Netzwerk-Monitoring/#EthStatus) - Eth Speed
- [btop](https://github.com/aristocratos/btop) anstelle von [Debrecated - Bashtop](https://www.tecmint.com/bashtop-linux-resource-monitoring-tool/) vom gleichen Entwickler `sudo snap install btop`
### ZIP archive
```
ZIP zip myfile.zip filename.txt
recursifly zip –r filename.zip directory_name
exclude from dir zip –x filename.zip file_to_be_excluded
unzip unzip myfile.zip
delete file zip –d filename.zip file.txt
update/add file zip –u filename.zip file.txt
verbose zip –v filename.zip file1.txt
```
### WebDAV
[WebDAV](http://wiki.ubuntuusers.de/WebDAV)
### ufw (Uncomplicated Firewall)
- Port eines Services mit netcat herausfinden
- `netstat -tulpn | egrep "samba|smbd|nmbd|winbind"`
## Linux Tools
- Quelle: [Leyrer: Moderne Linux Kommandozeilenwerkzeuge - Edition "Allein zu Haus"](https://www.youtube.com/watch?v=uEEHq6f8RsM&t=698s&pp=ygUUbHlyZXIga29tbWFuZG96ZWlsZW4%3D)
- [[UNIX Philosophy]]
### 2022
- XSV
- - wjq" for CSV files
- index, slice, analyze, split and join CVS files
- gron
- ic
- fx
- bat
- ccat
- delta
- diff-so-fancy
- Syff
- skim
- choose
- sd
- map
- xonsh
- crush
- xxh
- starship
- Oh My Posh
- a
- gping
- ioping
- broot
- ncdu
- duf
- dust
- dutree
- Isd
- goto
- mcfly
- hyperfine
- procs
- bottom
- btop++
- musikcube
- googler
- viu
- hexyl
- glow
- falsisian
- fuck
- oh-heck
- usbkill
### 2019
hub
tig
lynis
top Familie
nethogs
socket
statistics
dstat
saidar
nmon
kubtail
colorex lolcat gulasch
HTTP Prompt
XMLStarlet
Ultimate
Plumber
reptyr
ttyd
WTF
### 2018
dig
tracepath
mtr
oping
iproute2
tmux
zsh
ranger
HTTPie
aria2c
ja
icdiff
colordiff
ripgrep
fd
Z
exa fzf
pv
progress
##
***
Related:
- [[$-Software|Software]]