Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
$ rm foobar
rm: remove regular file `foobar'?

What does it mean for a file to be "regular" and why does rm treat such a file as a special case?

share|improve this question

I figure rm is an alias, possibly rm -i. The "regular" part doesn't mean anything in particular, it only means that it's not a pipe, device, socket or anything other "special".

share|improve this answer
Ah, you're right - it's aliased to rm -i. – Cory Klein Nov 7 '13 at 19:00
So it does mean something in particular. Actually it's a very important aspect of the object to be removed ... – Bananguin Nov 7 '13 at 20:00
As @alexander said, it means the file is not a symlink, pipe, rand, null, cpu, etc. Perhaps you have heard the linux philosophy "everything is a text file". This isn't literally true, but it suggests a dominant operational context where string processing tools can be applied to filesystem elements directly. In this case, it means that in a more literal fashion. To see the detection step in isolation, try the command file, as in file /etc/passwd or file /dev/null. – Joe Atzberger Nov 7 '13 at 21:32

test command

Any file that passes the test (-f) is a regular file:

$ test -f afile.zip && echo regular

If you look through the man page for test you'll see all the various types of files.

stat command

You can also check if a file is regular by using the stat command:

$ stat afile.zip 
  File: `afile.zip'
  Size: 1512        Blocks: 8          IO Block: 4096   regular file
Device: fd02h/64770d    Inode: 10370668    Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/    saml)   Gid: (  501/    saml)
Access: 2013-11-07 15:52:06.719632792 -0500
Modify: 2013-11-07 15:52:00.949760104 -0500
Change: 2013-11-07 15:52:00.949760104 -0500

stat() function

To understand more about what the difference is between a regular file and the other possible types take a look at the man page for stat. Be sure to look at the man page for the programmers manual and not the man page for the actual stat command.

$ man 2 stat

This section in particular shows the various types of files:

   The following flags are defined for the st_mode field:

       S_IFMT     0170000   bit mask for the file type bit fields
       S_IFSOCK   0140000   socket
       S_IFLNK    0120000   symbolic link
       S_IFREG    0100000   regular file
       S_IFBLK    0060000   block device
       S_IFDIR    0040000   directory
       S_IFCHR    0020000   character device
       S_IFIFO    0010000   FIFO
       S_ISUID    0004000   set UID bit
       S_ISGID    0002000   set-group-ID bit (see below)
       S_ISVTX    0001000   sticky bit (see below)
       S_IRWXU    00700     mask for file owner permissions
       S_IRUSR    00400     owner has read permission
       S_IWUSR    00200     owner has write permission
       S_IXUSR    00100     owner has execute permission
       S_IRWXG    00070     mask for group permissions
       S_IRGRP    00040     group has read permission
       S_IWGRP    00020     group has write permission
       S_IXGRP    00010     group has execute permission
       S_IRWXO    00007     mask for permissions for others (not in group)
       S_IROTH    00004     others have read permission
       S_IWOTH    00002     others have write permission
       S_IXOTH    00001     others have execute permission
share|improve this answer

Your Answer


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.