Skip to content

Linux Basic Guides

Setup sudo

  • Switch to root

    Terminal window
    su -
  • Install sudo

    Terminal window
    apt install sudo
  • Add your user to the sudo group

    Terminal window
    usermod -aG sudo <username>

Mount External USB Drive

  • Get your external USB drive information UUID

    Terminal window
    lsblk -f
  • Add your external drive to /etc/fstab to mount it on boot

    Terminal window
    nano /etc/fstab

    Then add your drive like so:
    UUID=<UUID> <mount path> auto uid=1000,gid=1000,nosuid,nodev,nofail 0 0

  • Reboot

Setup Samba

  • Install samba

    Terminal window
    apt install samba
  • Open /etc/samba/smb.conf

    Terminal window
    sudo nano /etc/samba/smb.conf
  • Add a Share Definition then save and exit

    smb.conf
    [shareName]
    comment = hello
    path = /media/samba/share
    browseable = yes
    writable = yes
    guest ok = yes
    read only = no
    users = <user>, <user>
  • Add a Samba user

    Terminal window
    smbpasswd -a <username>
  • Restart samba

    Terminal window
    sudo service smbd restart
  • Access the Share at //<your ip>/shareName

Create a systemd service

  • Create a systemd service

    Terminal window
    nano /etc/systemd/system/<serviceName>.service
  • Edit the service with your desired settings

    <seriveName>.service
    [Unit]
    Description=<description>
    [Service]
    ExecStart=<path to executable>
    WorkingDirectory=<working directory path>
    Restart=always
    RestartSec=50s
    User=<username>
    After=<service name>
    Requires=<service name>
  • Reload daemon

    Terminal window
    sudo systemctl daemon-reload
  • Enable and start the service

    Terminal window
    sudo systemctl enable <serviceName>
    sudo systemctl start <serviceName>
  • Check service status

    Terminal window
    sudo systemctl status <serviceName>
  • Stop the service

    Terminal window
    sudo systemctl stop <serviceName>
  • List all services

    Terminal window
    systemctl list-unit-files --type=service

Auto screen off

  • Open the GRUB configuration file

    Terminal window
    sudo nano /etc/default/grub
  • Edit the line that starts with GRUB_CMDLINE_LINUX_DEFAULT and add consoleblank=<seconds>

    grub
    GRUB_CMDLINE_LINUX_DEFAULT="quiet consoleblank=60"
  • Update GRUB

    Terminal window
    sudo update-grub
  • Reboot

Download and Install a Debian package

  • Download the package

    Terminal window
    wget <url>
  • Install the package

    Terminal window
    sudo dpkg -i <filename>
  • Remove the file you downloaded

    Terminal window
    rm <filename>