A very interesting bash shell trick. Edit the last command in the history.
How to use the !! operator to perform a very nice bash shell trick. This is how to edit the last command in the history and edit a spelling mistake.
How to use the !! operator to perform a very nice bash shell trick. This is how to edit the last command in the history and edit a spelling mistake.
Get the IPv6 address of a website very easily with this simple one-liner. jason@. PWD: ~. -bash. 3.2.57. 29 $> host ipv6.google.com | awk ‘FNR==2 {print $5}’ 2404:6800:4006:811::200ejason@. PWD: ~. -bash. 3.2.57. 29 $> host ipv6.google.com | awk ‘FNR==2 {print $5}’ 2404:6800:4006:811::200e This works just fine to get the required information. I am not sure … Read more
Setting up your BASH prompt. A nice BASH shell prompt. This shows the current time and the current folder you are in as well as a full directory path if you are in a subfolder. PS1="-\t– \u@\h [\w]\$ "PS1="-\t– \u@\h [\w]\$ " How to set the contents of the Xterm title bar. Using the PROMPT_COMMAND … Read more
This is a very useful Bash shell script, this will create a Webm clip from a movie. This shows how to get parameters in a Bash script easily. #!/bin/bash while [[ "$#" -gt 0 ]]; do case $1 in -f|–filename) filename="$2"; shift ;; -t|–timestamp) timestamp="$2"; shift ;; -o|–outfile) outfile="$2"; shift ;; *) echo "Unknown … Read more
This simple command-line will create a new user on Linux named test5. ┌──[[email protected]]─[~] └──╼ ╼ $ sudo useradd test5 -m -K PASS_MAX_DAYS=5 -K PASS_WARN_AGE=3 -K LOGIN_RETRIES=1┌──[[email protected]]─[~] └──╼ ╼ $ sudo useradd test5 -m -K PASS_MAX_DAYS=5 -K PASS_WARN_AGE=3 -K LOGIN_RETRIES=1 Then set a password for the new user. ┌──[[email protected]]─[~] └──╼ ╼ $ sudo passwd test5 New … Read more
An obfuscated command like this is an example of one that you should never run. ┌──[[email protected]]─[~] └──╼ ╼ $ echo "ZWNobyBIYWhhaGFoYWhhaGFoYWhhaGFoYWhhaGFoYWhhaGFoYWhhaGFoYWhhaGFodG91Y2ggLS1mdWNreW91ISA+PiAtZnVja3UhCg==" | base64 -d | sh -s┌──[[email protected]]─[~] └──╼ ╼ $ echo "ZWNobyBIYWhhaGFoYWhhaGFoYWhhaGFoYWhhaGFoYWhhaGFoYWhhaGFoYWhhaGFodG91Y2ggLS1mdWNreW91ISA+PiAtZnVja3UhCg==" | base64 -d | sh -s This is the actual command it will run, this creates a file named “-fucku!”. But this can … Read more
How to delete a file with a strange filename This can be an annoying trick to play on someone. Create a file named -f with this command: >-f and then ask them to delete it with the command line only. This can be frustrating exercise; you try to use rm \-f and that does not … Read more
How to best view all available terminal colours This one-liner will print out all available terminal colours for your chosen Linux terminal application. This is very useful for creating a colourful bash prompt and the user wishes to know which colour codes will work and look good in the terminal. for x in {0..8}; do … Read more
Printing information about the weather on the command line is quite easy on Linux. One way is using the finger(1) command to retrieve a forecast for a certain city. ┌──(john㉿DESKTOP-PF01IEE)-[~] └─$ finger [email protected] -= Meteogram for Sydney, New South Wales, Australia =- ‘C Rain (mm) 25 24 23 ^^^ 22 ===^^^^^^ ===^^^ 21=== ^^^=–=–=–=–=– 20 … Read more
Useful bash shell shortcut keys to navigate the command line ^a, ^e – Move the cursor. The ^-a shortcut will move the cursor to the beginning of the line. The ^-e shortcut will bring the cursor to the end of the line. ^d – End of file or EOF. This tells a console application that … Read more
This is a very cool Linux one-liner, this is using the Tesseract OCR engine to read an image generated by a script and then read the time from it. ┌──[[email protected]]─[~/Pictures/letter] └──╼ ╼ $ curl -s ‘https://securitronlinux.com/api/servers.php’ -o – | tesseract stdin stdout –dpi 150 | grep –color CDT 05:33:13pm Sun Aug 22, 2021 CDT┌──[[email protected]]─[~/Pictures/letter] └──╼ … Read more
If you’ve ever piped the output of one command into the input of the other or joined simple commands together to do complex tasks, then you have a taste for the power of the shell. As you use the shell more and more you’ll discover how powerful it is and that, more often than not, … Read more
If you’ve ever piped the output of one command into the input of the other or joined simple commands together to do complex tasks, then you have a taste for the power of the shell. As you use the shell more and more you’ll discover how powerful it is and that, more often than not, … Read more
This one-liner will take your IP address and convert it into binary. This is very useful and fun to do. ┌──[[email protected]]─[~/Videos] └──╼ ╼ $ ipcalc `ip a | awk ‘/inet / { print $2 }’ | sed -n 2p | cut -d "/" -f1` | awk ‘/Address/ {print $3,$4}’ 11000000.10101000.00000001. 00000010┌──[[email protected]]─[~/Videos] └──╼ ╼ $ ipcalc … Read more
There are many ways to use the bash shell on Linux. It has different key binding options and the ability to navigate to a directory by typing the name alone. set -o vi bind -m vi-insert "\C-l":clear-screenset -o vi bind -m vi-insert "\C-l":clear-screen This will enable VIM styled keybindings for the bash shell. Press ESC, … Read more
This simple command will search for a folder named xray* and then switch to it. ┌──[[email protected]]─[~/Documents] └──╼ ╼ $ cd $(find . -type d -name "xray*")┌──[[email protected]]─[~/Documents] └──╼ ╼ $ cd $(find . -type d -name "xray*") After running this command, it has found a folder that matches the wildcard and then switched to it. ┌──[[email protected]]─[~/Documents/xray-16] … Read more
There are many ways to get detailed information on known users on your Linux system. The lslogins command is therefore very useful for listing all usable login accounts. The below example will list all user accounts including the root account. This might be disabled on an Ubuntu system, but it is worth listing it anyway. … Read more
Show a preview of a directory as you cd into it. c() { cd "$@" ls_truncate=20 files=$(ls -F -C –color=always) files_num=$(echo "$files" | wc -l) echo "$files" | head -n $ls_truncate [ $(echo "$files" | wc -l) -gt "$ls_truncate" ] && echo "(Ommited $((files_num-$ls_truncate)) files/directories)" }c() { cd "$@" ls_truncate=20 files=$(ls -F -C –color=always) files_num=$(echo … Read more
Finding files in your home directory is very easy. The command below will search inside all files in your home directory and find all files that contain the text “linux”. find . -type f -exec grep -niH linux ‘{}’ ‘;’find . -type f -exec grep -niH linux ‘{}’ ‘;’ This is a good example of … Read more
Generating a password with the Linux command line is very easy with data from /dev/urandom. This allows a user to retrieve random data easily. The example below shows a password being generated only using letters and numbers. ┌──[[email protected]]─[~] └──╼ ╼ $ tr -dc "0-9A-Za-z" < /dev/urandom | head -c 96 ; echo gOApOMzRqqbmvUjxT7esfJcKW58PxxXqYDwCVvd628OsEa1yyfLADADJQ8YBZFdWZQkCXCRDKCPncSsC20OOjHxklnaxEbJF┌──[[email protected]]─[~] └──╼ ╼ … Read more