10 (More) Unknown but Useful Linux Terminal Commands: Since our list of unknown but useful Linux terminal commands has become quite popular, I would like to give you another round of handy Linux one-liners. If used appropriately, these commands will help you do the job quickly and efficiently.

1. A quick way to rename a file:
mv name_of_file.{old,new}
2. Monitoring progress of a particular command:
pv access.log | gzip > access.log.gz
3. Deleting every file in a folder that don’t match a specific file extension
rm !(*.foo|*.bar|*.baz)
4. Removing duplicate entries in a file without sorting:
awk '!x[$0]++'
5. Ripping audio from a video file:
mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile
6. Displaying the Linux distribution name and version:
cat /etc/issue
7. Creating a script of the last executed command:
echo “!!” > foo.sh
8. Extracting tarball from the Internet without saving it locally:
wget -qO – “http://www.tarball.com/tarball.gz” | tar zxvf -
9. Removing all files except the one specified:
rm -f !(never_delete.txt)
10. Editing a file on a remote host using vim:
vim scp://username@host//path/to/name_of_file
As we change the issue file in our shop to display a custom message, the command described in #6 wouldn't work. However, in most Linux distros, this command should work:
ReplyDeletecat /etc/*release
awesome gems you got here.
ReplyDelete