My personal cheatsheet for using the Linux command line.
Linux Subsystem
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
List of installed programms
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > C:\Users\Kelly\Desktop\InstalledPrograms.txt
Get Windows License Key
wmic path softwarelicensingservice get OA3xOriginalProductKey
powercfg.bat
powercfg -requests
pause
exit
-
download LineageOS Upgrade
-
download OpenGApps
-
download Magisk
-
Backup
-
reboot to recovery
-
wipe system / cache / dalvik
-
install LineageOS
-
install GApps
-
install Magisk
-
wipe cache / dalvik
-
Power off
-
Reboot manually
dd if=/dev/zero of=/dev/block/bootdevice/by-name/misc bs=256 count=1 conv=notrunc
cp $(ls | grep -i audio) ../TFaudioFiles/
@InLaTeXbot \[\dfrac{df}{dx}=f_{(x)}=\lim_{\Delta{x} \to \infty}\dfrac{f_{(x-\Delta{x}}-f_{(x)}}{\Delta{x}}\]
youtube-dl -x —audio-format mp3 -f bestaudio -l https://www.youtube.com/playlist?list=
-r
for recursive
scp [email protected]:foobar.txt /local/dir
scp -r [email protected]:/home/pi/workspace ./Desktop/
echo "ping" >/dev/udp/$host/$port
.tar.bz2
tar -jxvf file.tar.bz2
.tar.xz
tar xvfJ file.tar.xz
.tar.gz
tar -zxvf file.tar.gz
.gz
gunzip file.gz
Zip something
zip foo foo.zip
Zip recursively
zip -r file.zip directory/
Configure GIT
git config --global user.email "[email protected]"
git config --global user.name "Name Surname"
Commit to master
git init
git add README.md
git commit -m "initial commit"
git remote add origin https://github.com/user/repo.git
git push -u origin master
git pull
git status
git branch
git branch dingsbums
git checkout dingsbums
git git add -A
git commit
git push
(git push --set-upstream origin dingsbums)
To add a new Samba user, you first have to create a new Unix user.
sudo useradd --shell /bin/false USER # new unix user
sudo passwd USER # set password
sudo smbpasswd -a USER # create samba user
lsblk -l #the usb drive
umount /dev/sdX
bs=4MB if=file.iso of=/dev/sdX
Check for how long your SSL certificate remains valid.
openssl x509 -noout -dates -in /etc/letsencrypt/live/yourdomain.tld/cert.pem
sudo grep "Failed password" /var/log/auth.log
sudo cat /var/log/fail2ban.log
Crop a bunch of screenshots and make a PDF.
for f in *.png; do echo "Processing $f file.."; convert $f -crop 1580x254+1+390 $f; done
convert *.png ebssd-HS19-test-3.pdf
convert in.png -crop widthxheight+left+top out.jpg
Nixcraft: How To Compile And Run a C/C++ Code In Linux
Compile a C++ file
g++ CODE.cpp -o BINARY.exe
Compile a C file
gcc CODE.c -o BINARY.exe
Recursively download
wget -r -np -nH —cut-dirs=2 -R index.html http://maven.jzy3d.org/releases/org/jzy3d/
Size of a directory
du -sh DIR/
Recursively copy all files of type
find DIR -iname \*.TXT -exec cp {} DESTINATION \;
find ExampleGame/ -name '*.bnk' -exec cp '{}' ./audio/ \;
Recursively search/find for string/pattern in all files
grep -rnw '/path/to/somewhere/' -e 'pattern'
grep --include=\*.{c,h} -rn -e usart
grep --include=\*.c -rn -e usart
r
or -R is recursive,n
is line number, andw
stands for match the whole word.l
(lower-case L) can be added to just give the file name of matching files.e
is the pattern used during the search
Recursively delete all files of type
Use PowerShell ADB to Android Phone.
cd /storage/3FB1-1D06
find ./Music/ -name "*.jpg" -type f -delete
Copy a file from a remote location via SSH (ssh copy)
(download from remote)
scp user@remote:/path/to/file /path/to/destination
(push to remote)
scp /path/to/file user@remote:/path/to/destination
Random Filename argument
echo `ls dir | sort -R | tail -n 1`
sudo dpkg -i pack.deb
nohup command > /dev/null 2>&1
nmap -F domain.org
ncrack -p 22 --user root -P 'SecLists/Passwords/darkweb2017-top10000.txt' domain.org
- find all files and print their last edited date
- count date occurrances and sort them
find . -name '*.flac' -o -name '*.mp3' -printf "%TY-%Tm-%Td\n" > all-files.txt
sort all-dates.txt | uniq -c | awk '{ print $2 "," $1}' > histogram.csv
SSH tunnel
-D [Bind Port]
-p [Remote Port]
ssh -CnN -D 9999 -p 22 [email protected] # forwards local port 9999 via ssl tunnel
SSH tunnel settings for PuTTY
Connection > SSH > Tunnels :
Source Port: port
☒ Dynamic
☒ Auto
[Add]
Session :
Host Name: server
Port: port
Saved Sessions: name
[Save]
[Load]
cat /dev/urandom | xxd -p -c 92 | lolcat
figlet -c Happy Birthday | lolcat
toilet -f mono12 -F metal Hello
espeak "Hello"
sl
mplayer -vo caca video.mp4