Skip to main content

Cronjob, tar, autostart, sudo, grep, ln

cronjob

  • execute all listed cronjobs: crontab -l | grep -v '^#' | cut -f 6- -d ' ' | while read CMD; do eval $CMD; done
  • send mail address https://de.godaddy.com/blog/behalten-sie-ihre-cron-jobs-unter-kontrolle/

tar

useage: tar [OPTION...] [FILE]...

  • options:

    • -c Ein neues Archiv erzeugen.
    • -d Dateien im Archiv und im Dateisystem miteinander vergleichen.
  • create archive:

    • unzipped
      • tar -czf archiv.tar.gz file Create archiv.tar.gz
    • zipped
      • tar -cf archiv.tar path/ Create archiv.tar with all subdir
      • tar -cf archiv.tar datei_1.txt *.pdf Create archiv.tar with 1 file and all pdfs
  • tar

    anhängen

    -cf archiv.tar path/
     Create archiv.tar with all subdir
    • tar -rf archiv.tar datei_1.txt Add 1 specific file to archiv (unconpressed)
  • zipped
    • tar -czf archiv.tar.gz file Create archiv.tar.gz

extract archive: ACHTUNG - tar überschreibt existierende automatisch

  • tar -xf archiv.tar Extract files
  • tar -xzf archiv.tar.gz -C / Extract gzip archives
  • tar -xzf archiv.tar.gz -C /path Extract gzip archives to /path
  • anzeigen tar -tvf archiv.tar Show which files are in archiv.tar

  • autostart

    • create new file
      • user only sudo nano ~/.config/autostart/<some_name>.desktop
      • global sudo nano /etc/xdg/autostart/<some_name>.desktop
    • insert content like:
      [Desktop Entry]
      Type=Application
      Name=Musterprogramm
      Exec=Auszuführendes Kommando
      

    sudo

    add user to sudo

    su -
    usermod -aG sudo <username>
    

    no password sudo

    • edit sudoers file with sudo visudo
    • add line at end of file (important for not be overriten):
      username  ALL=(ALL) NOPASSWD:ALL
      

    grep

    • arguments:

      • -i, --ignore-case Ignore case distinctions in both the PATTERN and the input files.
    • use cases:

    • ln -s /Pfad/zur/Datei /Pfad/zum/symlink
      • -s (symbolic) erstellt einen symbolischen Link statt eines Hardlinks.
      • -f (force) aktualisiert den Link und entfernt existierende Ziele.
      • -i (interactive) fragt nach, bevor Ziele entfernt werden (setzt -s voraus).
      • -r (relative) erstellt symbolische Links relativ zum Link-Speicherort.