Why do question mark characters appear when changing the permissions of directory?

To view the permissions of a directory, you need to pass the -d flag to ls, like this:

ls -ld squid3

To read a file, its read permission needs to be set. However, to read a directory and the listing of its files, both the read and the execute permissions need to be set. If they aren't, you get weird errors like the ones you're experiencing.

To set the read permission on files and the read and execute permissions on directories recursively, use this command:

chmod -R a+rX directoryname

Here's an explanation of that command:

  • chmod is the name of the command, use for changing the permissions of files.
  • -R is the recursive flag. It means apply this command to the directory, and all of its children, and of its children's children, and so on.
  • a stands for all: apply these permissions the owner of the file, the group owner of the file, and all other users.
  • + means add the following permissions if they aren't set already.
  • r means the read permission.
  • X means the execute permission, but only on directories. Lower-case x would mean the execute permission on both files and directories.

More information is found in the manpage for the chmod command Manpage icon.


I had this problem too. I couldn't do chmod or chown on the file. I had tried to delete it. It turns out that trying to delete it (rm command) caused the problem. The kicker is that the file is shared between two different systems. Once I closed the file in the other system, the file disappeared. Here's more details of my configuration. system 1: Ubuntu guest VM. This is where I did the rm command. system 2: Windows 7 host. This is where I had opened the file using the less command (in cygwin, not that it's necessarily relevant).


As you stated that your goal is to read /var/log/squid/access.log, your best solution is to type sudo less /var/log/squid/access.log, which spares the trouble of repeatedly chmodding.