Package Management with dpkg
Install a local .deb package:
sudo dpkg -i package.deb
Remove a package while keeping configuration files:
sudo dpkg -r package_name
Purge both the package and its configuration files:
sudo dpkg --purge package_name
List all installed packages:
dpkg -l
Display information about a .deb file:
dpkg -I package.deb
Display Configuration via xrandr
Query connected displays and supported modes:
xrandr --query
Set resolution and refresh rate for a specific output (e.g., HDMI-1-0):
xrandr --output HDMI-1-0 --mode 1920x1080 --rate 144
Secure Shell (SSH) Usage
Connect to a remote host on a custom port:
ssh -p 6000 v3-1000@100.100.100.100
Generate an SSH key pair:
ssh-keygen
Copy the public key to a remote server:
ssh-copy-id -p 6000 v3-1000@100.100.100.100
File Transfer Tools
Upload a file using scp:
scp /home/curme/Documents/cyb.txt smith@100.100.100.100:/home/smith/Documents/
Recursively upload a directory:
scp -r /home/curme/Documents/cyb/ smith@100.100.100.100:/home/smith/Documents/
Download a file from a remote server:
scp smith@100.100.100.100:/home/smith/Documents/smith.txt /home/curme/Documents/
Use rsync over SSH for efficient transfers:
rsync -avz -e "ssh -p 22" /mnt/d/curme/KEEP_CYB/*.tar.gz smith@111.111.111.111:/home/curme/
Git Basics
Initialize a new repository:
git init
Stage changes:
git add path/to/file
Commit staged changes:
git commit -m "Descriptive message"
Archive Handling with tar
Create a gzip-compressed archive:
tar -czvf archive.tar.gz source_file
Create an xz-compressed archive:
tar -cJvf archive.tar.xz source_file
Extract a .tar.gz file:
tar -xzvf archive.tar.gz
Extract a .tar.xz file:
tar -xJvf archive.tar.xz
Directory Listing Enhancements
Show all files, including hidden ones:
ls -la
Display human-readable file sizes:
ls -lh
Countt regular files in the current directory:
ls -l | grep '^-' | wc -l
Count directories:
ls -l | grep '^d' | wc -l
Python Package Management with pip
List outdated packages:
pip list --outdated
Upgrade a specific package to a version:
pip install --upgrade package_name==1.2.3
Fun Terminal Utilities
Display a speaking cow:
cowsay "Hello, world!"
Simulate a Matrix-style terminal rain:
cmatrix -C blue
Print large ASCII banners:
banner Linux
Install and set up Oh My Zsh:
sudo apt install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
ZIP Compression
Compress a directory:
zip -r archive.zip source_directory/
Encrypt during compression:
zip -re secure.zip sensitive_data/
Extract to a specific directory:
unzip archive.zip -d destination_folder/
Disk Image and Filesystem Operations
Create a 256 MB blank disk image:
dd if=/dev/zero of=virtual.img bs=1M count=256
Format a device with ext4:
mkfs.ext4 /dev/sdb
Mount a partition as read-only:
mount -o ro /dev/sda3 /media/usb
Unmount a filesystem:
umount /media/usb
Disk Usage Analysis
Show human-readable disk usage per subdirectory:
du -ah
Conda Environment Management
Create a new environment with Python 3.11:
conda create -n myenv python=3.11
Activate the environment (Linux/macOS):
source activate myenv
Deactivate the current environment:
source deactivate
Export environment to a YAML file:
conda env export > environment.yml
Recreate an environment from a file:
conda env create -f environment.yml
Remove an entire environment:
conda remove -n myenv --all
APT Package Management
Install a package:
sudo apt install package_name
Remove a package but keep configs:
sudo apt remove package_name
Fully purge a package and its dependencies:
sudo apt purge package_name
sudo apt autoremove
List all available packages:
apt list
GPU Memory Cleanup
Force-kill processes using NVIDIA GPUs to free memory:
fuser -v /dev/nvidia* 2>/dev/null | awk 'NR>1 {print "kill -9", $2}' | sh