The Linux Command Line
History Management
Execute the last command with sudo
sudo !!Recall the last argument of the previous command
!$Recall all arguments of the previous command
!*Execute the last command that started with grep
!grepQuick find-and-replace in the last command
^foo^barGlobal find-and-replace in the last command
!!:gs/foo/bar/Reverse search your command history
Ctrl+RBuilt-in variables
Prints the Process ID (PID) of the current shell
echo $$Prints the PID of the last command you sent to the background
echo $!Prints the exit status of the last command.
echo $?Prints the last argument of the previous command.
echo $_Prints a random integer between 0 and 32767
echo $RANDOMNavigation
Go back to the previous directory you were in
cd -Push the current directory onto a stack
pushd .Pop a directory from the stack and cd into it
popdcd into the path of the last argument
cd $_Networking & Localhost
Pings localhost
ping 0ping localhostIPv6
ping ::1Connect to a local web server on port 8080
curl 0:8080Process & Job Control
Suspend (pause) the currently running foreground process.
Ctrl+ZResume the most recently suspended job in the background
bgBring the most recent backgrounded or suspended job to the foreground
fgList all suspended and backgrounded jobs.
jobsKill job number 1
kill %1base64
Generate MD5 hash
md5sum <file>Generates a SHA256 hash
sha256sum file.txtEncoding
EncodingEncode File + Redirect Output
base64 file.txt > hash.txtEncode String + Redirect Output
echo "your_string_here" | base64 > encoded_file.txtIn
Base64encoding, by default, some implementations add line breaks every 76 characters (following theRFC 2045 standard).
Encode File Without line break
base64 -w 0 <file>Encode String without line breaks
echo -n "your_string_here" | base64 -w 0Safe URL encoding
base64 -w 0 <file> | tr '+/' '-_' > url_safe_encoded.txtDecoding
DecodingDecode String + Output to a file
echo <string> | base64 -d > <file>Decode File + Output to a file
base64 -d -i <file> > <decoded_file>Decode File without line breaks
base64 -d -w 0 file.txt > decoded_output.binChroot
Decrypt the system
Decrypt partition
sudo cryptsetup luksOpen /dev/sda3 cryptdiskMounts the decrypted device
sudo mount /dev/mapper/cryptdisk /mntMounts the boot partion
sudo mount /dev/sda1 /mnt/bootchroot into a mounted partition
sudo arch-chroot /mntConnect using WPA
Connect using WPAShows connection status
wpa_cli statusCreates the passphrase
sudo wpa_passphrase "MyWiFi" "mypassword123" | sudo tee /etc/wpa_supplicant/wpa_supplicant.confConnect using passphrase
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.confBoot/UEFI Management
Boot/UEFI Management Displays the current boot entries in the UEFI firmware
efibootmgrdeletes the boot entry "0"
sudo efibootmgr --delete-bootnum --bootnum 0Last updated