Command Line Reference


🪟 Windows (PowerShell)

CommandFields / FlagsDescription
cdpath (same as Linux)Change directory. Also works with cd ..\Desktop or cd ~Desktop
pwdnonePrint working directory
lspath (optional), same flags as LinuxList directories/files inside the current directory
Get-ChildItemdirectorySame as ls shorthand
mkdirdirectory nameMake a new folder in the current directory
clearnoneClear the current terminal screen
historynoneList of every command you’ve run

Files & Content

CommandFields / FlagsDescription
cpcopied path, pasting path, -Recurse (copy inner contents), -Verbose (confirm copy)Copy a file/folder to another directory. Supports wildcards like *.jpg
mvcopied path/filename, pasting pathMove a file/folder to another location
rmpath of item, -Force (bypass permission prompts)Remove/delete the specified item
catpath of file, -Head (first x lines), -Tail (last x lines)Dump the contents of a file to the screen
morepath of fileDump file contents one screen at a time — good for large files
echo (Write-Output)echo woof > dog.txt (new file)
echo woofTwice >> dog.txt (append)
Create files, write content to them, or print to terminal
sls (Select-String)search string, directory, -Filter (narrow results, supports *.txt)Search for file names, file contents, or other items in the filesystem
Compress-Archivepath to directory, path to new zipped, -pathUsed in order to compress documents via the command line
Expand-ArchiveExpand-Archive -Path C:\Data\Archive.zip -DestinationPath C:\Data\ExtractedUsed to extract the given data in zip file

Help & Info

CommandFields / FlagsDescription
Get-Helpcommand name, -Full (more detail), -Force (show hidden)General help/direction for a given command
Get-Aliascommand nameShow the full PowerShell name for a shorthand command

Diskpart & Managing Disks

CommandFields / FlagsDescription
DiskpartnoneOpens another CLI window that lets you use diskpart and it’s commands
list disknonelists your current disks connected to that OS
select disk xnoneLets you select the disk you are working in
cleannoneCleans / empties out the disk for you
create partition primarynoneCreates a primary partition on your disk current disk
select partition xnoneThis allows you to go into the partition that you just created or went into
activenonemarks your partition as active
formatFS=<filesystem, label=<name>, quickThis basically formats your partition on that drive with the filesystem you want
chkdisk/F, diskBasically, without the /F flag, it will run only in read only mode and report what is wrong on the disk, otherwise it will try and fix the issue

Users, Groups & Permissions

CommandFields / FlagsDescription
Get-LocalUsernoneList every account on the machine, with enabled/disabled status
Get-LocalGroupnoneList all groups on the local machine
Get-LocalGroupMembergroup nameList all users belonging to a given group
Remove-LocalUserusernameRemove a user from the computer/group
net usernet user <username> 'password'Change a user’s password
net usernet user <username> /logonpasswordchg:yesForce password change at next logon
net usernet user <username> * /add or /delAdd or remove a user
icaclspath to file/directoryShow user permissions for that item. Use icacls /? for a key
icaclsicacls 'Path\To\Dir' /grant 'Everyone:(OI)(CI)(R)'Grant permissions (use /remove to revoke)

Networking

CommandFields / FlagsDescription
Test-NetConnectionhost, portNetcat equivalent for Windows
Telnet lookupvaries — search for your specific use caseGo-to tool for diagnosing internet issues on Win11
pscp.exepscp.exe <filepath> user@IPAddressAllows for the use of the Secure Copy Protocol to copy files remotely between desktops
net sharenet share ShareMe=<filepath> /grant:everyone,fullThis creates a shared folder that everyone on the network can access

Windows Update / Package Install Switches

SwitchDescription
/extract <path>Extract package contents to the given folder
/log <path>Enable verbose logging to a log file
/lang:lcidSet UI to a specified locale when multiple are available
/quietRun the package in silent mode
/passiveRun the update with no user interaction
/norestartPrevent prompting the user to restart
/forcerestartForce a restart as soon as the update finishes

Installing & Managing Packages

CommandFields / FlagsDescription
Find-PackageFind-Package sysinternals -IncludeDependenciesBasically helps you to find the given package that you are looking for, and the include dependencies flag also then lets you see the dependencies for that package
Install-PackageInstall-Package -Name sysinternals -Source <sourcename>Used to install a piece of software and it’s given dependencies
Get-PackageGet-Package -name sysinternalsThis basically verifies that the package that you installed is actually on your system
Uninstall-PackageUninstall-Package -Name sysinternalsThis would then uninstall the package

Active Directory Administrative Center Commands

CommandFields / FlagsDescription
New-ADGroup-Description:"desc" -GroupCategory:"Text" -GroupScope"Text" -GroupSamName This creates a new group inside of the current domain you are in inside of the ADAC for a given admin account, see SAIIS - Module 4 - Directory Services for more details about this service
Add-Computer-DomainName 'example.com -Server 'dc1'This will connect a computer to the Active Directory service, which will give it it’s own computer account and configure the computer for AD authentication
Get-AdForestnoneTells you a lot of the information about your Active Directory, including your current version
Get-AdDomainnoneGets information about your domain, including a LOT of its like inner domains, names, and much more, this way you can see what AD features you support
Resolve-DNSName-Type SRV -Name _ldap._tcp.dc._msdcs.DOMAINThis is basically a way to make sure that the current computer that is having trouble logging on to the AD is in fact able to get the needed SRV record to connect to the domain controller
Senv:LOGONSERVERnonecontains the name of the domain controller variable to see what domain controller a given computer is attached to AD by
gpresult/R, /H test.html /s /u /p /r /zPrints out a log of a report that deals with the heal of your AD and whether or not they might be in sync and other information
gpeditnoneThe Group Policy Editor, which is a robust tool for changing Registry settings related to the Control Panel, Settings, user profiles, system configurations, third-party software, and more.
gpupdateCommand that can be used to force a new or edited GPO to be applied immediately using the /force switch.

Managing Windows Processes

CommandFields / FlagsDescription
taskkilltaskkill /pid <processID#>This stops a given process that may be running, can be used if a process is not responding or the ‘x’ button for it is not working. Windows Documentation
tasklistnone (or name probably)shows all of the running processes and their process identification number on your current system
Get-Processnone (or name probably)Does the same thing as tasklist but just inside of Powershell and not the cmd
Get-ProcessGet-Process \| Sort CPU -descending \| select -first 3 -Property ID, ProcessName, CPUBasically a way for you to look for specific items inside of the command line that might be taking up whatever resource you are looking for. You get all the process info, pipe it into Sort with the flags, then with Select you get the first 3, and dictate the data you want displayed
Get-ServiceGet-Service <OptionalServiceName>This would print out the given status, name, and display name of the windows service that you wish to view
Get-ServiceGet-Service <serviceName> \| Format-List *This will showcase more information about any service that you are trying to look for
Stop-Servicethe service nameThis would then obviously stop the service
Start-Servicethe service nameThis starts the service back up again
Set-Service

Miscellaneous

CommandFields / FlagsDescription
Start-TranscriptStart-Transcript -Path C:\path\to\dirThis will start a recording of your current terminal session, and record all of the commands you put in, useful for recording logs of what you are doing
Stop-TranscriptnoneEnds the recording of your CLI for that given session

🐧 Linux (Bash)

CommandFields / FlagsDescription
cdpathChange directory, or cd .. to go back
pwdnonePrint working directory
ls-l, -a, or noneList directory contents in a given format, or include hidden files
dirnoneList all current directories
mkdirdirectory path/nameMake a new directory
clearnoneClear the current terminal screen
historynoneList of every command you’ve run

Files & Content

CommandFields / FlagsDescription
cpcopied path, pasting path, -r (recursive)Copy a file/folder to another directory. Supports wildcards like *.jpg
mvcopied path/filename, pasting pathMove a file/folder to another location
touchfilenameCreate a new file in the current directory
rmpath of itemRemove/delete the specified item
nanofilename/pathOpen the file in the terminal text editor
catpath of fileDump the contents of a file to the screen
lesspath of fileView file contents one page at a time (Windows’ more equivalent)
headpath of fileShow the first 10 lines of a file by default
tailpath of fileShow the last 10 lines of a file by default
echopath (optional)Write to a file (echo "hello" >> file.txt) or print to terminal. Also prints file contents, and can pipe output into another command with \|, e.g. ls -la /etc \| grep bluetooth
dpkgpath of fileUsed to install .deb packages, use -i flag for installation, -r flag for removing, -l for listing all installed packages
7z7z x "nameOfZipped" -o"FolderToBeCreated"used to extract files with the 7-Zip software, note for extraction you use just e not -e, the -o also creates the directory you want to extract to
7 z7z a -sdel archive.7z /path/to/file_or_folderThe a tag lets you archive the given file, the -sdel lets you delete the archiving file while it is being compressed, there is also a -mx=9 which is a maximum compression alg that is better but takes longer
tarpath of fileused to also extract files, check Here for more information
uname-r (kernel version)tells you the current kernel you have
ln-s, filepath, new filepath of linkThis creates a hard or soft link to a given file in basically another file, the -s flag can be used to create a softlink, or it can be left out to create a hardlink
a2ensitesudo an2ensite 001-websitename.confThis is basically just a short cut to manage the available website configurations inside of the /etc/apache2/sites-enabled portion of the apache 2 web service. It also has a2dissite
unrarunrar x archive.rar "/path/to/destination"used for .rar files
CommandFields / FlagsDescription
grepsearch term, locationSearch for file names, directory names, or file contents
mancommand nameManual page for a given command
wcgrep -o "text" file.txt \| wc -lCount occurrences of a word/pattern in a file

Linux Management of Processes

CommandFields / FlagsDescription
htopnoneThe fucking goat, basically gives you a lot of system information about your current proccesses, and allows you to view information about them. Also great for searching through proccesses and killing them
ps-xIt shows you a current snapshot of the processes that you have running on your system, the first thing is the PID, TTY is the terminal associated with the process, next is the process status, cpu time it takes it up
ps-efGets all of the processes from all users, it gives a lot of process details as well, such as PID, PPID, the time, the STIME, and more
killPID, -KILL, -TSTP, -CONTterminates whatever given process you pointed it to with the PID, the -KILL flag is used to terminate the process without giving it time to release it’s resources, the -TSTP flag suspends the process, -Cont then continues that same stopped process
lsofnoneLists all of the open files on the OS and what processes are using them
serviceservice <name> statusThis command allows you to check which background daemons are running on your device
systemctlstatus, start, stop, restart, reload, enableThis i believe is the more modern version of the service command, and is used like this systemctl status <service>
systemctlsystemctl list-unitsThis basically showcases all of the active and inactive services
systemctl list-units --type=service --all

Users, Groups & Permissions

CommandFields / FlagsDescription
sudoany commandRun a command as root/admin
suaccount nameSwitch to that account (sudo su -i switches to root)
passwdusername, -e (expire password, forces change at next login)Change a user’s password
useradd / userdelusername (requires root)Add or delete a user; often paired with -e to expire the password
chmodu/g/o + perms (r, w, x)Change read/write/execute permissions for owner, group, or others
chmodnumeric, e.g. chmod 754 <filepath>Set permissions numerically — 4=read, 2=write, 1=execute (add together, e.g. rwx = 7)
chownusername, filepathChange the owner of a file
chgrpgroup name, filepathChange which group a file belongs to
usermod-h for help bro,theres a lotchange the user that a group is in, their given perms maybe, as well as their given information on the system
catcat /etc/passwdShows all of the given users on a system

Networking

CommandFields / FlagsDescription
pingIP addressTest connectivity with a given address
nc (netcat)host, portScan ports on a network
nslookupDNS site nameTest DNS servers
tracerouteIP addressShow every hop your IP datagram makes
scpscrp <filepath> user@IPAddressTransfers files between computers on the same network
ssh<username>@<IPAddress>Allows you to log into a desktop’s CLI remotely given you have the proper credentials and both devices have SSH installed
digdig www.example.com localhostBasically lets you see more information about DNS queries to your own DNS server? I am not entirely sure what this does
speedtest-clinonetests your download and upload speeds to see your internet metrics
sftpusername@IPBasically lets you transfer files over a network as long as both machines have openssh-server installed, use put sourcepath destinationpath or the same but with get, -r flag for directories DON’T USE QUOTES
tcpdumpsudo tcpdump -i eth0Allows you to monitor given packets on your network, ones incoming to your computer at least. See ISDADDA - Module 4 -Securing Your Networks for more information. For more detailed analysis, use the -v & -n flags, for verbose output and not replacing ip addresses with DNS names
tcpdumpsudo tcpdump -i eth0 -vn host 100.1.4.3 and port 8080 &This would be if you want to retrieve specific packets as the source or destination IP address, so if you want to only get specific packets from that IP

Disks And Partitioning

CommandFields / FlagsDescription
parted-lused to showcase what disks/partitions you might currently have on your system, it also tells you your type of partition table
parted /dev/sdxnoneThis opens up the parted tool for you to be able to manage your disks
printnoneshows you the data for your current drive inside of the parted tool
mklabelgptThis labels your drive with the GPT partition table label
mkparttype of partition, filesystem, start of disk, end of diskThis basically makes a partition on your drive given the following fields typed in
mkfssudo mkfs -t ext4 /dev/sdaBasically make it that specific filesystem
mountfilepath of drive, file of directory to mountMounts a given drive file onto a folder so that way you can start reading and writing data over to those drives
umountfilepath of drive, filepath of directory to unmountUnmounts a given drive file away from a folder
blkidnonegives you the UUID for each of the block / hard drive devices that you have on your computer
mkswapyour swap partitionbasically, since swap is not a file-type system, you have to specifically tell the OS to make it different
swaponswap paritionthis enables this partition as your swap memory
du -hdirectoryshows the disk usage of a given directory
df -hdirectoryused to see how much space you have available on your entire system
fsck-n (no to all), -p (no minor issues), -y (yes to all), -f (fast),make sure that the partition you are trying to run this for is NOT mounted, it might damage the filesystem
wipefs-aclears your drive, overriding it all with unallocated space
HOW TO SET UP A DRIVE
1. sudo wipefs -a /dev/sdb
2. sudo parted /dev/sdb mklabel gpt
3. sudo parted /dev/sdb mkpart primary ext4 0% 100%
4. sudo mkfs.ext4 /dev/sdb1

Proxmox and VM management

CommandFields / FlagsDescription
qm setqm set <VMID> -scsi1 /dev/disk/by-id/<your-disk-id>Points over the id of the HDD that you have plugged into your host hypervisor over to the given ID, letting it be seen by that guest
qm configqm config <VMID>Shows the configurations for that vm
qm -helpnoneshows all of the given inputs for the qm command
nonels -l /dev/disk/by-id/The directory in which the disk id values live, these are used above to mount the disk to a given drive
qm stopqm stop <VMID>stops a vm, also has things like reset start reboot and more
noneqm set 101 -delete scsi1Deletes that given drive entry inside of that vm’s configuration
qm listnoneshows that computers virtual machines, if they’re running, and their ID
smartctl -a /dev/sdb \| grep -i temperaturesmartctl -a /dev/sdb \| grep -i temperatureCheck Drive them, use lsblk to see what the sdx of a drive is

OpenLDAP for Directory Services

CommandFields / FlagsDescription
sudo apt install slapd ldap-utilsnoneBasically installs the ldap services on your given device, you will need to type in an admin password
sudo dpkg-reconfigure slpadnoneThis will let you reconfigure your given settings for LDAP, openldap. org.
ldapaddsomethingTakes in the input of an LDIF file, see SAIIS - Module 4 - Directory Services, and adds the context of the files
ldapmodifysomethingmodifies an existing LDAP object
ldapdeletesomethingremoves the object that the LDIF file refers to
ldapsearchsomethingwill search for entries in your directory database

Miscellaneous

CommandFields / FlagsDescription
scriptscript session.logThis will start a recording of your current terminal session, and record all of the commands you put in, useful for recording logs of what you are doing
ansi2txtcat session.log \| ansi2txt clean_log.txtBasically, the script command stores the data in ANSI format, for a readable format, you can use this to convert the log file to ASCII
ansi 2 htmlansi2html < log > outputfileBasically the same as ansi2txt but instead of ASCII, it converts the ANSI format to html data

😸 Git / Github (CLI)

CommandFields / FlagsDescription
git addgit add . & git add -AThis basically adds all unrecognized files in your current repository to the staging area
git resetgit reset --hard HEADthis basically resets ANY changes in current working directory and can be used to “un-add file(s)” The head one permanently deletes all uncommitted changes in both staging area and working directory
git branchgit branch git branch <newBranch> git branch -d <branchName>This one allows you to mess with branches, the first one lets you see your current list of branches, the second lets you make a new branch, the first deletes a branch
git checkoutgit checkout <branchName>Lets you switch between current branches
git clonegit clone <repoURL>Allows you to copy and online repository over to your local machine
git pullgit pull origin mainThis basically fetches any changes from a remote repository and merges them into your local branch, so you switch to the branch you want to merge with with git checkout and then run this there
git pushgit push origin <branchname>Basically lets you upload your local repository code into the remote repository. generally, the longer way is only done on a first commit connection, you can use git push as long as you’re in the same branch
git versionNONEShows the version of git installed on your machine
git diffgit diff git diff HEAD-1 HEAD git diff <branch1> <branch2>This one shows the different and changes between commits. The first one is between working dir and last commit. The second between last and second-last commit. The last compares specific branches
git revertgit revert HEADThis basically reverts a commit by applying a new commit, and this is a commit that undoes the changes made by the last commit
git configgit config -global user.emal <yourEmail>This basically sets your global email configuration for github which needs to be done before you connect yourself over to the github site for your account
git configgit config -global user.name <yourUser>This, like the email, basically lets you set your username for your github
git remotegit remote -vThis lists the name of all remote repositories associated with your local repository, the -v flag basically gives you the links
git remotegit remote add origin <URL>This allows you to connect over a remote repository to your current local repository, so you can upload changes over to it
git remote renamegit remote rename origin upstreamThe remote rename command is followed by the name of the remote repository you want to rename an the new name (upstream) you want to give it
git remote rmgit remote rm <name>It removes a remote repository with the specified name
git format-patchgit format-patch HEAD-3This generates patches for email submission. These patches can be used for submitting changes via email or sharing them with others
git request-pullgit request-pull origin/main <myFork or BranchName>This basically generates a summary of pending changes for an email request. It helps communicate the changes made in a branch or fork to the upstream repository maintainer
git send-emailgit send-email *.patchIt sends a collection of patches as emails, and allows you to send multiple files to different people via email.
git amgit am <patchfile.patch>This applies patches to the repository, it takes the patch file as input and applies the changes it requires
git daemongit daemon -base-path=/path/to/reposThis exposes repositories with the Git://protocol which is a lightweight protocol designed for efficient communication between Git clients and servers
git instawebgit instaweb -httpd=webrickThis instantly launches a web server to browser repositories. it provides a simple way to view repo contents through a web interface without the need for configuration of a full web-server
git rerereNONEIt resuses recorded resolution of previously resolved merge conflics. You need to enable it using git config --global rerere.enabled true
git switchgit switch <branchName>Allows you to move between branches or even create and switch to a new branch in a simple and easy way
git restoregit restore <file>, git restore -staged <file>, git restore -source <commit> <file>This discards/resets changes in files by restoring them from the staging area or a specific commit
gh auth loginghThis is used to authenticate your Github account inside of the Github CLI, it lets you log in with either the web browser or a token so you can SECURELY use github features

🐳 Docker & Docker-Compose

CommandFields / FlagsDescription
installationcurl -fsSL https://get.docker.com -o get-docker. shDownloads docker into your current directory, basically lets you run the .sh script to get docker up and running
docker--version, compose versioncheck to see if the installation was correct by checking to see your docker versions
docker runhello-worldSets up a small container to test that docker is actually working and can run containers, also showcases sort of how docker works
docker composedocker compose up -dThis will run the docker image after editing the yaml
docker psnoneThis will verify if a container is running :3
docker restartthe given docker container name or idRestarts the container (obviously)
docker stats --no-stream obsidian-natanBasically a way to see the CPU and RAM usage of a given container
readread -s -p "Enter CouchDB admin password: " COUCHDB_PASSBasically a way to set up variable values in bash
docker restartdocker restart $(docker ps -a -q)restart all containers running at once
docker imagesnoneLists all of the given images made from DockerFiles in your computer
docker pushdockr push <yourappname>This stores images in a configured registry, letting you pull them later on other devices
docker pulldocker pull nginxThis lets you pull images from that exact registry
docker builddocker build -t <appname> /path/to/dockerfileThis here builds an image from a DockerFile in a specific directory
docker container rmdocker container rm <containername>Removes a given container from your system
seeDocker Compose and yaml Setupsfor more reference on containers and configs
seeCDKO - Module 1- Containers and ContainerizationFor how to set up something like a DockerFile and how they work and play and all of the good stuff

Kubectl / Kubernetes

  • Pasted image 20260906215530.png
CommandFields / FlagsDescription