How do you name a file with special characters in Linux?
Sarah Martinez
Published Mar 04, 2026
How do you name a file with special characters in Linux?
Linux / UNIX: Rules For Naming File And Directory Names
- All file names are case sensitive.
- You can use upper and lowercase letters, numbers, “.” (dot), and “_” (underscore) symbols.
- You can use other special characters such as blank space, but they are hard to use and it is better to avoid them.
What special characters can be used in filename?
In both NTFS and FAT file systems, the special file name characters are: ‘\’, ‘/’, ‘. ‘, ‘?’ , and ‘*’. On OEM code pages, these special characters are in the ASCII range of characters (0x00 through 0x7F).
What characters are not allowed in Linux filenames?
Under Linux and other Unix-related systems, there are only two characters that cannot appear in the name of a file or directory, and those are NUL ‘\0’ and slash ‘/’ . The slash, of course, can appear in a pathname, separating directory components.
How do I use special characters in Linux?
When you quote a special character, you prevent the shell from giving it special meaning. The shell treats a quoted special character as a regular character. However, a slash (/) is always a separator in a pathname, even when you quote it. To quote a character, precede it with a backslash (\).
How do you name a file in Linux?
To use mv to rename a file type mv , a space, the name of the file, a space, and the new name you wish the file to have. Then press Enter. You can use ls to check the file has been renamed.
What are special characters in Linux?
The characters <, >, |, and & are four examples of special characters that have particular meanings to the shell. The wildcards we saw earlier in this chapter (*,?, and […]) are also special characters.
What special characters Cannot be used in a filename?
Illegal Filename Characters
- # pound. % percent. & ampersand. { left curly bracket. } right curly bracket. \ back slash.
- < left angle bracket. > right angle bracket. * asterisk.? question mark. / forward slash.
- $ dollar sign. ! exclamation point. ‘ single quotes. ” double quotes. : colon.
- + plus sign. ` backtick. | pipe. = equal sign.
Can I use colon in filename?
A colon is an invalid character for a Windows file name. You won’t be able to allow ‘:’ in the file name, but you can work around it.
How do you add special characters in a file name?
Explanation
- Double your \ , like this: \\ , so that your shell does not interpret the backslashes from your filename as escape characters.
- Escape ” and ‘ , like this: \” , \’ , so that your shell interprets the double quotes as part of the filename.
What special characters are not allowed in filenames?
How do I check UNIX special characters?
1 Answer. man grep : -v, –invert-match Invert the sense of matching, to select non-matching lines. -n, –line-number Prefix each line of output with the 1-based line number within its input file.
How do I rename a file in Ubuntu?
Rename a file or folder
- Right-click on the item and select Rename, or select the file and press F2 .
- Type the new name and press Enter or click Rename.
What characters are not allowed in file names?
It depends on the operating system. As others have said, on Microsoft systems many characters are not allowed. But on Unix variants, including Linux and MacOS, there is no such restriction, and most characters are allowed in filenames.
Which characters cannot be used in a filename?
These characters have explicit significance in the Windows file system, and as such cannot be allowed in filenames – for instance, the backslash \\ is used to separate the components of a path (ex C:\\Documents\\), while the period is used to separate the base file name from the extension (ex test.doc).
What are the allowed characters in filenames?
– Don’t start or end your filename with a space, period, hyphen, or underline. – Keep your filenames to a reasonable length and be sure they are under 31 characters. – Most operating systems are case sensitive; always use lowercase . – Avoid using spaces and underscores; use a hyphen instead. This will also improve your search engine rankings .
How do you rename a file in Linux?
In order to rename a file in Linux you can use either of two approaches. 1. Create a copy of the existing file with the new desired name and then delete the old file. 2. Rename the file by moving it with the mv command.