Complete List of Cheat Sheet For Technician

Table Of Contents

CMD

Basic System Commands

  • cls
    Clears the Command Prompt screen.
  • exit
    Closes the Command Prompt window.
  • echo Hello World
    Displays a message in the Command Prompt (outputs “Hello World”).
  • time
    Displays or sets the system time. Example input: 12:30:00 to set the time.
  • date
    Displays or sets the system date. Example input: 01-12-2024 to set the date.
  • hostname
    Displays the name of the computer.
  • ver
    Displays the version of Windows.
  • systeminfo
    Displays detailed information about the system configuration.
  • tasklist
    Lists all running processes.
  • taskkill /IM notepad.exe
    Terminates the Notepad process.

File and Directory Management

  • dir
    Lists the files and directories in the current folder.
  • cd C:\Users\user1\Documents
    Changes to the specified directory.
  • cd..
    Moves up one directory level.
  • mkdir newFolder
    Creates a new directory named newFolder.
  • rmdir newFolder
    Deletes the empty directory newFolder.
  • del myfile.txt
    Deletes the file myfile.txt.
  • copy C:\file1.txt D:\file2.txt
    Copies file1.txt from C: to D: as file2.txt.
  • move C:\file1.txt D:\file2.txt
    Moves file1.txt from C: to D:.
  • rename oldfile.txt newfile.txt
    Renames oldfile.txt to newfile.txt.
  • attrib +r myfile.txt
    Sets the myfile.txt file to read-only.
  • xcopy C:\Folder D:\Backup /s
    Copies the entire Folder from C: to D:\Backup (including subdirectories).
  • robocopy C:\data D:\backup /e
    Copies files from C:\data to D:\backup, including all subdirectories and files.

Network Commands

  • ping google.com
    Sends a network ping to google.com.
  • ipconfig
    Displays the current IP configuration.
  • ipconfig /all
    Displays detailed information about network interfaces.
  • tracert google.com
    Traces the route packets take to google.com.
  • netstat
    Displays active network connections and listening ports.
  • nslookup google.com
    Looks up DNS information for google.com.
  • net use X: \Server\SharedFolder
    Maps network share \\Server\SharedFolder to drive X:.

System Configuration and Maintenance

  • chkdsk C:
    Checks and repairs errors on the C: drive.
  • sfc /scannow
    Scans and repairs system files.
  • diskpart
    Opens the disk partition tool.
  • defrag C:
    Defragments the C: drive.
  • shutdown /s /f /t 60
    Shuts down the computer in 60 seconds.
  • shutdown /r /f /t 60
    Restarts the computer in 60 seconds.
  • powercfg /hibernate off
    Disables hibernation on the system.
  • msconfig
    Opens the System Configuration utility.
  • regedit
    Opens the Registry Editor.

User Management

  • net user
    Lists all user accounts on the computer.
  • net user user1 password123 /add
    Adds a new user user1 with the password password123.
  • net user user1 /delete
    Deletes the user account user1.
  • net localgroup administrators user1 /add
    Adds user1 to the administrators group.
  • net user user1 newpassword123
    Changes the password for user1 to newpassword123.

Drive and Disk Management

  • diskpart
    Opens the disk partition utility.
  • format D:
    Formats the D: drive (Warning: This deletes all data).
  • chkdsk C: /f
    Fixes file system errors on the C: drive.

Environment and System Variables

  • set
    Displays all environment variables.
  • set PATH=C:\NewPath
    Sets the PATH environment variable to C:\NewPath.
  • echo %PATH%
    Displays the current value of the PATH environment variable.

Advanced Commands

  • find “error” log.txt
    Searches for the word error in log.txt.
  • findstr “error” log.txt
    Searches for the word error in log.txt with more advanced options.
  • assoc .txt=txtfile
    Associates the .txt file extension with the txtfile type.
  • cipher /e C:\Data
    Encrypts the C:\Data folder.
  • tasklist
    Lists all running processes on the system.
  • taskkill /f /im notepad.exe
    Forcefully closes notepad.exe.
  • schtasks /create /sc daily /tn “Backup” /tr “C:\Backup\backup.bat” /st 02:00
    Schedules a task to run backup.bat daily at 2:00 AM.

Help Commands

  • help
    Displays a list of available commands.
  • del /?
    Displays help information for the del command.

PowerShell

Basic System Commands

  • Clear-Host
    Clears the PowerShell screen.
  • Exit
    Closes the PowerShell window.
  • Write-Host “Hello World”
    Displays a message in the PowerShell window (outputs “Hello World”).
  • Get-Date
    Displays the current date and time.
  • Set-Date “12/01/2024 14:30”
    Sets the system date and time to 12/01/2024 14:30.
  • Get-Command
    Lists all available commands in PowerShell.
  • Get-Help Get-Command
    Shows help information for the Get-Command command.
  • Get-Process
    Lists all running processes.
  • Stop-Process -Name notepad
    Terminates the notepad process.

File and Directory Management

  • Get-ChildItem
    Lists the files and directories in the current directory.
  • Set-Location C:\Users\user1\Documents
    Changes to the specified directory.
  • New-Item -Path C:\ -Name “newFolder” -ItemType Directory
    Creates a new directory named newFolder in C:\.
  • Remove-Item C:\newFolder
    Deletes the newFolder directory.
  • Remove-Item C:\file1.txt
    Deletes the file1.txt file.
  • Copy-Item C:\file1.txt -Destination D:\file2.txt
    Copies file1.txt from C: to D:\file2.txt.
  • Move-Item C:\file1.txt -Destination D:\file2.txt
    Moves file1.txt from C: to D:\file2.txt.
  • Rename-Item C:\file1.txt -NewName file2.txt
    Renames file1.txt to file2.txt.
  • Get-Content C:\file1.txt
    Displays the contents of file1.txt.
  • Set-Content C:\file1.txt “New content”
    Replaces the contents of file1.txt with “New content”.
  • Add-Content C:\file1.txt “Additional content”
    Appends “Additional content” to file1.txt.
  • Test-Path C:\file1.txt
    Checks if file1.txt exists in C: (returns True or False).

Network Commands

  • Test-Connection google.com
    Sends a network ping to google.com.
  • Get-NetIPAddress
    Displays IP address configuration information.
  • Get-NetRoute
    Displays routing table information.
  • Get-NetAdapter
    Lists all network adapters on the system.
  • Set-NetIPAddress -InterfaceAlias “Ethernet” -IPAddress 192.168.1.100 -PrefixLength 24
    Sets a static IP address for the “Ethernet” interface.
  • Get-DnsClientServerAddress
    Displays DNS server information for the system.

System Configuration and Maintenance

  • Get-EventLog -LogName System
    Displays system event logs.
  • Get-EventLog -LogName Application | Where-Object {$_.EntryType -eq “Error”}
    Displays error events from the Application log.
  • Get-Service
    Lists all services running on the system.
  • Start-Service -Name wuauserv
    Starts the Windows Update service.
  • Stop-Service -Name wuauserv
    Stops the Windows Update service.
  • Get-Command -Module Microsoft.PowerShell.Management
    Lists all commands available in the Microsoft.PowerShell.Management module.
  • Get-Help Get-Command -Full
    Displays detailed help information for the Get-Command cmdlet.
  • chkdsk C:
    Runs a disk check on the C: drive (run with admin privileges).
  • sfc /scannow
    Scans and repairs system files (run with admin privileges).

User Management

  • Get-LocalUser
    Lists all local user accounts.
  • New-LocalUser -Name user1 -Password (ConvertTo-SecureString “password123” -AsPlainText -Force)
    Creates a new user user1 with the password password123.
  • Remove-LocalUser -Name user1
    Deletes the user account user1.
  • Add-LocalGroupMember -Group “Administrators” -Member user1
    Adds user1 to the Administrators group.
  • Set-LocalUser -Name user1 -Password (ConvertTo-SecureString “newpassword123” -AsPlainText -Force)
    Changes the password for user1 to newpassword123.

Drive and Disk Management

  • Get-PSDrive
    Lists all available drives.
  • Get-Volume
    Lists all volumes on the system.
  • Format-Volume -DriveLetter D -FileSystem NTFS -NewFileSystemLabel “NewVolume”
    Formats the D: drive with NTFS and labels it as “NewVolume”.
  • Set-Partition -DriveLetter C -NewDriveLetter Z
    Changes the drive letter of C: to Z:.
  • Resize-Partition -DriveLetter D -Size 100GB
    Resizes the D: partition to 100GB.

Environment and System Variables

  • Get-EnvironmentVariable -Name PATH
    Displays the value of the PATH environment variable.
  • Set-EnvironmentVariable -Name PATH -Value “C:\NewPath”
    Sets the PATH environment variable to C:\NewPath.
  • [Environment]::SetEnvironmentVariable(“MyVar”, “MyValue”, “User”)
    Sets a user-level environment variable MyVar with value MyValue.
  • [Environment]::GetEnvironmentVariable(“MyVar”, “User”)
    Retrieves the value of the user-level environment variable MyVar.

Advanced Commands

  • Select-String “error” C:\log.txt
    Searches for the string “error” in the log.txt file.
  • Get-Content C:\log.txt | Select-String “error”
    Filters the content of log.txt to display only lines containing “error”.
  • Get-Command -Module Microsoft.PowerShell.Management | Export-Csv “commands.csv”
    Exports all available commands in the Microsoft.PowerShell.Management module to a CSV file.
  • Start-Process notepad
    Launches Notepad.
  • Stop-Process -Name notepad
    Stops the Notepad process.
  • New-ScheduledTask -Action (New-ScheduledTaskAction -Execute “C:\Backup\backup.bat”) -Trigger (New-ScheduledTaskTrigger -At 2am -Daily) | Register-ScheduledTask -TaskName “BackupTask”
    Creates and schedules a daily backup task at 2 AM.

Help Commands

Get-Help
Lists all available help topics.

Get-Help Get-Command
Displays help information for the Get-Command cmdlet.

Get-Help -Name Get-Command -Full
Displays detailed help information for the Get-Command cmdlet.

Bash

Basic System Commands

  • clear
    Clears the terminal screen.
  • exit
    Closes the terminal window.
  • echo “Hello World”
    Displays the message “Hello World” in the terminal.
  • date
    Displays the current date and time.
  • date “+%Y-%m-%d %H:%M:%S”
    Displays the current date and time in a custom format (e.g., 2024-12-01 14:30:00).
  • hostname
    Displays the name of the current machine.
  • uname -a
    Displays system information like kernel version and OS.
  • uptime
    Displays how long the system has been running.
  • whoami
    Displays the current logged-in user.

File and Directory Management

  • ls
    Lists the files and directories in the current directory.
  • ls -l
    Lists files in the current directory in long format (permissions, ownership, size).
  • cd /home/user1/Documents
    Changes the current directory to /home/user1/Documents.
  • cd ..
    Moves up one directory level.
  • mkdir newfolder
    Creates a new directory named newfolder.
  • rmdir newfolder
    Deletes the empty directory newfolder.
  • rm file.txt
    Deletes the file file.txt.
  • rm -r directory
    Recursively deletes a directory and its contents.
  • cp file1.txt file2.txt
    Copies file1.txt to file2.txt.
  • mv file1.txt /home/user1/Documents/
    Moves file1.txt to /home/user1/Documents/.
  • rename file1.txt newfile.txt
    Renames file1.txt to newfile.txt.
  • touch newfile.txt
    Creates an empty file named newfile.txt.
  • cat file.txt
    Displays the contents of file.txt.
  • more file.txt
    Displays the contents of file.txt one page at a time.
  • head -n 10 file.txt
    Displays the first 10 lines of file.txt.
  • tail -n 10 file.txt
    Displays the last 10 lines of file.txt.
  • find /home/user1 -name “*.txt”
    Finds all .txt files in the /home/user1 directory.
  • chmod 755 file.txt
    Changes the permissions of file.txt to rwxr-xr-x.
  • chown user1:user1 file.txt
    Changes the owner and group of file.txt to user1.
  • ln -s /path/to/original /path/to/symlink
    Creates a symbolic link.

Network Commands

  • ping google.com
    Sends a network ping to google.com.
  • ifconfig
    Displays network interface configuration (older systems, use ip instead).
  • ip a
    Displays network interface configuration.
  • ip link show
    Displays network interfaces and their states.
  • netstat -tuln
    Lists all listening ports and their associated services.
  • wget http://example.com/file.txt
    Downloads file.txt from example.com.
  • curl -O http://example.com/file.txt
    Downloads file.txt from example.com using curl.
  • ssh user1@hostname
    Connects to a remote server via SSH as user1.
  • scp file.txt user1@hostname:/path/to/destination/
    Copies file.txt to a remote server using SCP.
  • ftp ftp.example.com
    Connects to an FTP server.

Process Management

  • ps aux
    Displays a list of all running processes.
  • top
    Displays a dynamic, real-time view of system processes.
  • kill 1234
    Terminates the process with PID 1234.
  • killall firefox
    Terminates all processes named firefox.
  • bg
    Resumes a suspended job in the background.
  • fg
    Brings a job from the background to the foreground.
  • jobs
    Lists all jobs running in the background or suspended.
  • nice -n 10 command
    Runs command with a lower priority (nice value of 10).
  • renice 10 -p 1234
    Changes the priority of the process with PID 1234 to 10.

User Management

  • whoami
    Displays the current user.
  • id user1
    Displays information about the user user1.
  • adduser user1
    Adds a new user user1.
  • userdel user1
    Deletes the user user1.
  • usermod -aG sudo user1
    Adds user1 to the sudo group.
  • passwd user1
    Changes the password for user1.
  • su user1
    Switches to the user1 account.
  • sudo command
    Runs a command with elevated privileges (as superuser).

System Management

  • df -h
    Displays disk space usage in a human-readable format.
  • du -sh directory
    Displays the total size of a directory (human-readable).
  • free -h
    Displays memory usage (in human-readable format).
  • top
    Displays a dynamic view of system processes.
  • shutdown -h now
    Immediately shuts down the system.
  • reboot
    Reboots the system.
  • systemctl status apache2
    Checks the status of the apache2 service (or any other service).
  • systemctl start apache2
    Starts the apache2 service.
  • systemctl stop apache2
    Stops the apache2 service.
  • systemctl enable apache2
    Enables the apache2 service to start at boot.
  • systemctl disable apache2
    Disables the apache2 service from starting at boot.

Environment and System Variables

  • echo $PATH
    Displays the current value of the PATH environment variable.
  • export PATH=$PATH:/new/path
    Adds /new/path to the PATH environment variable.
  • printenv
    Displays all environment variables.
  • unset VAR_NAME
    Unsets (removes) the environment variable VAR_NAME.

File Permissions and Ownership

  • chmod 755 file.txt
    Changes the permissions of file.txt to rwxr-xr-x.
  • chown user1:user1 file.txt
    Changes the owner and group of file.txt to user1.
  • chgrp group1 file.txt
    Changes the group ownership of file.txt to group1.

Search and Filtering

  • grep “pattern” file.txt
    Searches for the string “pattern” in file.txt.
  • grep -r “pattern” /home/user1/
    Recursively searches for the string “pattern” in the /home/user1 directory.
  • find /home/user1 -name “*.txt”
    Finds all .txt files in /home/user1.
  • sort file.txt
    Sorts the contents of file.txt alphabetically.
  • cut -d ‘,’ -f 1 file.csv
    Extracts the first column of data from file.csv, assuming comma as delimiter.
  • wc -l file.txt
    Counts the number of lines in file.txt.

Help Commands

command –help
Displays help information for a specific command (e.g., ls --help).

man command
Displays the manual for the specified command (e.g., man ls).