The literal answer is as others have given: because the current directory isn't in your $PATH.

But why? In short, it's for security. If you're looking in someone else's home directory (or /tmp), and type just gcc or ls, you want to know you're running the real one, not a malicious version your prankster friend has written which erases all your files. Another example would be test or [, which might override those commands in shell scripts, if your shell doesn't have those as built-ins.

Having . as the last entry in your path is a bit safer, but there are other attacks which make use of that. An easy one is to exploit common typos, like sl or ls-l. Or, find a common command that happens to be not installed on this system — vim, for example, since sysadmins are of above-average likelyhood to type that.

Does this sound too theoretical? It largely is, but it definitely can happen in reality, especially on multi-user systems. In fact, here is an example from this site where an administrator switched to a users' home directory and found ps to be masked by an executable of that name.

Answer from mattdm on Stack Exchange
🌐
Quora
quora.com › How-do-I-run-a-file-in-terminal-using-Linux
How to run a file in terminal using Linux - Quora
Answer (1 of 6): [code ]./path/to/file/file_name.extension[/code] For the various other possible cases, you’ve provided too little information, which hopefully teaches you to provide context, logs and/or examples.
🌐
Stack Overflow
stackoverflow.com › questions › 35259825 › linux-how-to-run-execute-a-file-in-the-command-line-without-the
linux - how to run/execute a file in the command line without the ./ - Stack Overflow
For example, this is a part of my "$PATH": /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/rany/bin ... After putting an executable script in one of these directories you'll be able to execute it by simply typing its name at the command line.
Discussions

How can i run a downloaded file?

🌐 r/linux4noobs
21
March 9, 2023
you should give more details. you extract the files from the archive, then what to do next totally depends on the files that were in the archive. so extract the files, and give more details. More on reddit.com

How to execute sh files on linux

🌐 r/linux4noobs
6
June 26, 2021
if the file.sh isn't marked executable yet, do a chmod +x file.sh after that, just ./file.sh to run it HTH More on reddit.com

How to run .bin file?

🌐 r/linux
15
September 17, 2013
chmod +x foo.bin ./foo.bin More on reddit.com
Videos
February 26, 2019
5.98K
February 15, 2016
6.94K
🌐
Stack Exchange
unix.stackexchange.com › questions › 4430 › why-do-we-use-dot-slash-to-execute-a-file-in-linux-unix
command line - Why do we use "./" (dot slash) to execute a file in Linux/UNIX? - Unix & Linux Stack Exchange

The literal answer is as others have given: because the current directory isn't in your $PATH.

But why? In short, it's for security. If you're looking in someone else's home directory (or /tmp), and type just gcc or ls, you want to know you're running the real one, not a malicious version your prankster friend has written which erases all your files. Another example would be test or [, which might override those commands in shell scripts, if your shell doesn't have those as built-ins.

Having . as the last entry in your path is a bit safer, but there are other attacks which make use of that. An easy one is to exploit common typos, like sl or ls-l. Or, find a common command that happens to be not installed on this system — vim, for example, since sysadmins are of above-average likelyhood to type that.

Does this sound too theoretical? It largely is, but it definitely can happen in reality, especially on multi-user systems. In fact, here is an example from this site where an administrator switched to a users' home directory and found ps to be masked by an executable of that name.

Answer from mattdm on unix.stackexchange.com
🌐
Wikihow
wikihow.com › computers and electronics › operating systems › linux › how to run files in linux: 9 steps (with pictures) - wikihow
How to Run Files in Linux: 9 Steps (with Pictures) - wikiHow
May 8, 2025 - This wikiHow teaches you how to run files in Linux. You can run most files using a file manager program. Most Linux distributions have a default File Manager that comes pre-installed. You can also use the Terminal to run a file in Linux....
🌐
Living the Linux Lifestyle
livingthelinuxlifestyle.wordpress.com › 2020 › 02 › 09 › how-to-execute-files-in-linux
How to Execute Files in Linux – Living the Linux Lifestyle
February 9, 2020 - Some executable files will run if you click on them in the GUI. Simply open your file manager and double click on the file. If you can’t find the executable file that you’re looking for, it may be hidden, or in a hidden folder. Your file manager probably has a menu item or shortcut to show ...
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › how to execute a shell script in linux
How to execute a shell script in Linux - nixCraft
June 12, 2024 - How do you execute .sh in Linux? Give execute permission to the script: chmod +x /path/to/script.sh To run your script: /path/to/script.sh ./script.sh ... Thanks well explained. ... Very Well explainetion! it really really wonder and it is the best explainetion on the entire inter net.
🌐
Wikihow
wikihow.com › computers and electronics › operating systems › linux › how to execute .run files (& more) in linux: 2 easy ways
How to Execute .RUN Files (& More) in Linux: 2 Easy Ways
3 weeks ago - You can usually find a version of the same application in your package manager (e.g., Ubuntu Software or Apt) or the SNAP store. ... Type chmod +x <filename> and press ↵ Enter. For example, if the file is called installer.run, you'd type chmod +x installer.run.
Find elsewhere
🌐
Gcore
gcore.com › home › developers › how to make a file executable in linux
How to Make a File Executable in Linux | Step-by-step Guide
September 18, 2023 - In the world of Linux, mastering the terminal is a rite of passage for every user. One of the fundamental skills you’ll need is the ability to make a file executable. Whether it’s a custom script or a program you’re testing, knowing how to give it the right permissions is essential.
🌐
Baeldung
baeldung.com › home
Why Do We Use ./ (Dot Slash) To Execute a File in Linux | Baeldung on Linux
March 18, 2024 - Let’s assume we add the current directory to $PATH. If we put “.” as the first path in $PATH, our ls sample file will run instead of the external command ls: ... If we run ls on a system, we want to be sure we’re running the system ls, not another user’s executable file with the name ls.
🌐
Linux Mint Forums
forums.linuxmint.com › viewtopic.php
running executables in terminal
April 21, 2022 - You are being redirected · Javascript is required. Please enable javascript before you are allowed to see this page
🌐
Super User
superuser.com › questions › 48773 › how-to-run-an-exe-from-linux-command-prompt
How to run an .exe from linux command prompt - Super User

try:

abc/info.exe

but if it's really a Windows program, you will need to install "wine", then do:

wine abc/info.exe

but only some Windows programs will work under wine.

Answer from JoelFan on superuser.com
🌐
Reddit
reddit.com › r/linux4noobs › how can i run a downloaded file?
r/linux4noobs on Reddit: How can i run a downloaded file?

you should give more details. you extract the files from the archive, then what to do next totally depends on the files that were in the archive. so extract the files, and give more details.

🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › how-to-run-file-in-linux
How to Run a File in Linux - GeeksforGeeks
December 31, 2024 - In this article, you'll learn how to run different types of files from the Linux command line. In Linux, you can run files using two methods. The first is through the file manager, where you can double-click on executable files to run them. The second is by using the terminal command line, ...
🌐
Plastproinc
demo.plastproinc.com › home › 4+ proven ways to execute files effectively on linux
4+ Proven Ways to Execute Files Effectively on Linux
March 28, 2025 - Running a file on Linux is the process of executing a set of instructions contained within a file. This can be done by typing the name of the file into a terminal window, followed by the Enter key. For example, to run a file named "hello.sh", you would type the following into a terminal window:
🌐
Plastproinc
demo.plastproinc.com › home › 5+ ways to execute a file in linux (with clear examples)
5+ Ways to Execute a File in Linux (with Clear Examples)
March 22, 2025 - Running a file in Linux involves executing a program or script. To do so, you can use the terminal, which is a command-line interface that allows you to interact with the operating system. There are several ways to run a file in Linux, depending on the type of file and your desired outcome.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › run-Unix-shell-script-Linux-Ubuntu-command-chmod-777-permission-steps
How to create and run a shell script in Linux and Ubuntu
It’s pretty easy to run a batch file on Windows. Just create a file, change the extension to .bat, and either call the script in PowerShell or double click to execute it. Windows users are spoiled. Linux users can create and run shell scripts too, with a little more effort.
🌐
Reddit
reddit.com › r/linux4noobs › how to execute sh files on linux
r/linux4noobs on Reddit: How to execute sh files on linux

if the file.sh isn't marked executable yet, do a chmod +x file.sh after that, just ./file.sh to run it HTH

🌐
Ask Ubuntu
askubuntu.com › questions › 38661 › how-do-i-run-sh-scripts
command line - How do I run .sh scripts? - Ask Ubuntu

Give execute permission to your script:

chmod +x /path/to/yourscript.sh

And to run your script:

/path/to/yourscript.sh

Since . refers to the current directory: if yourscript.sh is in the current directory, you can simplify this to:

./yourscript.sh
Answer from karthick87 on askubuntu.com
🌐
KodeKloud
kodekloud.com › blog › linux-run-sh-script
How to Run Shell Script (.sh) Files in Linux
January 7, 2025 - Note that the examples and commands in this blog post are meant to be executed in a Bash shell, which is one of the most common shell environments in Linux distributions by default. Before we explore different methods to run script files, it's essential that we have a script file to work with.
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › how to run the .sh file shell script in linux / unix
How to run .sh file shell script (bash/ksh) in Linux / UNIX - nixCraft
July 17, 2024 - The procedure to run the .sh file shell script on Linux is as follows: ... To run your script : ./script-name-here.sh Another option is as follows to execute shell script: sh script-name-here.sh OR bash script-name-here.sh