A notebook for Windows folks like me who struggle to remember Linux commands

Before starting

Control options

Operation Command Example
Execute command one by one command1; command2
Execute command1 background command1 & command2
Execute command2 if 1 success command1 && command2
Execute command2 if 1 fail command1 || command2
Reverse the command result !command1

Pipeline options

Operation Command Example
Redirect the output as input to next command1 | command2
Redirect the output and error command1 |& command2

Stream options

Operation Command Example
Give input to a command command < in.txt
Readonly mode to a command command <> in.txt
Redirect the output command > out.txt
Redirect the output and error command > out.txt > error.txt
Redirect the output and override command >| out.txt
Redirect the output and append command >> out.txt
Redirect the output and error command &> out.txt

File Explorer

Operation Command Example
Show Files (List View) ls
Show Files (Detail View) ls -l
Show Hidden Files ls -a
Delete File rm filename
Delete Folder rm foldername -rf
Move File mv filename /some/path
Unzip File tar zxvf ./file.tar.gz
Zip File tar czvf file.tar.gz ./folder
Run as Administrator sudo command
Locate command which ping
View File cat NewDocument.txt
Search Files find . -name '*.txt'(Search *.txt in current folder)
View Folder size du -d 3 -h (3 is depth)
Create File touch file


Operation Pipeline example
Page view cat NewDocument | less
Search in content cat NewDocument | grep something
Count lines cat NewDocument | wc -l
Foreach in lines cat NewDocument | xargs -L1 echo
Convert to base64 echo MyString | base64


Operation Pipeline example
Copy by bytes dd if=filesource of=target


Product Example Note
nano nano config.json use Ctrl to invoke short cuts
micro micro config.json use Ctrl+E for commands, Ctrl + Q for exit, Ctrl + A,S just work like Windows. https://micro-editor.github.io/index.html

Task Manager

Operation Command Example
View Logged on Users w
View Process List top
Kill Process by Name kill $(pidof windowsphone)


Operation Command Example
View my IP Address ifconfig
Download File wget https://some/file.zip
Ping ping bing.com
Check DNS Records dig bing.com


Operation Command Example
GET Url curl -v https://www.baidu.com
POST Url curl -v -d 'abc' https://www.baidu.com
POST JSON curl -v -d '{ }' -H "Content-Type: application/json" https://www.baidu.com
OPTIONS Url curl -v -X OPTIONS https://www.baidu.com

Programs and Features

Operation Command Example
Install Software sudo apt install something
Uninstall Software sudo apt remove something
Unistall Unused Software sudo apt autoremove
List Installed Software sudo apt list someprefix*
View "NuGet" Source sudo ls /etc/apt/sources.list.d
Remove "NuGet" Source sudo rm -i /etc/apt/sources.list.d/PPA_Name.list


Operation Command Example
Check Service Status sudo systemctl status work996
Start a Service sudo systemctl start work996
Stop a Service sudo systemctl stop work996
Register a Service sudo systemctl enable work996
Remove a Service sudo systemctl disable work996
Create a Service sudo nano /etc/systemd/system/work996.service

Example of a custom service:

Description=Work 996

# Restart service after 10 seconds if the dotnet service crashes:



Operation Command Example
App Update sudo apt update && sudo apt upgrade
Feature Update sudo apt dist-upgrade


Auto run commands on start up

sudo nano .profile

Add commands you want to execute, e.g:

# set .NET Core SDK and Runtime path
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

Count total lines of my code

find . -name "*.cs" | xargs -L1 cat | wc -l

Pull all repositories:

find . -maxdepth 2 -mindepth 2 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git pull" \;

Git add only non-white-space changes

git add `git diff -w --ignore-submodules |grep "^[+][+][+]" |cut -c7-`

Test disk write speed

dd if=/dev/zero of=/tmp/tmp count=1 bs=1G

Test transfer speed via SSH

ssh anduin@host 'dd if=/dev/urandom bs=1024000 count=10' | dd of=/dev/null

dd if=/dev/urandom bs=102400 count=10 | ssh anduin@HOST 'cat > /dev/null'

Download file without wget and show downloaded file

curl https://www.baidu.com/ --output - > baidu.html && cat ./baidu.html

Heat the CPU without touching the disk

yes > /dev/null & yes > /dev/null & yes > /dev/null & yes > /dev/null & yes > /dev/null

Get new UUID and convert to base 64

uuid=$(uuidgen) && echo $uuid && mybase64=$(echo $uuid | base64) && echo $mybase64

Get random 4 numbers

cat /dev/urandom | tr -dc '0-9' | fold -w 4 | head -n 1

Keep playing random video under the current folder

while true; do vlc "$(find . -name "*.mp4" | shuf -n 1)"; done

Sync photos with limited folder depth to another folder (Copy but ignore existing)

find "/source" -maxdepth 12345 -not -type d | xargs -i cp -nv '{}' '/target'

Go to Prison

sudo rm / -rvf --no-preserve-root