Autor: Stefan

  • Ubuntu Timezone einstellen

    Abfrage der aktuellen Timezone / Zeitzone:

    timedatectl status

    Auflisten der bekannten Timezones:

    timedatectl list-timezones
    

    Setzen der neuen Timezone:

    sudo timedatectl set-timezone Europe/Berlin

  • Umbenennen einer Ubuntu-Maschine

    Ändere den Hostnamen: Um den Hostnamen deines Ubuntu-Servers zu ändern, verwende den Befehl hostnamectl. Ersetze neuer-hostname durch den gewünschten Hostnamen

    sudo hostnamectl set-hostname neuer-hostname

    Bearbeite die Hosts-Datei: Als nächstes musst du die Datei /etc/hosts bearbeiten, um den neuen Hostnamen widerzuspiegeln. Verwende einen Texteditor wie nano oder vim, um die Datei zu öffnen:

    sudo nano /etc/hosts 

    Innerhalb der Datei siehst du eine Zeile wie:

    127.0.1.1 alter-hostname 

    Ersetze alter-hostname durch deinen neuen Hostnamen:

    127.0.1.1 neuer-hostname

    Speichere die Datei und verlasse den Texteditor.

    Bearbeite die Netzwerkkonfigurationsdatei: Öffne die Netzwerkkonfigurationsdatei mit einem Texteditor:

    sudo nano /etc/netplan/01-netcfg.yaml 

    In dieser Datei siehst du einen Abschnitt mit ethernets und version. Aktualisiere das Feld hostname mit deinem neuen Hostnamen:

    network:
    version: 2
    ethernets:
    eth0:
    dhcp4: true
    hostname: neuer-hostname

    Speichere die Datei und verlasse sie.

    Änderungen anwenden: Wende die Änderungen an der Netzwerkkonfiguration mit netplan an:

    sudo netplan apply

    Neustart: Um sicherzustellen, dass alle Änderungen wirksam werden, starte den Server neu:

    sudo reboot

    Nach dem Neustart sollte der Server den von dir angegebenen neuen Hostnamen haben. Vergiss nicht, ggf. DNS-Einträge zu aktualisieren, um den neuen Hostnamen für den externen Zugriff oder für Netzwerkdienste, die davon abhängen, widerzuspiegeln.


  • Login-Seiten für MS-Identity

    aspnet-codegenerator installieren:

    dotnet tool install -g dotnet-aspnet-codegenerator --version 6.0.0

    dotnet aspnet-codegenerator identity -dc ApplicationDbContext
    oder wenn vorhanden:
    dotnet aspnet-codegenerator identity -dc ApplicationDbContext --force
    dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
    dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design --version 6.0.0
    dotnet aspnet-codegenerator identity -dc MyBlazorApp.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout"
    
    
    Quelle:
    https://learn.microsoft.com/de-de/aspnet/core/fundamentals/tools/dotnet-aspnet-codegenerator?view=aspnetcore-8.0
    
    
    
    
    

  • IP-Adresse vor dem Login anzeigen lassen (Ubuntu)

    Manchmal kann es praktisch sein, sich vor dem Login die IP-Adresse der Linux-Maschine anzeigen zu lassen, um sich z.B. direkt per ssh zu ihr verbinden und nicht erst umständlich einloggen, ifconfig etc. auszuführen.

    Achtung: Dieses ist bei VMs sehr praktisch, die via DHCP immer eine andere IP-Adresse haben, sollte aber bei echten Servern nicht implementiert werden, da so einem Hacker bereits Informationen geliefert werden.

    (mehr …)

  • Ubuntu – Festplattenfresser feststellen

    NCDU

    To investigate why the disk space on your Ubuntu server decreased significantly at a specific time, you can follow these steps:

    1. Check System Logs: System logs can provide insights into what processes were running at that time. Look into logs like /var/log/syslog, /var/log/auth.log, and other relevant logs in /var/log/ directory. Use commands like grep or awk to filter logs around the specific time.
       grep 'Nov 20 11:' /var/log/syslog
    1. Analyze Cron Jobs: Check if any cron jobs were scheduled to run at that time which might have created or downloaded large files. You can view cron jobs with:
       crontab -l

    And also check system-wide cron jobs in /etc/crontab and the /etc/cron.* directories.

    1. Review User Activity: If you have multiple users, check their activity around that time. Look into their bash history if possible:
       cat /home/username/.bash_history
    1. Disk Usage Tools: Use tools like du and ncdu to analyze which directories grew in size. For instance, you can see the size of directories in /var or /home:
       du -h --max-depth=1 /var
    1. Check for Large Files: Find recently modified large files using find:
       find / -type f -size +100M -mtime -2

    This command finds files larger than 100MB modified in the last 2 days.

    1. Database Logs: If you have databases running, check their logs as well. They might have performed large operations or backups.
    2. Network Activity Logs: If the server downloads data from the internet, check logs of applications like wget, curl, or any other custom scripts that might have downloaded large amounts of data.
    3. System Updates: Sometimes system updates or automatic software installations can consume disk space. Check /var/log/apt/history.log for any recent installations or upgrades.
    4. Backup and Snapshot Systems: If you have any backup systems or snapshot tools (like Timeshift), they might have created backups or snapshots at that time.
    5. External Monitoring Tools: If you have any monitoring tools installed, like nagios, zabbix, or a custom monitoring solution, check their logs and reports.

    Investigating disk space issues often requires correlating data from multiple sources. If you find a specific large file or a process that consumed the space, you can then delve deeper into why it happened and how to prevent it in the future.


  • Serien und Videos

    Bewertung nach Schulnoten

    Bis zum 04.11.2023 Netflix Note 3
    Der Untergang des Hauses Usher

    05.11.2023 Netflix Note 1
    Alles Licht, was man nicht sehen kann

    05.11.2023 Netflix Note 3
    Locked in

    Bis 06.11.2023 Prime Note 2
    Last Exit Schinkenstraße

    06.11.2023 Prime Note 6, abgebrochen
    Shotgun Wedding

    06.11. – Prime Note 1
    Night Sky

    bis 22.11.2023 Disney+, Note 5
    The Changeling


  • EntityFramework.Core in eine .net Core Blazor WebApp integrieren

    1. Install necessary packages:

    For a Blazor Server App, you’d typically manage the EF Core functionality in the Server project. So, make sure you are working in the Server project directory or set the Server project as the default project in the Package Manager Console (PMC) in Visual Studio.

    Using the NuGet Package Manager or the PMC, install the following packages:

    • Microsoft.EntityFrameworkCore
    • Microsoft.EntityFrameworkCore.SqlServer
    • Microsoft.EntityFrameworkCore.Tools (for migration tools)

    2. Define your Model:

    Create classes that will define the structure of your database tables. Place these in the Shared or Server project, depending on your design decisions.

    Example:

    public class Product
    {
        public int ProductId { get; set; }
        public string Name { get; set; }
        public decimal Price { get; set; }
    }
    

    3. Create a DbContext:

    In the Server project, create a class that derives from DbContext:

    public class AppDbContext : DbContext
    {
        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
    
        public DbSet<Product> Products { get; set; }
    }
    

    4. Configure the Connection String:

    In the appsettings.json file in the Server project, add your connection string:

    {
      "ConnectionStrings": {
        "DefaultConnection": "Server=Servername;Database=DatabaseName;user=UserId;password=secret;MultipleActiveResultSets=true;TrustServerCertificate=True;MultiSubnetFailover=True"
      }
    }
    

    Replace YourConnectionStringHere with your MS SQL Server 2022 connection string.

    5. Register DbContext:

    In the Startup.cs (or Program.cs for newer versions) of your Server project, register the DbContext in the ConfigureServices method:

    builder.Services.AddDbContext<AppDbContext>(options =>
    options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));

    (Do not forget to import EF Core)

    6. Create Initial Migration:

    In the PMC or terminal, navigate to the Server project directory and run:

    Add-Migration InitialCreate
    

    This will scaffold a migration to create the initial set of tables for your model.

    7. Update the Database:

    Apply the migration to create the database schema:

    Update-Database
    
    
    

    8. Use the DbContext in your app:

    Now you can inject and use your DbContext in your pages, components, or services:

    csharpCopy code@inject AppDbContext _context
    
    // ...
    
    var products = await _context.Products.ToListAsync();
    

    That’s the basic setup! As your app grows, you might add more entities, relationships, migrations, and other advanced EF Core features. Ensure you understand concepts like the lifecycle of a DbContext and how it tracks changes to entities to avoid issues when manipulating data.


  • HDD an Fritz!Box als TimeMachine Target

    QUELLE: https://www.tutonaut.de/anleitung-time-machine-mit-fritzbox-nutzen/


  • update npm on MacOS

    Using NPM:

    To update Node using NPM, do the following:

    1. Open the Terminal and check your current Node version:  
      node -v 
    2. Install n package using the following command:
      npm install -g n   
      This command will install a tool called „n“ which you can use to update Node easily.
    3. To update Node, run the following command in your terminal:           
      n latest
      This command will install the latest version of Node on your system.
    4. Now you can verify that your update is complete by rechecking your Node version:  
      node -v

    You can also manually download and install the latest Node version from the official website.


  • rsa private / publik key erstellen

    To generate a private key and public key pair for SSH access on Ubuntu, you can use the OpenSSH utility called ssh-keygen. Here’s a step-by-step guide:

    1. Open a terminal on your Ubuntu machine.
    2. Run the following command to generate the key pair:
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

    Replace "your_email@example.com" with your own email address or any identifier you prefer.

    1. You will be prompted to specify the file location to save the key pair. Press Enter to accept the default location (/home/your_username/.ssh/id_rsa) or provide a different path.
    2. You will then be prompted to enter a passphrase. A passphrase adds an extra layer of security to your private key, but it’s optional. You can press Enter to leave it empty, but it’s generally recommended to use a passphrase for added security. If you choose to use a passphrase, make sure to remember it, as you will need it whenever you use the private key.
    3. After generating the keys, you will see output similar to:
    Your identification has been saved in /home/your_username/.ssh/id_rsa.
    Your public key has been saved in /home/your_username/.ssh/id_rsa.pub.
    1. The private key is stored in the file id_rsa, and the public key is stored in id_rsa.pub. These are the files you’ll need for SSH access.
    2. You can now copy the public key (id_rsa.pub) to the remote SSH server. You can use the ssh-copy-id command to automate this process. Run the following command, replacing username and server_address with the appropriate values:
    ssh-copy-id -i ~/.ssh/id_rsa.pub username@server_address

    This command will prompt you for the password of the remote user account.

    1. Once the public key is copied to the remote server, you should be able to authenticate using your private key without entering a password.

    That’s it! You have successfully generated a private key and public key pair and copied the public key to the remote SSH server.


Wir benutzen Cookies um die Nutzerfreundlichkeit der Webseite zu verbessen. Durch Deinen Besuch stimmst Du dem zu.