Basename Installation On A Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora, Raspbian And MacOS

Basename Installation On A Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora, Raspbian And MacOS

basename

Returns non-directory portion of a pathname.

Maintainer: Michael Stone



Section: utils

Install basename

  • Debian apt-get install coreutils Click to copy
  • Ubuntu apt-get install coreutils Click to copy
  • Alpine OS apk add coreutils Click to copy
  • Arch Linux pacman -S coreutils Click to copy
  • Kali Linux apt-get install coreutils Click to copy
  • CentOS yum install coreutils Click to copy
  • Fedora dnf install coreutils Click to copy
  • Raspbian apt-get install coreutils Click to copy
  • macOS brew install coreutils Click to copy

Returns non-directory portion of a pathname.

How to use basename?

Below are few example commands for basename that you can use in the terminal.

Show only the file name from a path:
basename path/to/fileClick to copy
Show only the file name from a path, with a suffix removed:
basename path/to/file suffixClick to copy
Installation of latest basename command is available for Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora, Raspbian and macOS. You can copy the command for your OS from above and paste it into your terminal. Once you run the command it will download the 2026 latest package from the repository and install it in your computer/server.