Posts for: #Basic

18.How to Run Ai locally on Your Pc


Why Run AI Locally?

  1. Privacy: Your data stays on your machine.
  2. Cost: No API fees or subscriptions.
  3. Customization: Tweak models to solve your unique problems.
  4. Offline Access: Use AI even without an internet connection.

Step 1: Installing Ollama

Ollama works on Windows, macOS, and Linux. Here’s how to set it up:

For Windows (Preview):

  1. Download the Ollama Windows installer.
  2. Run the .exe file and follow the prompts.
  3. Open PowerShell or Command Prompt and test with ollama --version.

For macOS/Linux:

  1. Open Terminal and run this command:
    curl -fsSL https://ollama.ai/install.sh | sh  
    
  2. Verify the install: ollama --version.

Step 2: Running Your First AI Model

Ollama has a library of pre-trained models. Let’s start with Llama 2 (a popular open-source model by Meta):

Read more

  1. Bash Commands


Bash Cheat Sheet

A cheat sheet for bash commands.

Command History

!!            # Run the last command

touch foo.sh
chmod +x !$   # !$ is the last argument of the last command i.e. foo.sh
pwd                       # Print current directory path
ls                        # List directories
ls -a|--all               # List directories including hidden
ls -l                     # List directories in long form
ls -l -h|--human-readable # List directories in long form with human readable sizes
ls -t                     # List directories by modification time, newest first
stat foo.txt              # List size, created and modified timestamps for a file
stat foo                  # List size, created and modified timestamps for a directory
tree                      # List directory and file tree
tree -a                   # List directory and file tree including hidden
tree -d                   # List directory tree
cd foo                    # Go to foo sub-directory
cd                        # Go to home directory
cd ~                      # Go to home directory
cd -                      # Go to last directory
pushd foo                 # Go to foo sub-directory and add previous directory to stack
popd                      # Go back to directory in stack saved by `pushd`

Creating Directories

mkdir foo                        # Create a directory
mkdir foo bar                    # Create multiple directories
mkdir -p|--parents foo/bar       # Create nested directory
mkdir -p|--parents {foo,bar}/baz # Create multiple nested directories

mktemp -d|--directory            # Create a temporary directory

Moving Directories

cp -R|--recursive foo bar                               # Copy directory
mv foo bar                                              # Move directory

rsync -z|--compress -v|--verbose /foo /bar              # Copy directory, overwrites destination
rsync -a|--archive -z|--compress -v|--verbose /foo /bar # Copy directory, without overwriting destination
rsync -avz /foo username@hostname:/bar                  # Copy local directory to remote directory
rsync -avz username@hostname:/foo /bar                  # Copy remote directory to local directory

Deleting Directories

rmdir foo                        # Delete empty directory
rm -r|--recursive foo            # Delete directory including contents
rm -r|--recursive -f|--force foo # Delete directory including contents, ignore nonexistent files and never prompt

Creating Files

touch foo.txt          # Create file or update existing files modified timestamp
touch foo.txt bar.txt  # Create multiple files
touch {foo,bar}.txt    # Create multiple files
touch test{1..3}       # Create test1, test2 and test3 files
touch test{a..c}       # Create testa, testb and testc files

mktemp                 # Create a temporary file

Standard Output, Standard Error and Standard Input

echo "foo" > bar.txt       # Overwrite file with content
echo "foo" >> bar.txt      # Append to file with content

ls exists 1> stdout.txt    # Redirect the standard output to a file
ls noexist 2> stderror.txt # Redirect the standard error output to a file
ls 2>&1 > out.txt          # Redirect standard output and error to a file
ls > /dev/null             # Discard standard output and error

read foo                   # Read from standard input and write to the variable foo

Moving Files

cp foo.txt bar.txt                                # Copy file
mv foo.txt bar.txt                                # Move file

rsync -z|--compress -v|--verbose /foo.txt /bar    # Copy file quickly if not changed
rsync z|--compress -v|--verbose /foo.txt /bar.txt # Copy and rename file quickly if not changed

Deleting Files

rm foo.txt            # Delete file
rm -f|--force foo.txt # Delete file, ignore nonexistent files and never prompt

Reading Files

cat foo.txt            # Print all contents
less foo.txt           # Print some contents at a time (g - go to top of file, SHIFT+g, go to bottom of file, /foo to search for 'foo')
head foo.txt           # Print top 10 lines of file
tail foo.txt           # Print bottom 10 lines of file
open foo.txt           # Open file in the default editor
wc foo.txt             # List number of lines words and characters in the file

File Permissions

# Permission rwx Binary
7 read, write and execute rwx 111
6 read and write rw- 110
5 read and execute r-x 101
4 read only r– 100
3 write and execute -wx 011
2 write only -w- 010
1 execute only –x 001
0 none 000

For a directory, execute means you can enter a directory.

Read more

  1. windows command


Directory Navigation

  • c: - Switch to the C:\ drive.
  • d: - Switch to the D:\ drive.
  • CD c:\path\to\my_folder - Change directory to c:\path\to\my_folder.
  • CD .. - Move to the parent directory.
  • CD .\new_folder - Move to the folder new_folder in the current directory.
  • CD /D d:\videos\ - Switch to D:\ drive and go to videos folder.
  • DIR - List files and folders in the current directory.
  • DIR /A c:\apps\ - Show files and folders in c:\apps.
  • DIR /A:D - Show only folders.
  • DIR /A:-D - Show only files.
  • DIR /A:H - Show hidden files and folders.
  • DIR /O - List files and folders alphabetically.
  • DIR /O:S - Sort by file size (smallest to largest).
  • DIR /O:-S - Sort by file size (largest to smallest).
  • DIR /B - Show only file and folder names.
  • SORT - Sort input alphabetically.
  • MOVE c:\f1\text.txt c:\f2 - Move text.txt from f1 to f2.
  • MD new_folder - Create a folder named new_folder.
  • RD new_folder - Remove a folder named new_folder.
  • TREE - Show directory structure.
  • ATTRIB +H +S +R myItem - Hide myItem.
  • ATTRIB -H -S -R myItem - Unhide myItem.

File Management

  • COPY text.txt C:\schoolwork - Copy text.txt to C:\schoolwork.
  • DEL text.txt - Delete text.txt.
  • REN text.txt script.bat - Rename text.txt to script.bat.
  • REPLACE .\src\hey.txt .\dest - Replace hey.txt in dest with the one in src.
  • XCOPY /S folder1 folder2 - Copy folder1 and subfolders to folder2.
  • ROBOCOPY - Copy files/directories with advanced options.
  • EXPAND gameData.cab - Decompress gameData.cab.
  • FC file1.ext file2.ext - Compare contents of two files.
  • FIND "python" run.bat - Find lines containing python in run.bat.
  • PRINT resume.txt - Print resume.txt.
  • TYPE test.txt - Display test.txt contents.
  • MORE - Display file contents one screen at a time.
  • NOTEPAD filename.ext - Open filename.ext in Notepad.

Disk Management

  • CHKDSK - Check and repair disk issues.
  • CIPHER /E folder - Encrypt folder.
  • CIPHER /D file - Decrypt file.
  • DEFRAG - Defragment a disk.
  • CHKNTFS - Modify disk-checking on startup.
  • FORMAT - Format a disk.
  • DISKPART - Manage disk partitions.
  • LABEL d:x - Rename D:\ drive to X:.
  • RECOVER d:\data.dat - Recover data.dat from D:.
  • VOL - Show disk volume label and serial number.
  • SFC /SCANNOW - Scan and update protected system files.

System Info & Networking

  • VER - Show OS version.
  • SYSTEMINFO - Show system configuration.
  • HOSTNAME - Show computer’s hostname.
  • DATE - Display/set system date.
  • IPCONFIG - Show IP configuration.
  • PING google.com - Check connectivity to google.com.
  • PATHPING - Trace route with latency and packet loss.
  • TRACERT - Trace route to a host.
  • NET - Access network services.
  • NETSTAT - Show network connections and stats.
  • NSLOOKUP - Look up IP addresses.
  • ROUTE - Manage routing tables.
  • GETMAC - Show MAC addresses.

Process Management

  • SCHTASKS - Create/edit scheduled tasks.
  • SET - List environment variables.
  • PATH - Display or modify the PATH environment variable.
  • SHUTDOWN /R - Restart the computer.
  • SHUTDOWN /S /T 60 - Shut down in 60 seconds.
  • TASKLIST - List running tasks.
  • TASKKILL /IM "process_name" - Terminate tasks by name.
  • TASKKILL /PID process_id - Terminate tasks by process ID.
  • REGEDIT - Open Registry Editor.
  • RUNAS /USER:username program - Run a program as another user.
  • POWERSHELL - Open a PowerShell instance.

Batch Scripting

  • REM - Add a single-line comment.
  • GOTO - Jump to a labeled section.
  • SET /A var=expression - Perform arithmetic operations.
  • TIMEOUT seconds - Pause for a specified time.
  • PAUSE - Wait for user input.
  • CHOICE - Prompt for user selection.
  • CLS - Clear the screen.
  • COLOR - Set console colors.
  • ECHO - Display text.
  • HELP - Get help for a command.
  • PROMPT - Change the command prompt appearance.
  • START - Open a file or program in a new window.
  • TITLE - Set the console window title.
  • EXIT - Close the command prompt.

Flow Control

  • IF condition command - Execute a command if the condition is true.
  • IF condition (command1) ELSE (command2) - Execute one of two commands based on a condition.
  • :label - Define a marker for loops.
  • GOTO label - Jump to a marker.

Shortcut Keys

  • Tab - Autocomplete commands and paths.
  • Ctrl+F - Search within the console.
  • F1, F3, F5, F8 - Recall previous commands.
  • F7 - Display command history.
  • F9 - Execute a specific command from history.

1 Line Common Commands

Files and Folders Management

  • COPY - Copies files to another location
  • DIR – Displays files and folders in current directory
  • DEL or ERASE - Deletes files
  • EDIT - Starts file editor
  • CD - Changes directory
  • EXPAND - Decompresses compressed files
  • FC - Compares files and shows the differences between them
  • FIND - Finds a text string in the file
  • MD or MAKEDIR - Creates a folder
  • MOVE - Moves files from one folder to another
  • PRINT - Prints out the text file contents
  • RD or RMDIR - Deletes a folder
  • REN or RENAME - Renames a file or folder
  • REPLACE - Replaces files in one directory with files of the same name in another directory (overwrite)
  • ROBOCOPY - Uses an advanced tool to copy files and directories
  • TREE - Shows directory structure of a disk or folder
  • TYPE - Displays the contents of text files
  • OPENFILES – Manages opened local or network files
  • XCOPY - Copies files and directory trees

Applications and Processes

  • SCHTASKS - Executes a command or start a scheduled application (Task Scheduler)
  • SHUTDOWN - Shutdowns or reboots your computer
  • TASKLIST - Lists the tasks being performed
  • TASKKILL - Stops or halts a task (to stop a task you use a PID which you can find out from TASKLIST)
  • REG – Starts registry editor
  • RUNAS - Launches the task as another user

Disks Management

  • CHKDISK - Checks disk and shows statistics
  • DEFRAG – Starts disk defragmentation
  • CHKNTFS - Displays or changes execution of disk check at boot
  • COMPACT - Displays and change the compression of files in NTFS partitions
  • CONVERT - Converts FAT disk volume to NTFS
  • DISKPART - Displays and adjusts disk partition properties
  • FORMAT - Formats the disk
  • FSUTIL - Displays and configures file system properties
  • LABEL - Creates, changes, or deletes a disk volume label
  • RECOVER - Recovers data from a bad or damaged disk
  • VOL - Displays volume label and serial number for the disk

System Information

  • DATE - Outputs or sets the current date
  • TIME - Displays or sets the system time
  • DRIVERQUERY - Displays the current state and properties of the device driver
  • HOSTNAME - Displays name of the computer
  • SYSTEMINFO - Shows configuration information about your computer
  • VER - Allows you to view the Windows version
  • GPRESULT – Displays current applied group policies (RSoP)
  • GPUPDATE – Updates group policies

Network

  • IPCONFIG - Shows information about network interfaces
  • PING – Sends ICMP requests to the target host, checks host availability
  • TRACERT - Finds the path for packets traveling over the network
  • NSLOOKUP - Finds IP address by resource name
  • ROUTE - Displays network route tables
  • ARP- Shows a table with IP addresses converted into physical addresses
  • NETSH – Starts is a network settings control program
  • GETMAC - Shows the MAC address of the network adapter
  • TFTP – Starts TFTP client in console

Command Line Setup

  • CLS - Clears screen
  • CMD - Displays another command prompt
  • COLOR - Sets the text and background color
  • PROMPT - Changes the command line prompt
  • TITLE - Assigns a title for the current session
  • HELP – Launches CMD help
  • EXIT - Exits the command line
Read more

  1. Git Workflow and Commands Explained

Git Workflow and Commands Explained

Introduction

Git is a distributed version control system for version tracking and collaboration. This guide covers essential Git commands and workflows, applicable to any project or file.


Interfaces

  • Command Line: Fastest and most versatile option.
  • GUI Options:
    • GitKraken: Free for open-source projects.
    • Sourcetree: Free for Windows and macOS.

Initial Setup

Check Git Version

Verify the Git installation:

git --version

Git Bash

Emulates a Linux terminal environment for Windows users, making it easier to use Git commands.

Read more

  1. Exploring the Linux File System: A Beginner’s Guide


When you first jump into Linux, one of the first things you’ll encounter is its file system. Unlike Windows, which uses drive letters like C:, Linux organizes everything under a single root directory (/). This organization might seem a bit daunting at first, but understanding it is key to navigating your system, troubleshooting problems, and managing files effectively. So, let’s break down the Linux file system hierarchy in a more approachable, human way, so you can start using it like a pro.

Read more

  1. Linux Networking Essentials


Linux Networking Essentials: From IP Addresses to Firewalls (In-Depth Guide)

Networking in Linux is an essential skill for anyone working with the operating system. It forms the backbone of all communication between systems, whether it’s on the internet or within a local network. In this detailed guide, we’ll dive deep into essential networking concepts, from understanding IP addresses and subnetting to configuring IPs and setting up firewalls.

1. What is Networking on Linux?

Networking on Linux refers to the process of connecting your Linux system to other devices and systems via different network interfaces. This could involve connecting to the internet, setting up local networks, managing network configurations, or securing your system with firewalls. Linux provides a flexible and powerful environment for managing these tasks.

Read more

  1. Docker on Linux


Docker on Linux and Windows: Setting Up and Running Your First Container with Real-Life Use Case

Docker has revolutionized how we deploy and manage applications, offering a consistent environment across various platforms. By creating containers, Docker allows developers and sysadmins to package their applications with all the dependencies they need, ensuring they run smoothly regardless of the environment. Whether you’re on Linux or Windows, setting up Docker and understanding its core concepts will make your life easier. In this blog, we’ll not only go through the installation process on both Linux and Windows but also dive into a real-life use case—deploying a web application using Docker.

Read more

  1. Introduction to Shell Scripting


Introduction to Shell Scripting: Automating Daily Tasks (Bash and PowerShell Edition)

Alright, imagine this: you wake up, fire up your computer, and instead of wasting time organizing files or backing up data, you just hit a button, and boom—your computer does all that boring stuff for you. That’s the magic of shell scripting. It’s not just for Linux nerds; even Windows folks can automate tasks like a pro using PowerShell.

Read more

  1. Kali, linux Commands


Top 60 Linux Commands Cheat Sheet in one line


A. File and Directory Management Commands

  • ssh: Secure Shell, used for secure remote access to a system.
  • ls: List directory contents.
  • pwd: Print the current working directory.
  • cd: Change directory to a different folder.
  • touch: Create an empty file or update the modified timestamp of an existing file.
  • echo: Print a message or the value of a variable.
  • nano: A simple text editor.
  • vim: A more advanced text editor with many features.
  • cat: Print the contents of a file to the console.
  • shred: Securely delete a file by overwriting its contents.
  • mkdir: Create a new directory.
  • cp: Copy a file from one location to another.
  • mv: Move a file from one location to another, or rename a file.
  • rm: Remove a file.
  • rmdir: Remove a directory if it is empty.
  • ln: Create a link to a file or directory.
  • head: Display the first lines of a file.
  • tail: Display the last lines of a file.
  • cmp: Compare two files byte by byte.
  • diff: Display the differences between two files.
  • sort: Sort the lines of a file.
  • find: Search for files in a directory hierarchy.
  • chmod: Change the permissions of a file or directory.
  • chown: Change the owner of a file or directory.

B. System Management Commands

Read more

  1. Setting up hacking Environment…


Setting Up Your Hacking Environment: A Beginner’s Guide

If you’re curious about ethical hacking or just starting your journey into cybersecurity, the first step is creating a safe and functional environment for your experiments and learning. This guide will walk you through the process in a detailed and technical format, making it easy to understand—even for beginners (yes, you!).


1. Start with the Right Hardware

Before you get your hacker on, make sure your computer can handle the demands of hacking tools and virtual machines. A good hacking environment requires hardware that can support multiple virtual machines, networks, and complex tools. Here’s a more technical breakdown:

Read more