In Linux, any special character can be literally inserted on the terminal by pressing Ctrl+v followed by the actual symbol. null is usually ^@ where ^ stands for Ctrl and @ for whatever combination on your keyboard layout that produces @.

So on my keyboard I do: Ctrl+v followed by Ctrl+Shift+@ and I get a ^@ symbol with a distinguished background color. This means it's a special character and not just ^ and @ typed in.

Edit: Several years later and a few input variations implemented by different terminals using keyboard layouts that require pressing Shift to access @.

  • Ctrl+v followed by Ctrl+Shift+@
  • Ctrl+v followed by Shift+@ without releasing Ctrl.
  • Ctrl+Shift+v followed by @ without releasing Ctrl+Shift.
  • Ctrl+Shift release Shift and re-press Shift keeping both Ctrl+Shift pressed followed by v and finally @. Seen in some terminals that implement a special input on Ctrl+Shift.
Answer from unode on Stack Overflow
๐ŸŒ
Baeldung
https://baeldung.com โ€บ home โ€บ scripting โ€บ zero null character and typing or inserting null in the terminal
Zero NULL Character and Typing or Inserting NULL in the Terminal | Baeldung on Linux
March 18, 2024 - The null, NULL, \0, or <NUL> is an important character and value in almost any operating system (OS) and computing in general. However, itโ€™s not part of the keys on a regular keyboard, so we rarely have a direct way to type or even insert it.
Discussions

How can I type the null sign?
How can I type the null sign, the symbol looking like a zero with a slash through it. More on learn.microsoft.com
๐ŸŒ learn.microsoft.com
2
71
June 20, 2020
How can I type the null sign?
How can I type the null sign, the symbol looking like a zero with a slash through it. More on answers.microsoft.com
๐ŸŒ answers.microsoft.com
2
71
June 21, 2020
How to simulate NUL character from keyboard? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. Can we type NUL character (HEX 0) from the keyboard? Most of the printable character starts from HEX value 20. ... NULL is a (control) character, ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
bash - Using/reading/writing the null and escape characters - Unix & Linux Stack Exchange
Instead zsh acts as 'c code', an string ends where a null exists. ... echo -ne '\0' outputs a 0 byte in all the echo implementations that support that syntax. It's just that the NUL character, for a terminal, is a control character, the control character that does nothing (for instance it's used sometimes for slowing down the flow of character on a serial line without flow control to let the terminal (like tele-typewriters ... More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
August 17, 2015

In Linux, any special character can be literally inserted on the terminal by pressing Ctrl+v followed by the actual symbol. null is usually ^@ where ^ stands for Ctrl and @ for whatever combination on your keyboard layout that produces @.

So on my keyboard I do: Ctrl+v followed by Ctrl+Shift+@ and I get a ^@ symbol with a distinguished background color. This means it's a special character and not just ^ and @ typed in.

Edit: Several years later and a few input variations implemented by different terminals using keyboard layouts that require pressing Shift to access @.

  • Ctrl+v followed by Ctrl+Shift+@
  • Ctrl+v followed by Shift+@ without releasing Ctrl.
  • Ctrl+Shift+v followed by @ without releasing Ctrl+Shift.
  • Ctrl+Shift release Shift and re-press Shift keeping both Ctrl+Shift pressed followed by v and finally @. Seen in some terminals that implement a special input on Ctrl+Shift.
Answer from unode on Stack Overflow
๐ŸŒ
Wikipedia
https://en.wikipedia.org โ€บ wiki โ€บ Null_character
Null character - Wikipedia
October 10, 2026 - A null-terminated string is a commonly ... uses a null character to indicate the end of a string. This design allows a string to be any length at the cost of only one extra character of memory. The common competing design for a string stores the length of the string as an integer data type, but this ...
๐ŸŒ
LinuxVox
https://linuxvox.com โ€บ blog โ€บ type-null-character-in-terminal
How to Type Null Character in Terminal: Easy Methods and Examples โ€” linuxvox.com
Press Ctrl + V (this tells the terminal to โ€œescapeโ€ the next key, treating it as a literal character). Immediately press Ctrl + @ (on US keyboards, @ is Shift + 2, so this is often Ctrl + Shift + 2). If youโ€™re in a Python interactive shell ...
Find elsewhere
Top answer
1 of 4
20

Printing the null character

On many recent shells you can write null character with dollar single quotes format $'\0', hexadecimal format \x00, unicode format \u0000 or \U00000000, or just as you tried with octal: '\0'. The point is that the command has to understand what to do with backslash-escaped characters. For example in case of echo usually one needs to add -e option and in case of printf that would be %b.

Let's check if it works:

$ echo -ne '\0'
$

So produces nothing, just like echo -ne '', similar

$ printf '%b' '\0'
$

Let's add some characters around (I will stick with printf '%b' from now on as more robust, but similar effect is with echo -ne):

$ printf '%b' a'\0'b
ab

Only two characters were printed, where did the null go?

$ printf '%b' a'\0'b | wc -c
3

Let's compare it with a''b:

$ printf '%b' a''b | wc -c
2

Last more check that we really print null character before trying to create file, let's pass the printed value to the command which will throw the error, like xargs:

$ printf '%b' a'\0'b | xargs echo
xargs: Warning: a NUL character occurred in the input.  It cannot be 
passed through in the argument list.  Did you mean to use the --null option?
a

Notice how only a was printed at the end. Of course xargs -0 works fine:

$ printf '%b' a'\0'b | xargs -0 echo
a b

Creating the file with null?

Now let's try to create file with null character:

$ touch $'\0'
touch: cannot touch โ€˜โ€™: No such file or directory
$ mkdir $'\0'
mkdir: cannot create directory โ€˜โ€™: No such file or directory

# let's try another approach - using printf in command substitution:
$ touch "$(printf '%b' '\0')"
touch: cannot touch โ€˜โ€™: No such file or directory
$ mkdir "$(printf '%b' '\0')"
mkdir: cannot create directory โ€˜โ€™: No such file or directory

The result is exactly the same as in touch '', it seems null is just ignored all together. What if we skip double quotes around command substitution?

$ touch $(printf '%b' '\0')
touch: missing file operand
Try 'touch --help' for more information.
$ mkdir $(printf '%b' '\0')
mkdir: missing operand
Try 'mkdir --help' for more information.

This is the same situation as touch/mkdir without arguments at all. Yet another result is if we surround null with text:

$ touch "$(printf '%b' a'\0'b)"
$ ls
a   # in zsh
ab  # in bash

One can also try to redirect standard output to $'\0' but all one gets is different kind of error.

2 of 4
5

Single/double quotes vs. backslash: single quotes and backslashes are equivalent in quoting power. It's a lot more convenient to use single quotes to quote a long string with spaces, tabs, newlines, ()[]*$><?|{}~&;"`^!# and probably other characters I'm forgetting. But you could achieve exactly equivalent results with just backslashes (beware of the overloading of backslashes within backticks (`...`) though)

Double quotes are unique, though. $ expands inside double-quotes, but not single. "$foo" expands foo, but protects the expanded result from word-splitting and glob expansion.

http://mywiki.wooledge.org/BashFAQ might be a good place to start. The bash manual doesn't spend much time on how to use all the features it describes, just how they work individually.


It's literally not possible to pass a string containing a zero-byte as a command line argument, or to a system call. The ABI (application binary interface) that specifies exactly how data is passed between processes and the kernel uses C strings for everything (except binary data), including command line arguments and file / path arguments to system calls. C strings are character arrays where the end-of-string is marked by a zero-byte. There is no way to "escape" a zero byte to indicate that it's not the end of a string.

Any attempt to do something like touch $'foo\0bar' would just result in touch seeing its argument list as

argv[0] = "/bin/touch";
argv[1] = "foo";

Even though sitting in memory, argv[1] = "foo\0bar\0", the first \0 marks the end of the string. Actually, "foo\0bar\0" wouldn't make it as far as the new process's argv. It wouldn't make it out of the argv array in the exevce(2) system call that ran touch.

And even if you wrote a C or perl program with character arrays / strings containing null bytes, passing them to a system call like open(2) would cause the same interpretation of the string by kernel. System calls that need to handle arbitrary data, like read(2) and write(2), take a length argument as well as a pointer to the buffer.


It's not even possible to do much of anything with null bytes with bash. As jimmij points out, the bash syntax for writing a string literal with escape-sequence processing is $'string', but writing a \0 in your string literal acts as a string terminator inside bash. I guess this means bash stores strings internally as C strings, not with an explicit length.

str=$'foo\0bar'
echo "${#str}"   # 3, showing that bash isn't even storing it in a variable.
echo "$str" | wc -c   # 4. wouldn't work even if ${#str} did: echo's cmdline would eat it
wc -c <<< $'foo\0bar'   # 4 (includes a newline)

So we can't use this syntax to send a null byte anywhere. We'd have to use tr or something.


However, bash printf does have some limited support for \0. The %b conversion processes backslash escapes, including \0. And printf already processes such escapes in its format string.

  • printf '\0' prints a zero byte. Pipe it into hexdump -C to confirm.
  • printf '%s\0%s' foo bar | hexdump -C writes foo.bar (where . is a NUL byte) to stdout. Note that \0 inside single or double quotes doesn't expand on its own; only $'\0' quoting would expand it before printf, which would make it act as a terminator.
  • printf '%b' 'foo\0bar' does the same thing, but more complicated.
๐ŸŒ
HotSymbol
https://hotsymbol.com โ€บ home โ€บ symbols โ€บ technical symbols โ€บ symbol for null
Symbol For Null (โ€): Copy and Paste | HotSymbol
September 30, 2026 - How do I type the Symbol For Null symbol on Windows? In Microsoft Word, type 2400 and press Alt+X to turn the code into โ€. In any app, open Character Map from the Start menu, search for โ€œsymbol for nullโ€, then select and copy the character.
๐ŸŒ
Overclockers
https://overclockers.com โ€บ home โ€บ forums โ€บ software โ€บ programming tips and tricks
How Do You Type A Null Character | Overclockers Forums
October 23, 2002 - When you click a link to make a purchase, we may earn a commission. Learn More. ... It looks like nothing. It's just a nothing in the data stream. It would be 0000 0000 in ASCII. You can also get it with ALT+000. That's what a NULL character is.
๐ŸŒ
Piliapp
https://piliapp.com โ€บ symbols โ€บ null-sign
โˆ… Null Sign - PiliApp
It is unique in that it is a subset of every set, including itself. Windows: Hold down the Alt key and type 8709 on the numeric keypad, then release the Alt key. Mac: There is no default shortcut on the US layout; use the Character Viewer or copy and paste. Linux: Press Ctrl + Shift + u, then ...
๐ŸŒ
Quora
https://quora.com โ€บ How-do-you-write-a-null-character
How to write a null character - Quora
Answer (1 of 3): By definition, the null character is all zeroes, both in the ASCII (ISO/IEC 646) character set (hex code 00) and in the ISO/IEC 10646 character set (Universal Multi-Octet Character Set), in both the UCS-2 encoding (hex code 0000) and the UCS-4 encoding (hex code 00000000). How yo...
๐ŸŒ
Symbols AZ
https://symbolsaz.com โ€บ home โ€บ null symbol
Null Symbol (โ€) โ€“ Copy and Paste
June 20, 2026 - Choose your device or app to insert the null symbol without copying it from another page. Copy โ€ from this page or enter the complete Unicode sequence U+2400 in a Unicode-aware editor. Open Character Viewer with Control+Command+Space and search for the character name, or copy โ€ from this page.
๐ŸŒ
En Academic
https://en-academic.com โ€บ dic.nsf โ€บ enwiki โ€บ 199534
Null character
In caret notation the null character is ^@. On some keyboards, one can enter a null character by holding down Ctrl and pressing @ (which usually requires also holding โ‡ง Shift and pressing another key such as 2 or P). It is also common to be ...