Skip to content
Jassweb
  • Home
  • Company
    • About Us
    • Portfolio
    • Blog
    • Career 
  • Services
    • SEO
    • Digital Marketing
    • Web Design & Development
    • E-commerce Solutions
    • Fix Broken Website
    • Website Maintenance
    • Web Hosting & Manage Server
    • Enterprise Automation Solutions
    • Full-Stack SaaS Development
    • Coolify Automation Plugin
  • Shop
  • Tools
  • My Account
    • Cart
    • Checkout
    • My Bookings
      • Appointment canceled
      • Appointment reschedule
  • Contact Us

basename Linux Commands – Overview with Examples and FAQs

March 10, 2023March 9, 2023 by Jass Web

Introduction

The Linux command basename is a utility that is used to strip directory and suffix from filenames. It is a very useful command for extracting the filename from a given pathname. It can also be used to extract the suffix from a filename. This command is available in most Linux distributions and is a part of the GNU Core Utilities package. It is a very useful tool for manipulating filenames and can be used in a variety of ways.

Examples

The basename Linux command is used to strip directory and suffix from filenames. It returns the filename without any leading directory components.

Syntax:

basename [OPTION]… NAME [SUFFIX]

Example:

$ basename /usr/local/bin/bash

bash
[ad_1]

[ad_2]

Linux Command: Basename

The basename command is a Linux utility used to strip directory and suffix from filenames. It is used to extract the filename from a given pathname. It is a standard Unix program and is included in most Linux distributions.

The syntax for the basename command is as follows:

basename [OPTION]... [NAME]...

The options for the basename command are as follows:

  • -a, –multiple : Treat each NAME as a separate argument, even if it contains spaces.
  • -s, –suffix : Remove a trailing SUFFIX; implies -a.
  • -z, –zero : End each output line with NUL, not newline.

The basename command is useful for extracting the filename from a given pathname. For example, if you have a file located at /home/user/myfile.txt, you can use the basename command to extract the filename myfile.txt from the pathname.

The basename command is a useful tool for scripting and automation tasks. It can be used to extract filenames from a list of pathnames, or to strip off a suffix from a filename.

Categories Linux Commands Tags adduser or addgroup, agetty, alias, anacron, apropos, apt, apt-get, aptitude, arch, arp, at, atq, atrm, awk, basename, batch, bc, bg, bzip, cal, cat, chgrp, chmod, chown, cksum, clear, cmp, comm, cp, date, dd, df, diff, dir, dmidecode, du, echo, eject, env, exit, expr, factor, find, free, grep, groups, gunzip, gzip, head, history, hostname, hostnamectl, hwclock, hwinfo, id, ifconfig, ionice, iostat, ip, iptables, iw, iwlist, kill, killall, kmod, last, Linux, ln, locate, login, ls, lscpu, lshw, lsof, lsusb, man, mdsum, mkdir, more, mv, nano, nc/netcat, netstat, nice, nmap, nproc, openssl, passwd, pidof, ping, ps, pstree, pwd, rdiff-backup, reboot, rename, rm, rmdir, scp, shutdown, sleep, sort, split, ssh, stat, su, sudo, sum, tac, tail, talk, tar, tee, time, top, touch, tr, tree, uname, uniq, uptime, users, vim or vi, w, wall, watch, wc, wget, whatis, whereis, which, who, xargs, yes, youtube-dl, zcmpor zdiff, zip, zz
batch Linux Commands – Overview with Examples and FAQs
bc Linux Commands – Overview with Examples and FAQs
© 2026 Jassweb • Built with GeneratePress