Skip to content

kintsugi-programmer/beWarehouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

beWarehouse : Debian Daily Operations Cheat Sheet

Table of Contents

System Information

  • Check Debian Version:

    lsb_release -a
  • Check Kernel Version:

    uname -r
  • Check System Uptime:

    uptime
  • Check Disk Usage:

    df -h
  • Check Memory Usage:

    free -h
  • Check CPU Usage:

    top

Package Management

  • Update Package List:

    sudo apt update
  • Upgrade All Packages:

    sudo apt upgrade
  • Full System Upgrade:

    sudo apt full-upgrade
  • Install a Package:

    sudo apt install package-name
  • Remove a Package:

    sudo apt remove package-name
  • Purge a Package (removes config files):

    sudo apt purge package-name
  • Search for a Package:

    apt search package-name
  • List Installed Packages:

    dpkg -l
  • Check Package Details:

    apt show package-name
  • Clean Up Unused Packages:

    sudo apt autoremove

User Management

  • Add a New User:

    sudo adduser username
  • Delete a User:

    sudo deluser username
  • Add User to a Group:

    sudo usermod -aG groupname username
  • Change User Password:

    sudo passwd username

File System Operations

  • List Files in Directory:

    ls -l
  • Change Directory:

    cd /path/to/directory
  • Create a New Directory:

    mkdir directory-name
  • Remove a Directory:

    rmdir directory-name
  • Copy Files:

    cp source-file destination-file
  • Move/Rename Files:

    mv source-file destination-file
  • Remove Files:

    rm file-name

Bash Basic Commands

  • Edit .bashrc:

    nano ~/.bashrc

    Or use your preferred text editor, such as vim or code.

  • Apply Changes Immediately:

    source ~/.bashrc

    Or simply:

    . ~/.bashrc

Common .bashrc Settings

  • Set Environment Variables:

    export VARIABLE_NAME="value"

    Example:

    export PATH="$PATH:/usr/local/bin"
  • Add Aliases:

    alias ll='ls -la'
    alias gs='git status'

    Aliases create shortcuts for longer commands.

  • Set Custom Prompt:

    PS1="\u@\h:\w\$ "

    Customize your shell prompt with colors and details:

    PS1='\[\e[0;32m\]\u@\h\[\e[m\]:\[\e[0;34m\]\w\[\e[m\]\$ '
  • Define Functions:

    my_function() {
      echo "Hello, World!"
    }
  • Change Default Editor:

    export EDITOR=nano
  • Set Up Command History:

    export HISTSIZE=1000
    export HISTFILESIZE=2000

Advanced Configurations

  • Enable Command Autocompletion:

    if [ -f /etc/bash_completion ]; then
      . /etc/bash_completion
    fi
  • Run Commands on Shell Start:

    echo "Welcome back, $USER!"
  • Load Additional Scripts:

    if [ -f ~/.bash_aliases ]; then
      . ~/.bash_aliases
    fi
  • Set Up SSH Agent:

    if [ -f ~/.ssh/agent.env ]; then
      . ~/.ssh/agent.env
    fi
  • Customize History Behavior:

    export HISTCONTROL=ignoredups:erasedups
    export HISTIGNORE="ls:ps:history"
  • Set Up Colorized ls Output:

    alias ls='ls --color=auto'

Troubleshooting

  • Check Syntax Errors:

    bash -n ~/.bashrc
  • Restore Default .bashrc: If you encounter issues, you can restore the default .bashrc by copying from /etc/skel/:

    cp /etc/skel/.bashrc ~/

Network Operations

  • Check IP Address:

    ip a
  • Check Network Connections:

    ss -tuln
  • Ping a Host:

    ping hostname-or-ip
  • Check Routing Table:

    ip route
  • Restart Network Service:

    sudo systemctl restart networking

System Services

  • Check Service Status:

    sudo systemctl status service-name
  • Start a Service:

    sudo systemctl start service-name
  • Stop a Service:

    sudo systemctl stop service-name
  • Restart a Service:

    sudo systemctl restart service-name
  • Enable a Service to Start at Boot:

    sudo systemctl enable service-name
  • Disable a Service from Starting at Boot:

    sudo systemctl disable service-name

System Logs

  • View System Logs:

    journalctl -xe
  • View Specific Log File:

    less /var/log/syslog
  • Tail a Log File:

    tail -f /var/log/syslog

Git Configuration

  • Set Global Git User Email & Name:

      git config --global user.email "siddhant22496@iiitd.ac.in"
      git config --global user.name "kintsugi-warrior"
  • Check Git Configuration:

    git config --list
  • Clone a Repository:

    git clone repository-url
  • Check Status of Repository:

    git status
  • Commit Changes:

    git commit -m "commit message"
  • Push Changes to Remote:

    git push
  • Pull Changes from Remote:

    git pull

Python

  • Check Python Version:

    python --version
  • Check Python3 Version:

    python3 --version
  • Install Python Package:

    pip install package-name
  • Install Python3 Package:

    pip3 install package-name
  • List Installed Python Packages:

    pip list
  • Create Virtual Environment:

    python -m venv env-name
  • Activate Virtual Environment:

    source env-name/bin/activate
  • Deactivate Virtual Environment:

    deactivate

Environment Variables

  • Set Environment Variable Temporarily:

    export VARIABLE_NAME=value
  • Set Environment Variable Permanently (in .bashrc or .bash_profile):

    echo 'export VARIABLE_NAME=value' >> ~/.bashrc
    source ~/.bashrc
  • View Environment Variables:

    printenv

SSH

  • Generate SSH Key Pair:

    ssh-keygen -t rsa -b 4096 -C "your-email@example.com"
  • Add SSH Key to SSH Agent:

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa
  • Copy SSH Key to Clipboard:

    cat ~/.ssh/id_rsa.pub
  • Connect to a Remote Host:

    ssh username@hostname
  • View SSH Configuration:

    cat ~/.ssh/config

OpenFortiVPN

  • Install OpenFortiVPN:

    sudo apt install openfortivpn
  • Connect to a VPN:

    sudo openfortivpn -c /etc/openfortivpn/config
  • Connect to a IIITD :

    sudo openfortivpn vpn.iiitd.edu.in:10443 --username=siddhant22496
  • Config file

      sudo nano /etc/openfortivpn/config
      sudo chmod 600 /etc/openfortivpn/config
      sudo openfortivpn
    # OpenFortiVPN Configuration File
    
    host = vpn.iiitd.edu.in
    port = 10443
    username = siddhant22496
    # Uncomment the following line if you have a password file
    # password = /path/to/password-file
    # Optional: You can specify the VPN gateway, client certificate, etc.
    # gateway = vpn-gateway-address
    # client-cert = /path/to/client-cert.pem
    # client-key = /path/to/client-key.pem
    
    
  • Check OpenFortiVPN Status:

    sudo systemctl status openfortivpn
  • Start OpenFortiVPN Service:

    sudo systemctl start openfortivpn
  • Stop OpenFortiVPN Service:

    sudo systemctl stop openfortivpn
  • Enable OpenFortiVPN Service to Start at Boot:

    sudo systemctl enable openfortivpn

Miscellaneous

  • Alias Setup:

    nano ~/.bashrc
    alias shortcut_name='full_command'
    source ~/.bashrc
  • Reboot the System:

    sudo reboot
  • Shutdown the System:

    sudo shutdown -h now
  • Check for Broken Packages:

    sudo apt --fix-broken install
  • Check Disk Space Usage:

    sudo du -sh /path/to/directory

REcent

#!/bin/bash

# Clear terminal
clear

# List contents of the current directory
ls
ls -R
clear

# Install necessary packages
sudo apt update
sudo apt install -y curl neofetch build-essential code git-all lolcat htop golang qbittorrent mysql-server sublime-text libreoffice pix audacious ghostwriter github-desktop virtualbox virtualbox-ext-pack tree fd-find exa duf cheese

# Install Brave browser
sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
sudo apt update
sudo apt install brave-browser -y

# Set opacity for Visual Studio Code
bash -c 'for W in $(wmctrl -l |grep "Visual Studio Code" |awk '\''{print $1}'\''); do xprop -id $W -format _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY $(printf 0x%x $((0xffffffff * 97 / 100))); done'

# Git configuration
git config --global user.email "siddhant22496@iiitd.ac.in"
git config --global user.name "kintsugi-warrior"

# Install OpenFortiVPN and connect
sudo apt install -y openfortivpn
sudo openfortivpn vpn.iiitd.edu.in:10443 --username=siddhant22496
sudo chmod 600 /etc/openfortivpn/config
openfortivpn

# Clone GitHub repository
gh repo clone kintsugi-programmer/balisalgo
git clone https://github.com/kintsugi-programmer/balisalgo.git

# Install GitHub CLI
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) 
sudo mkdir -p -m 755 /etc/apt/keyrings 
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null 
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg 
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null 
sudo apt update 
sudo apt install gh -y

# Compile and run C++ code
cd "/home/kintsugi-warrior/BaliGit/balisalgo/CodeRunner/" && g++ code.cpp -o code && "./code"
cd "/home/kintsugi-warrior/BaliGit/balisalgo/cpp/" && g++ cppprac.cpp -o cppprac && "./cppprac"
cd "/home/kintsugi-warrior/BaliGit/balisalgo/patterns/" && g++ prac.cpp -o prac && "./prac"

# Update and upgrade the system
sudo apt update && sudo apt upgrade -y

# Install g++
sudo apt install g++ -y

# Re-run C++ code after g++ installation
cd "/home/kintsugi-warrior/BaliGit/balisalgo/CodeRunner/" && g++ code.cpp -o code && "./code"
cd "/home/kintsugi-warrior/BaliGit/balisalgo/" && g++ code.cpp -o code && "./code"

# Bashrc modifications and source
nano ~/.bashrc
source ~/.bashrc

# Connect to IIITD VPN
iiitd

# Set opacity for Visual Studio Code (multiple times)
bash -c 'for W in $(wmctrl -l |grep "Visual Studio Code" |awk '\''{print $1}'\''); do xprop -id $W -format _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY $(printf 0x%x $((0xffffffff * 97 / 100))); done'

System Update & Upgrade

echo "Updating and upgrading system..."
sudo apt update && sudo apt upgrade -y

Install Required Packages

echo "Installing required packages..."
sudo apt install -y neofetch build-essential code git-all curl lolcat htop golang qbittorrent mysql-server sublime-text libreoffice pix audacious ghostwriter github-desktop virtualbox virtualbox-ext-pack tree fd-find exa duf cheese

Visual Studio Code Extensions

echo "Installing Visual Studio Code extensions..."
code --install-extension ahmadawais.shades-of-purple \
     --install-extension CoenraadS.bracket-pair-colorizer-2 \
     --install-extension eamodio.gitlens \
     --install-extension dbaeumer.vscode-eslint \
     --install-extension esbenp.prettier-vscode \
     --install-extension ritwickdey.LiveServer \
     --install-extension msjsdiag.debugger-for-chrome \
     --install-extension ms-azuretools.vscode-docker \
     --install-extension ms-vscode-remote.remote-ssh \
     --install-extension ms-vscode.cpptools \
     --install-extension formulahendry.code-runner \
     --install-extension Zackptg5.Glassit \
     --install-extension ms-toolsai.jupyter \
     --install-extension vscjava.vscode-maven \
     --install-extension mtxr.sqltools \
     --install-extension ms-python.python \
     --install-extension donjayamanne.githistory \
     --install-extension vscodevim.vim \
     --install-extension dsznajder.es7-react-js-snippets \
     --install-extension esbenp.prettier-vscode \
     --install-extension ecmel.vscode-html-css \
     --install-extension GitHub.copilot

Clone & Install auto-cpufreq

echo "Installing auto-cpufreq..."
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq && sudo ./auto-cpufreq-installer
cd ..

Install Brave Browser

echo "Installing Brave browser..."
sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
sudo apt update
sudo apt install -y brave-browser

Install Spotify

echo "Installing Spotify..."
curl -sS https://download.spotify.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt update
sudo apt install -y spotify-client

Install Sublime Text

echo "Installing Sublime Text..."
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-add-repository "deb https://download.sublimetext.com/ apt/stable/"
sudo apt update
sudo apt install -y sublime-text

Install TLDR

echo "Installing TLDR..."
sudo apt install -y tldr
sudo tldr --update

Install Node.js and npm

echo "Installing Node.js and npm..."
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt-get install -y nodejs npm

Add User to vboxusers Group

echo "Adding user to vboxusers group..."
sudo usermod -aG vboxusers $USER

Here's a similar style documentation for the commands from your history:

NVIDIA Drivers

  • Purge Existing NVIDIA Drivers:

    sudo apt-get purge nvidia*
  • Update Package Lists:

    sudo apt-get update
  • Install Build Essentials and DKMS:

    sudo apt-get install build-essential dkms
  • List Available NVIDIA Drivers:

    ubuntu-drivers devices
  • Install NVIDIA Driver 535:

    sudo apt-get install nvidia-driver-535
  • Update GRUB Configuration:

    sudo nano /etc/default/grub
    sudo update-grub
    sudo reboot

Brave Browser

  • Add Brave Browser GPG Key:

    sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
  • Add Brave Repository:

    echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
  • Install Brave Browser:

    sudo apt update
    sudo apt install brave-browser

GNOME Tweaks & Window Opacity

  • Install GNOME Tweaks:

    sudo apt install gnome-tweaks
  • Set Visual Studio Code Window Opacity to 80%:

    bash -c 'for W in $(wmctrl -l | grep "Visual Studio Code" | awk '{print $1}'); do xprop -id $W -format _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY $(printf 0x%x $((0xffffffff * 80 / 100))); done'

Touchegg

  • Add Touchegg PPA:

    sudo add-apt-repository ppa:touchegg/stable
  • Install Touchegg:

    sudo apt update
    sudo apt install touchegg
  • Enable Touchegg Service:

    sudo systemctl start touchegg
    sudo systemctl enable touchegg

Miscellaneous

  • Uninstall Cheese Webcam Application:

    sudo apt purge cheese
  • Install Docker using Nala:

    sudo nala install docker.io
  • Install Nix Package Manager:

    sh <(curl -L https://nixos.org/nix/install) --daemon
  • Install Ubuntu Restricted Extras:

    sudo nala install ubuntu-restricted-extras -y
  • Clean Up Nix Packages:

    nix-collect-garbage

Here's a concise cheat sheet for working with Nix:

Nix Basics

  • Install Nix:

    sh <(curl -L https://nixos.org/nix/install) --daemon
  • Enter a Nix Shell with Specific Packages:

    nix-shell -p package1 package2
  • Enter a Nix Shell with default.nix:

    nix-shell
  • Install a Package System-Wide:

    nix-env -iA nixpkgs.packageName
  • Search for a Package:

    nix-env -qaP | grep packageName
  • Uninstall a Package:

    nix-env -e packageName

Nix Packages and Channels

  • Update Nix Channels:

    nix-channel --update
  • Add a New Nix Channel:

    nix-channel --add https://nixos.org/channels/nixos-unstable
  • List Installed Packages:

    nix-env -q

Nix Garbage Collection

  • Remove Unused Packages:

    nix-collect-garbage
  • Remove All Old Generations:

    nix-collect-garbage -d
  • List All Generations:

    nix-env --list-generations

Nix Shell

  • Create a default.nix File:

    { pkgs ? import <nixpkgs> {} }:
    pkgs.mkShell {
      buildInputs = [ pkgs.package1 pkgs.package2 ];
    }
  • Enter a Nix Shell with shell.nix:

    nix-shell shell.nix

NixOS Specific

  • Rebuild System Configuration:

    nixos-rebuild switch
  • Edit NixOS Configuration:

    sudo nano /etc/nixos/configuration.nix
  • Install NixOS Configuration:

    nixos-rebuild boot

Nix Expressions

  • Run a Nix Expression:

    nix-build '<nixpkgs>' -A packageName
  • Create a Simple Nix Expression:

    { pkgs ? import <nixpkgs> {} }:
    pkgs.stdenv.mkDerivation {
      name = "hello";
      src = ./src;
      buildInputs = [ pkgs.gcc ];
      buildPhase = "make";
      installPhase = "make install";
    }

Basic GRUB Commands

  • Update GRUB Configuration:

    sudo update-grub

    This regenerates the GRUB configuration file (grub.cfg) based on the scripts in /etc/grub.d/.

  • Edit GRUB Configuration:

    sudo nano /etc/default/grub

    Use this to modify GRUB settings like the default operating system, timeout, etc.

  • Apply GRUB Changes:

    sudo update-grub

    Always run this command after editing /etc/default/grub to apply changes.

Common GRUB Settings in /etc/default/grub

  • Set Default Operating System:

    GRUB_DEFAULT=0

    Change the number to select a different OS from the list (0-based index).

  • Set GRUB Timeout:

    GRUB_TIMEOUT=10

    Set the timeout period in seconds before GRUB boots the default OS.

  • Enable/Disable GRUB Hidden Menu:

    GRUB_TIMEOUT_STYLE=hidden

    Set to hidden to hide the menu, or menu to show it.

  • Change GRUB Background Image:

    GRUB_BACKGROUND="/path/to/your/image.png"
  • Add Kernel Parameters:

    GRUB_CMDLINE_LINUX="quiet splash"

    You can add additional kernel parameters here.

Advanced GRUB Commands

  • Reinstall GRUB on a Specific Disk:

    sudo grub-install /dev/sda

    Replace /dev/sda with the target disk.

  • Boot into GRUB Command Line: Press c at the GRUB menu.

  • List Available Disks and Partitions:

    ls

    Useful in GRUB command line to identify disk partitions.

  • Set Root Partition:

    set root=(hd0,1)

    Adjust (hd0,1) according to your partition layout.

  • Load Kernel Manually (from GRUB CLI):

    linux /boot/vmlinuz-x.x.x-xx-generic root=/dev/sda1 ro

    Replace /dev/sda1 with your root partition.

  • Load Initial RAM Disk:

    initrd /boot/initrd.img-x.x.x-xx-generic
  • Boot Manually (after setting kernel and initrd):

    boot

GRUB Rescue Mode

  • Enter GRUB Rescue Mode: If GRUB cannot find its configuration files, it may drop you into rescue mode.

  • Set Root and Prefix:

    set root=(hd0,1)
    set prefix=(hd0,1)/boot/grub
  • Load Normal Module and Boot:

    insmod normal
    normal

Recovering GRUB

  • Boot from a Live CD/USB and Mount Partitions:

    sudo mount /dev/sda1 /mnt
    sudo mount --bind /dev /mnt/dev
    sudo mount --bind /proc /mnt/proc
    sudo mount --bind /sys /mnt/sys
  • Chroot into the Mounted System:

    sudo chroot /mnt
  • Reinstall GRUB from Chroot:

    grub-install /dev/sda
    update-grub
  • Exit Chroot and Unmount:

    exit
    sudo umount /mnt/dev /mnt/proc /mnt/sys
    sudo umount /mnt

Nala Basics

  • Update Package List:

    sudo nala fetch
  • Upgrade Installed Packages:

    sudo nala upgrade
  • Install a Package:

    sudo nala install package-name
  • Remove a Package:

    sudo nala remove package-name
  • Purge a Package (removes package and configuration files):

    sudo nala purge package-name
  • Search for a Package:

    nala search package-name
  • Show Information About a Package:

    nala show package-name
  • List All Installed Packages:

    nala list --installed

Advanced Usage

  • Install Multiple Packages:

    sudo nala install package1 package2 package3
  • Simulate an Installation or Upgrade:

    nala install package-name --simulate
    nala upgrade --simulate
  • View Change Log for a Package:

    nala changelog package-name
  • Hold a Package (prevent it from being upgraded):

    sudo nala hold package-name
  • Unhold a Package:

    sudo nala unhold package-name
  • Clean Up Unused Packages and Dependencies:

    sudo nala autoremove

Nala History

  • View Package Management History:

    nala history
  • Undo the Last Operation:

    sudo nala history undo
  • Redo the Last Undo:

    sudo nala history redo

Configuration

  • Set Preferred Language:

    sudo nala config --set language en
  • Enable Parallel Downloads:

    sudo nala config --set parallel_downloads true
  • Reset Nala Configuration:

    sudo nala config --reset

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published