What Is the nm Command?
nm is a Linux command that shows the symbols from symbol table of an object file or executable.
In simple words:
nm tells you what functions and variables exist inside a compiled file.
It is commonly used after compilation to inspect what got created inside the object file.
nm file.o
what is symbol?
A symbol is simply a name that represents something in your program.A symbol in C programming is simply the name of a function or global variable that the compiler records inside a compiled file so that the linker and other parts of the system can identify and connect different pieces of code together
That “something” is usually:
- A function
- A global variable
Symbol table
| Symbol | Meaning | Simple Explanation |
| ------ | ------------- | ----------------------------- |
| T | Text (global) | Global function |
| t | Text (local) | Static function |
| D | Data (global) | Global initialized variable |
| d | Data (local) | Static initialized variable |
| B | BSS (global) | Global uninitialized variable |
| b | BSS (local) | Static uninitialized variable |
| U | Undefined | Used but defined elsewhere |
each section meaning
- Text (.text) → Stores functions (code)
- *Data *(.data) → Stores initialized variables
- *BSS *(.bss) → Stores uninitialized variables
- *Undefined *(U) → Function exists, but defined somewhere else
lets under stand by example
#include <stdio.h>
// Global variable
int global_var = 10;
// Static global variable
static int static_var = 20;
// Global function
void global_function() {
printf("Inside global function\n");
}
// Static function
static void static_function() {
printf("Inside static function\n");
}
int main() {
global_function();
static_function();
return 0;
}
compilation stages:
step 1 "compile into object file"
gcc -c file.c
~This file.o is created
step 2 "nm command"
nm file.o
~you can might see someting like this
OUTPUT:
0000000000000000 T global_function
0000000000000000 T main
0000000000000000 t static_function
0000000000000000 D global_var
0000000000000000 d static_var
U printf
Important Note for Beginners
✔️ Global variables → become symbols
✔️ Functions → become symbols
❌ Local variables inside functions → usually NOT symbols
ex:
void func() {
int x = 10; // Not a symbol (local)
}
x is temporary and does not appear in nm.
why local variable are not in output?
Local variables are not shown in nm because they are not needed for linking. The purpose of the symbol table (the one nm shows) is to help the linker connect different files together, and local variables do not participate in that process.Its exists only inside its function, lives temporarily on the stack segment

Top comments (1)
A symbol is the name of a function or global variable saved inside a compiled file so the system can find and connect it during linking.