Linux / UNIX Desktop Fun: Steam Locomotive – get train in shell

One of the most common mistake is typing sl instead of ls command. I actually set an alias i.e. alias sl=ls; but then you may miss out the steam train with whistle.

sl is a joke software or classic UNIX game. It is a steam locomotive runs across your screen if you type “sl” (Steam Locomotive) instead of “ls” by mistake. sl is a highly advanced animation program for curing your bad habit of mistyping.

ADVERTISEMENTS

Install sl software to get Steam Locomotive ( train in shell )

Type the following apt-get command/apt command on a Debian / Ubuntu Linux:
$ sudo apt-get install sl
Run the following yum command on a CentOS/RHEL (first enable EPEL repo on a RHEL/CentOS version 6 or version 7 of CentOS/RHEL or enable and install ELEP repo on RHEL 8 or install EPEL repo on CentOS 8):
$ sudo yum install sl
Type the following dnf command on a Fedora Linux:
$ sudo dnf install sl
Execute the following brew command on a macOS Unix desktop:
$ brew install sl
Run the following pkg_add command on a OpenBSD:
# pkg_add -v sl
FreeBSD user type the following pkg command:
# pkg_add -v sl
Arch Linux user try the NA command $ sudo pacman -S sl

Usage

Okay, just mistyped ls command as sl:
$ sl
Run steam locomotive  i.e. get a train in shell when you type sl
Another run:

sl command in action

sl command in action

It also supports the following options:

  • -a : An accident seems to happen. You’ll feel pity for people who cry for help.
  • -l : shows little one.
  • -F : It flies.
  • -e : Allow interrupt by Ctrl+C.

For extra fun try the following little bash for loop along with lolcat command:

for i in a l f o
do
 sl -${i} | lolcat
done
sl command Linux

sl command in Linux

Conclusion

And there you have it, sl displays animations (train in shell) aimed to correct users who accidentally enter sl instead of ls for fun and profit. If you enjoyed this desktop fun app, you may also like to use the following apps on Linux:

๐Ÿง Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
24 comments… add one
  • vamsi May 27, 2011 @ 3:58

    Awesome ๐Ÿ˜‰
    working with ls will be more fun now .

  • Elaine May 27, 2011 @ 13:13

    I installed sl and saw the locomotive, but it didn’t whistle. Bummer.

    • TryMe May 27, 2011 @ 15:27

      Not sure about Linux but on the Solaris boxes it actually made a very loud whistle noise. It sent the audio to the hardware speaker inside the case. It means everyone in the Lab knew that you mistyped ls.. lol!

  • spartan May 29, 2011 @ 6:55

    is fun but no whistle

  • dgarratt May 29, 2011 @ 12:12

    no whistle on fedora 15 ๐Ÿ™ oh well ill makes typo’s more fun!

  • jaysunn Jun 12, 2011 @ 16:44

    SCHAAAAAAAWEEEEET

  • RawShark Jun 19, 2011 @ 14:50

    Confirm no whistle on Ubuntu 10.04 LTS (64 bit)

  • hari prasad k Jul 8, 2011 @ 11:33

    i want to see the code of sl command can i…

  • sathish damodaran suresh Jul 14, 2011 @ 3:00

    @ Hari -> i want to see the code of sl command can i

    Yes you can here are the steps. Execute the following command

    username@Linux-ubuntu:~$ whereis sl
    sl: /usr/bin/sl /usr/share/man/man6/sl.6.gz

    You should get the sl script location -> sl: /usr/bin/sl

    Then you need to navigate to that path

    username@Linux-ubuntu:~$ cd /usr/bin/

    Now execute the below command to view the script

    username@Linux-ubuntu:~$ strings sl
    
    ##################################################################
    ##################################################################
    
    /lib/ld-linux.so.2
    libncurses.so.5
    __gmon_start__
    _Jv_RegisterClasses
    scrollok
    stdscr
    waddch
    noecho
    _fini
    endwin
    _init
    wrefresh
    leaveok
    COLS
    mvcur
    wmove
    initscr
    LINES
    libc.so.6
    _IO_stdin_used
    signal
    usleep
    __libc_start_main
    _edata
    __bss_start
    _end
    GLIBC_2.0
    PTRh
    <Fu
    t-<at"~
    [^_]
    [^_]
    [^_]
    [^_]
    [^_]
    VUUU
    <[^_]
    WVSQ
    Y[^_]
    [^_]
    (   )
    (    )
    (  )
    (@@@)
    (@@@@)
    (@@)
    Help!
    ____________________
    |  ___ ___ ___ ___ |
    |  |_| |_| |_| |_| |
    |__________________|
       (O)        (O)
    
    ____
    |   @@@@@@@@@@@
    |    @@@@@@@@@@@@@_
    |                  |
       (O)       (O)
         ++      +------
         ||      |+-+ |
       /---------|| | |
      + ========  +-+ |
     _|--O========O~-+
    //// _/      _/
     _|--/O========O-+
     _|--/~O========O-+
     _|--/~------/~-+
    //// _O========O
    //// O========O/
    //// O========O_/
        _________________
       _|                _____A
     =|                        |
     -|                        |
    __|________________________|_
    |__________________________|_
       |_D__D__D_|  |_D__D__D_|
        _/   _/    _/   _/
          ====        ________                ___________
      _D _|  |_______/        __I_I_____===__|_________|
       |(_)---  |   H________/ |   |        =|___ ___|
       /     |  |   H  |  |     |   |         ||_| |_||
      |      |  |   H  |__--------------------| [___] |
      | ________|___H__/__|_____/[][]~_______|       |
      |/ |   |-----------I_____I [][] []  D   |=======|__
    __/ =| o |=-~~  /~~  /~~  /~~ ____Y___________|__
     |/-=|___|=    ||    ||    ||    |_____/~___/
      _/      O=====O=====O=====O_/      _/
    
     |/-=|___|=O=====O=====O=====O   |_____/~___/
      _/      __/  __/  __/  __/      _/
    __/ =| o |=-O=====O=====O=====O  ____Y___________|__
    __/ =| o |=-~O=====O=====O=====O ____Y___________|__
     |/-=|___|=   O=====O=====O=====O|_____/~___/
      _/      _O=====O=====O=====O/      _/
    
    ##################################################################
    
  • Ikhwan Maftuh Jun 5, 2012 @ 7:17

    wow it’s cool man… ๐Ÿ˜€

  • Steve Parker Aug 5, 2012 @ 21:09

    @hari prasad k
    cd /tmp/sl
    apt-get source sl

  • Jacob Sep 12, 2012 @ 9:50

    ha ha ๐Ÿ™‚ Perfect example of the fact, that good things can come from beein bored…

  • Monk Sep 29, 2012 @ 9:12

    Okai if you wanna a train whistle / air whistle, create a script as follows:

    #!/bin/sh
    # ~/bin/sl-wrapper.sh
    /usr/bin/aplay -N -q ~/train-whistle.wav &
    /usr/games/sl
    

    aplay is my command line .wav file player and download .wav files here. Now set alias as follows in ~/.bashrc:

    alias sl="$HOME/bin/sl-wrapper.sh"

    You can thank me later ๐Ÿ™‚ .

    • Harrie Baken Apr 6, 2015 @ 15:35

      It’s later now, so thanks, Monk!
      The sound works. On my openSUSE box, I have:

      #!/bin/sh
      # ~/bin/sl-wrapper.sh
      /usr/bin/play -q ~/trein.wav &
      /usr/bin/sl

      But: no colors. What’s more important: the options (-l -F -e -A) don’t work anymore.

  • Shang-Lin Jan 28, 2013 @ 23:38

    You can get the source code from the author’s web page: http://www.tkl.iis.u-tokyo.ac.jp/~toyoda/index_e.html.

  • TGIF Feb 9, 2013 @ 11:56

    And whats even more annoying is when you place in your bashrc:
    alias ls=’sl’
    Place it on a friday afternoon 5pm at a active used server, save, quit and leave for a week or 2 to a sunny location of choice.

    • tom Feb 18, 2015 @ 0:06

      You are a horrible person.

  • David Judik Feb 22, 2013 @ 12:19

    If you want whistle on Mac, you can use Sox, and this script:
    play -q ~/whistle.wav & sl $*
    and after that make an alias to this script.

  • daniel Jan 17, 2014 @ 13:47

    Try doing sl-h its a long one

  • Rodney Feb 7, 2014 @ 20:43

    The -e option to allow ctrl+c does not exist. Source code at https://github.com/mtoyoda/sl/blob/master/sl.c

  • IT Admin Feb 13, 2014 @ 4:32

    Confirm no sound and no colour in Ubuntu 13

  • Selenia Jul 23, 2014 @ 19:32

    Works in Debian Jessie but no whistle. Does not work in root terminal in the default install directory as it installs in /usr/games, whose content mostly should not be setup to run as root anyways. So, quick workaround:
    root@selenia-laptop:/home/selenia# sl
    bash: sl: command not found
    root@selenia-laptop:/home/selenia# whereis sl
    sl: /usr/games/sl /usr/share/man/man6/sl.6.gz
    root@selenia-laptop:/home/selenia# ln -s /usr/games/sl /usr/bin/sl
    root@selenia-laptop:/home/selenia# sl

    Worked on the subsequent sl command as root ๐Ÿ™‚

  • Selenia Jul 23, 2014 @ 19:41

    Actually, more proper workaround when I thought about it for one minute. So I deleted the symbolic link and did this:
    nano /etc/bash.bashrc
    Put this at the bottom of your file or above the http proxy lines(if they exist)
    alias sl=”/usr/games/sl”
    Save the file and type
    bash
    This reloads the config file.
    Now type the command and it should work. Figured this is nicer working in root too for us traditional Debian people who use su for a root terminal with sudo disabled.

  • Aayush Kapoor Dec 10, 2015 @ 12:43

    Confirm no sound on Ubuntu 923523421!

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.