How do I play files in random order using the mplayer command line player under Linux / Unix operating systems?
You can play most files such as MPEG/VOB, AVI, ASF/WMA/WMV, RM, QT/MOV/MP4, Ogg/OGM, MKV, VIVO, FLI, NuppelVideo, yuv4mpeg, FILM and RoQ files in random order using the following command syntax:
mplayer -shuffle -playlist YOUR-PLAY-LIST-HERE
How Do I Generate a Playlist?
mplayer can play files according to a playlist file type such as ASX, Winamp, SMIL, or one-file-per-line format. You can use the find command to generate a playlist for mplayer:
$ cd /path/to/music/dir
$ find -type f -iname \*.mp3 > playlist.txt
mplayer Shuffle Mode Command
Type the following command:
$ mplayer -shuffle -playlist playlist.txt
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 14 comments… read them below or add one }
Hey look! it’s the bottom of the barrel! I wondered when we would run out of linux commands.
Open a terminal and cd to the directory that has the music files you want to play. next type “mplayer *.*” press enter. Enjoy!!!!
Now, what if i want to skip to the next song? what is the shortcut?
no problem, press enter will bring me to the next song.
Thank you :D
You can also press > and <
Great tips!! Thanks for this beautiful post
how do I enqueue another song while one is already playing?
If only I had found this post earlier…
Great post! Thanks!
Vivek:
I have been wondering how to do what you so wonderfully explained for many years!
Thanks for your help — and thanks for helping the whole Linux/Gnu community!
‘mplayer *’ will do. Perhaps *.* is a relic from dos times :)
relic, lol, I miss dos.. Found another one tho! mplayer */* for your whole collection, it will do all in this directory, and all in one directory down.. I’ve also used mplayer */*/* to play two folders down.. =]
I bet there’s a way to do this without making a playlist.
Seems to work with regular filelists, e.g. mplayer -shuffle * will play files in the current directory in a random order.
Thanks Anonymous, that works for me!