Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How long can be files names and folder names in Ubuntu Linux and what characters are allowed in file name and folder name in Ubuntu Linux?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

File names in Linux were 14 bytes long in earlier Unix version. But The modern Linux system has 255 bytes for file names.

As a character requires 1 byte, The length becomes 255 characters. Also the folders are treated as files in Linux system

See this link for more information

share|improve this answer

I'm not sure what the maximum file name length can be (for ext4), but it's more dependent on the file system, than Linux itself. On FAT32, I think it is 255 characters. You probably don't ever actually need a file name that long.

As for characters allowed, any byte value is allowed on the ext4 file system, except for the NULL byte (and /, as that is the directory separator1). However, you should limit your file names to the UTF-8 character set, for the widest range of compatibility across applications, and devices.

1. As stated in the glibc manual, "any character except the null character is permitted in a file name string," but a / in the file name string separates the name of one file or folder from that of its parent.

share|improve this answer
    
I'ld say limit to a-z,A-Z,and numbers. Adding non-alpha-numerics is begging to find url parsing bugs –  hbdgaf Jul 22 '12 at 16:40
    
@aking1012 I wish to use '.' and '@' is it not advisable. –  Gaurav Agarwal Jul 22 '12 at 16:53
    
'.' is of course fine. I haven't seen @ go wooly, but I guess it could in some corner case. Things parsers use as delimiters and don't escape properly is more what I was referring to - examples: space, /, ", ', etc –  hbdgaf Jul 22 '12 at 16:57
1  
The period . is widely used in the system itself, so it is not a problem. The @ should also be fine, I see email servers (e.g. exim) with one directory per account that contain @ and have no problem whatsoever. –  Marios Zindilis Jul 22 '12 at 16:58
1  
using a @ is fine. 2 remarks: IF you use something special you can always escape the char. Also do realize that sometimes a char is used as a divider: for instance ssh uses it to seperate user and system: example this: user@system:/dir/dir@dir/ might be iffy and not understood). –  Rinzwind Jul 22 '12 at 17:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.