25 Useful & Not Much Known Linux Commands that you don’t want to miss
These Commands are so Interesting & Effective that you wouldn’t wanna missed it
The terminal commands is a utility of the any operating system. All basic to advanced tasks can be done by executing commands. The commands are executed on the Specific Operating System Terminal. The terminal is a command-line interface to interact with the system. Developers like me, Loves the Command Line and Many computational disciplines, such as bioinformatics, rely heavily on the command line. The Developer may be using Any other operating system like Windows, MacOS, Linux as the development machine operating system and development tools should be consistent across whichever platform they choose. One thing all these platforms have in common is that they all have a command line and it mostly works the same way everywhere.
Command lines are way more flexible and powerful than a GUI, especially when you get into shell scripting or even just piping. Plus it’s faster, since you can just type, instead of having to always switch back and forth between keyboard and mouse.
Advantages of Using Command Line
- Programmability
- Automation
- Flexible
- Powerful
- Chain Commands
- History
- Handle Big Data
- Fast
- Interesting
- Efficient
Command Line is Very Popular in Those users who write their own script. Basically, the command-line is the place where you can create your own functionality in the form of scripts. And what’s most important is that you can use the pipe to join those scripts together. Command Line Users can continue to customize their environments, and therefore improve their own productivity, more or less indefinitely.
Now On the Topic, The Commands which is reason to write this article. The Following Commands are Simple and Interesting, Some of you May be Used it already and Some of Other didn’t even know about those command.
SUDO !!
Run Previous Executed command as SUDO Privilege
sudo !!
DOWNLOAD A FILE AND UNCOMPRESSED IT WHILE IT DOWNLOADING
This command uncompressed any compressed file that you’re downloading from internet at the same time.
wget http://URL/FILENAME.tar.gz -O — | tar xfz -
FIND THE LAST REBOOT TIME
This command will find you system’s last reboot time
who -b
TERMINATE A FROZEN SSH SESSION
This command will Terminate Your System’s frozen SSH Session
RETURN~
BACKUP A REMOTE DATABASE TO YOUR FILE SYSTEM
This command will backup any remote database that you’ve accessed to into your system.
ssh user@host ‘mysqldump dbname | gzip’ > /path/to/backups/db-backup-`date +%Y-%m-%d`.sql.gz
FIND MALWARE IN THE CURRENT DIRECTORY BY MD5 HASHES
This command will find malware in your system’s directory by md5 hashes.
IFS=$'' && for f in `find . -type f -exec md5sum "{}" \;`; do echo $f | sed -r 's/^[^ ]+/Checking:/'; echo $f | cut -f1 -d' ' | netcat hash.cymru.com 43 ; done
SHUTDOWN YOUR WINDOWS MACHINE FROM LINUX
This command will shutdown your windows machine remotely from linux.
net rpc shutdown -I ipOfWindowsMachine -U username%password
DISPLAY TOP 10 RUNNING PROCESSES SORTED BY MEMORY USAGES
This command will display your system’s top 10 running processes sorted by memory usages.
ps aux | sort -nk +4 | tail
PROTECT A DIRECTORY FROM A RM -RF
This command will protect any directory you want from rm -rf command which will delete any directory completely from your system.
cd <directoryname>; touch ./-i
EXIT TERMINAL WITHOUT SAVING HISTORY
This command will exit your running terminal without saving history.
kill -9 $$
DELETE A LINE FROM YOUR SHELL HISTORY
This command will delete a line form your shell history
history -d
BLOCK AN IP ADDRESS FROM CONNECTING TO A SERVER
This command will block any specific IP address from connecting to any of your server.
iptables -A INPUT -s 222.35.138.25/32 -j DROP
LIST YOUR LARGEST INSTALLED PACKAGES
This command will list your system’s largest installed packages.
wajig large
GENERATE A QUICK RANDOM PASSWORD
This command will quickly generate a random password.
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '
I use 30 character password but you can choose any number of character.
RIP AUDIO FROM A VIDEO FILE
This command will rip audio from any video file
mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile <output-file> <input-file>
EXTRACT AUDIO FROM A VIDEO
This command will extract audio from a video file
ffmpeg -i video.avi -f mp3 audio.mp3
SHOW APPS THAT USES INTERNET CONNECTION AT THE MOMENT
This command will show installed software in your system which uses internet connection at the moment.
lsof -P -i -n
COPY AN ELEMENT FROM THE PREVIOUS COMMAND
This command will copy an element from the previous command.
!:1-3
FIND THE FILE IN A DATE RANGE
This command will find any file in a date range.
find . -type f -newermt "2021-01-01" ! -newermt "2021-06-01"
TAKE A SCREENSHOT THROUGH SSH
This command will take a screenshot through SSH.
DISPLAY=:0.0 import -window root /tmp/shot.png
LIST ONLY THE DIRECTORY
This command will list only the directory on your system.
ls -d */
PLAY MUSIC FROM YOUTUBE WITHOUT DOWNLOADING IT
This command will play music video from youtube without downloading it on your system.
wget -q -O - `youtube-dl -b -g $url`| ffmpeg -i - -f mp3 -vn -acodec libmp3lame -| mpg123 -
SAVE HTML PAGE AND CONVERT IT TO A PDF FILE
This command will save HTML page and convert it to a PDF file.
wget $URL | htmldoc --webpage -f "$URL".pdf - ; xpdf "$URL".pdf &
UPDATE TWITTER VIA CURL
This command will update your twitter status via curl.
curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
CREATE A SCRIPT OF LAST EXECUTED COMMAND
This command will create a script of last executed command.
echo "!!" > foo.sh
BINARY DIGIT MATRIX EFFECT
This command is for fun and its create a binary digit matrix effect in your terminal.
perl -e '$|++; while (1) { print " " x (rand(35) + 1), int(rand(2)) }'
CONCLUSION
Some commands are using the extra packages to execute the whole command at once which may be not installed on your system, so install those extra package before executing it.