Understanding the Asterisk (*) Suffix in Ubuntu File Listings: Meaning and Technical Implications


1 views

When working with Ubuntu (or any Linux system), you might have noticed an asterisk (*) appearing at the end of certain filenames when using the ll command (which is an alias for ls -alF). This isn't a random decoration - it carries specific meaning in UNIX/Linux systems.

The asterisk indicates that the file is executable. This is part of the -F flag's behavior in the ls command, which appends special characters to indicate file types:


$ ls -F
script.sh*  document.txt  directory/  symlink@

Here's the complete mapping of these indicators:

  • * - Executable file
  • / - Directory
  • @ - Symbolic link
  • | - FIFO (named pipe)
  • = - Socket

Let's create some test files to demonstrate this behavior:


# Create a regular file
touch testfile.txt

# Create an executable file
echo '#!/bin/bash\necho "Hello World"' > script.sh
chmod +x script.sh

# Now list with indicators
ls -F

The output will show:


script.sh*  testfile.txt

Understanding these indicators is particularly important when:

  • Writing shell scripts that process file listings
  • Developing applications that need to identify executable files
  • Troubleshooting permission-related issues
  • Creating build systems or deployment scripts

You can control this behavior through various ls options:


# Show indicators for all file types
ls --classify

# Disable all indicators
ls --indicator-style=none

# Show only executable indicator
ls --indicator-style=file-type

When writing scripts that parse ls output, always account for these suffixes. For example, this bash snippet handles executable files:


for file in *; do
    if [[ "$file" == *\* ]]; then
        echo "Executable found: ${file%\*}"
    fi
done

Alternatively, for more robust file type checking, use:


if [[ -x "$file" ]]; then
    echo "$file is executable"
fi

Be aware that:

  • The asterisk appears only with -F or --classify flags
  • It's purely a display indicator - the actual filename doesn't contain the *
  • Different terminals might show these indicators in different colors

When working with Ubuntu's terminal (specifically version 10.10 and later), you might encounter files displayed with an asterisk (*) appended to their names in ll (alias for ls -l) output. This isn't random decoration - it carries important executable information.

The asterisk appears when:

1. The file has executable permissions (x-bit set)
2. The file isn't a directory
3. The ls command is configured to show this indicator

Modern Ubuntu versions typically use color coding (green text) instead of the asterisk, but the behavior can vary based on:

$ ls -F
script.sh*  data.txt  program*

The asterisk appears due to implicit -F flag behavior in some ls aliases. This flag appends special characters to indicate file types:

*  = executable
/  = directory
@  = symbolic link
|  = FIFO (named pipe)

To understand why you're seeing asterisks:

$ alias ll
Typically shows: alias ll='ls -alF'

To temporarily remove the indicators:

$ \ls -l  # bypasses aliases
$ ls -l --indicator-style=none

When writing scripts that parse ls output:

# Bad practice - fragile parsing
for file in $(ls); do
    [[ "${file: -1}" == "*" ]] && echo "Executable: $file"
done

# Better approach - use test operator
for file in *; do
    [[ -x "$file" && ! -d "$file" ]] && echo "Executable: $file"
done

To modify this behavior system-wide:

# Edit your .bashrc or .bash_aliases
alias ll='ls -alh --color=auto'  # removes -F

This convention dates back to early Unix systems where:

  • Terminals lacked color support
  • Executable indication was crucial for shell scripts
  • Visual differentiation helped prevent accidental execution