This is a cheat sheet that highlights most commonly used commands in Windows and Linux. There are key differences between Windows and Linux commands that you should be aware like:
Linux Commands:
ls
- Lists the files and directories in the current directorycd
- Changes the current directorycp
- Copies one or more files to another locationrm
- Deletes one or more filesmv
- Moves one or more files to another locationmkdir
- Creates a new directoryrmdir
- Deletes an empty directory
Windows Commands:
dir
- Lists the files and directories in the current directorycd
- Changes the current directorycopy
- Copies one or more files to another locationdel
- Deletes one or more filesmove
- Moves one or more files to another locationmkdir
- Creates a new directoryrmdir
- Deletes an empty directory
An exhaustive list of all Linux and Windows with example can be found below:
Linux vs Windows cheat sheet
This is a great resource which can be used as a guide or a reference for begginners or advanced Linux and Windows users:
|
|
Windows |
Linux |
||||
Type |
Description |
Command |
Example |
Result |
Command |
Example |
Result |
General |
Logoff |
shutdown |
shutdown -l |
|
reboot |
reboot |
|
Restart |
shutdown |
shutdown -r |
|
logout |
logout |
|
|
Shutdown |
shutdown |
shutdown -s |
|
poweroff |
poweroff |
|
|
Show user |
echo %USERNAME% |
echo %USERNAME% |
user |
echo |
echo $USER |
user |
|
Install application |
|
|
|
apt-get |
sudo apt-get install ${package} |
|
|
Remove application |
|
|
|
apt-get |
apt-get remove ${package} |
|
|
Zip/unzip current folder |
zip |
zip -r file.zip folder |
|
unzip |
sudo apt-get install zip unzip |
|
|
Connect ssh |
You need putty client |
plink [email protected] -P 33 |
|
ssh |
ssh [email protected] -p 33 |
|
|
List mounted devices |
net use |
net use |
|
findmnt |
findmnt -lo source,target,fstype,label,options
-t ext4 |
|
|
Mount Remote |
net use |
net use \\Server\ShareFolder |
|
mount |
mount 192.168.1.1:/home /mnt/nfs/home |
|
|
Show network info |
ipconfig |
ipconfig /all |
Windows IP Configuration |
ifconfig |
ifconfig |
eth0 Link encap:Ethernet HWaddr |
|
Execute script |
|
test.cmd |
|
./ |
./test.sh |
|
|
History |
F7 |
F7 |
0: dir |
history |
history |
1 ls |
|
Go to previous command |
↑ or F8 |
F8 or ↑ |
|
↑ |
↑ |
|
|
Search for commands |
|
|
|
CTRL+R |
CTRL+R and type the command |
|
|
Clears screen |
cls |
cls |
|
clear |
clear |
|
|
Closes shell prompt |
exit |
|
|
exit |
exit |
|
|
Displays or sets date |
date |
|
|
date |
date |
|
|
Displays command help |
command /? |
dir /? |
|
info |
man command |
|
|
Displays command help 2 |
help command |
help dir |
|
man |
info command |
|
|
Autocompletion |
TAB |
TAB |
|
TAB |
TAB |
|
|
Uptime and logged user |
quser |
C:\Users\user\Desktop>quser |
USERNAME;SESSIONNAME;ID; |
uptime |
uptime |
06:18:56 up 75 days, 17:31, 1 user,
load average: 0.00, 0.00, 0.00 |
|
Files & |
Show current folder |
cd |
cd |
C:\Users\user |
pwd |
pwd |
/home/user |
Show current folder 2 |
chdir |
chdir |
C:\Users\user |
echo |
echo $PWD |
/home/user |
|
Create file |
copy NUL file1.txt |
|
|
touch |
touch file.txt |
|
|
Create file |
echo. 2>file2.txt |
|
|
cat |
cat > myfile.txt |
|
|
Renames a file |
ren |
ren file1.txt file2.txt |
|
mv |
mv tfileold.txt filenew.txt |
|
|
Copies files |
copy |
copy file1.txt C:/foldercopy |
|
cp |
cp file.txt /home/foldercopy |
|
|
Moves files |
move |
move file1.txt C:/newfolder |
|
mv |
mv file.txt /home/newfolder |
|
|
Lists files |
dir |
|
|
ls |
ls |
|
|
Collect file names |
dir |
dir "C:\" >FilesC.txt /b /o |
file1 |
find |
find /home -name '*' |
/home/file1 |
|
Deletes files |
del |
del deleteme.txt |
|
rm |
rm deleteme.txt |
|
|
Deletes folder |
rmdir |
rmdir /S deleteme |
|
rm -r |
rm -r deleteme |
|
|
"Echoes" output to the
screen |
echo |
|
|
echo |
echo this message |
|
|
Delete file content |
type |
type nul
> file.txt |
|
cat |
> file.txt |
|
|
Compares the contents of files |
fc |
fc file1.txt file2.txt |
Comparing files file1.txt and
file2.txt |
diff |
diff file1.txt file2.txt |
|
|
Finds a string of text in a file |
find |
find "test" 123.txt |
|
grep |
grep test file1.txt |
test line |
|
Displays help |
command /? |
dir /? |
|
info |
man command |
|
|
Displays help 2 |
help command |
help dir |
|
man |
info command |
|
|
Creates a folder |
mkdir |
mkdir newfolder |
|
mkdir |
mkdir directory |
|
|
View file content |
more |
more file1.txt |
|
less |
less file1.txt |
|
|
View file content 2 |
type |
type file1.txt |
|
tail |
tail -n 15 file1.txt |
|
|
Edit file |
edit |
edit file1.txt |
|
vi |
vi file.txt |
|
|
Changes directories with a
specified path (absolute path) |
cd |
cd C:/ |
|
cd |
cd /directory/directory |
|
|
Go one folder |
cd |
cd .. |
|
cd |
cd .. |
|
|
Search for a file |
dir |
dir /s *test* |
07/31/2010 02:30 AM 301 test.png |
find |
find / -name '*test*' |
/home/test.txt |
|
Search for text files |
dir |
dir /b/s *.txt |
|
find |
find / -name '*.txt' |
|
|
Change files extension to lower |
ren |
ren *.TXT *.txt |
|
mv |
for i in $( ls
*.TXT ); do echo $i; mv $i ${i%%.TXT}.txt;
done |
|
|
Check files permissions |
|
|
|
ls |
ls -l /home/user |
"-rwxr-xr-x 1 root root 53 Mar 23
2015 /home/user" |
|
Change Permissions |
|
|
|
chmod |
chmod 755 file |
|
|
Changing ownership |
|
|
|
chown |
chown user file |
|
|
Changing group ownership |
|
|
|
chgrp |
chgrp group file |
|
|
Other |
Displays the date |
date |
date /T |
Wed 07/05/2017 |
date |
date '+%d %W %Y' |
05 27 2017 |
Displays the time |
time |
time /T |
1:27 PM |
date |
date '+%X' |
12:18:22 PM |
|
Shows amount of RAM in use |
wmic |
wmic OS get FreePhysicalMemory
/Value |
|
free |
free |
|
|
Show disk space |
wmic |
wmic logicaldisk
get size,freespace,caption |
|
dh |
dh -f |
|
|
Show processes |
tasklist |
tasklist |
|
top |
top |
|
|
Services |
Stop execution |
CTRL+C |
CTRL+C |
|
CTRL+C |
CTRL+C |
|
Start service |
net |
net start [serviceName] |
|
service |
sudo service [serviceName] start |
|
|
Stop service |
net |
net stop [serviceName] |
|
service |
sudo service [serviceName] stop |
|
|
Start service 2 |
sc |
sc start [serviceName] |
|
systemctl |
sudo systemctl start [serviceName] |
|
|
Stop service 2 |
sc |
sc stop [serviceName] |
|
systemctl |
sudo systemctl stop [serviceName] |
|
|
Variables |
Display all variables |
set |
set |
USERNAME=user |
printenv |
printenv |
HOME=/home/user |
Display variable |
echo |
echo %USERNAME% |
user |
echo |
echo $HOME |
/home/user |
|
Display variable 2 |
set |
set USERNAME |
USERNAME=user |
printenv |
printenv | grep |
HOME=/home/user |
|
Set variable |
set |
set MYVAR=VALUE |
|
export |
export MYVAR=/path/to/var |
|
|
Set variable permanent |
setx |
setx MYVAR VALUE |
|
change profile |
vi ~/.bash_proflle |
|