The Art of Using the Command Line
20 curated super bash One-liners commands for your day to day

I love the Linux command line, so I have written several articles where I show tricks and utilities that bring us real utility.
On this occasion, I compile 20 command one-liners that I find especially useful. I hope you like them!
1. Show bios information
With the following command, we can see the Bios information of our computer.
$ sudo dmidecode -t bios
2. Encode and Decode a string in base64
We pass a text using the pipeline operator to the base64 command to encode it and add the “- - decode” flag to decode it to the original value. It’s as simple as that.
$ echo password1 | base64
$ echo xxx | base64 --decode
3. Share a folder quickly using a web server
Using python, we can easily share a folder in a URL.
$ cd $mydir && python3 -m http.server 88884. A simple way to Monitor memory every 2 seconds:
“watch -n X” repeats a command every X seconds and highlights the differences.
$ watch -n 2-d '/bin/free -m'
5. Execute in one step a pull request in all git directories
A quick way to update all our git repositories is to run the following command:
$ for i in */.git; do cd $(dirname $i); git pull; cd ..; done6. Convert a CSV file to Json file
You need to have python installed.
CSV file:

$ cat test.csv | python3 -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))'Json:


7. Display the Linux distribution information
The following command will display all available information about our current distribution, the package management, and the base details:
$ echo /etc/*_ver* /etc/*-rel*; cat /etc/*_ver* /etc/*-rel*
8. Show a notification when a shell command is completed
If we add “;notify-send done” to the end of a command, we will receive a notification when the command completes.
$ ls -l ;notify-send done
9. Execute command without asking for confirmation
If we want to execute a Linux command without being asked for confirmation at each step, we can use “yes” as follows:
$ yes | sudo apt install XXX10. Monitoring CPU speed
The default is every 2 seconds.
$ watch grep \"cpu MHz\" /proc/cpuinfo
11. Find broken symbolic links
If we want to find all the broken symbolic links on our system, we can run the following command:
$ find . -type l ! -exec test -e {} \; -print12. Equivalent to the ENTER key on our terminal
Very useful if, for some reason, the “ENTER” key does not work.
CTRL + m or CRL + j13. Find the process that is using a specific port
Simple and practical, not much more needs to be said.
$ lsof -P | grep ':8080'14. Backup a drive into a file on a remote host via ssh
We do not need to use any tool to create a backup of our disk.
$ dd if=/dev/sda | ssh user@server 'dd of=backup_sda.img'15. One-liner countdown in terminal
We do not need either any third-party application to launch a countdown from the command line and be notified when it reaches zero.
$ for i in `seq 10 -1 1` ; do echo -ne "\r$i " ; sleep 1 ; done ;notify-send ZERO!
16. List the most used commands
With the following command, we can see which have been the most frequently executed commands during the different shell sessions.
$ history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
17. Count files in the current directory, including subdirectories
$ find . -type f | wc -l
18. Remove executable bit
The following command recursively removes the executable bit from all files in the current directory.
$ chmod -R -x+X *19. Simulate the execution of some commands with echo
For example, in this case, we see which files with the .csv extension will be deleted.
$ echo rm *.csv
20. Show all current string values in the ram
A practical way to see the strings we have stored in the RAM.

I hope you found it valuable and entertaining to read. Do not hesitate to try the commands :)
If you liked this post, I think you will like these other posts that talk about the Linux command line:
Any suggestion is always welcome.
