What Does Basename Mean?

A basename is the name of a directory in a Unix pathname that occurs after the last slash. It is also the name of a standard utility on Unix-like systems that returns the basename when given a Unix pathname. This program is part of the Single Unix Specification and installed on nearly every system, including most Linux distributions.


Techopedia Explains Basename

A basename is the last directory in a Unix path after the last slash. For example, in the pathname /usr/share/techopedia, the basename would be “techopedia.” There is also a utility called basename that returns the basename of a directory when given a pathname. It is frequently used in shell scripts for convenience. The major scripting languages, including Perl and Python, also have the capability to generate basenames through libraries.

A companion utility, dirname, returns everything but the final basename in a pathname. Both of these utilities are part of the Single Unix Specification. Even though Linux is not part of the Single Unix Specification, almost all distributions include dirname and basename as part of GNU Coreutils. Similarly, the free BSD systems also include these utilities.


Related Terms

Latest Privacy and Compliance Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…