93

I'm new to Ubuntu and need to create a new folder in /var and need all users on the machine to have full permissions to this folder.

How should I proceed?

5
  • Welcome to Ask Ubuntu! ;-) Do you want to create a folder in /var that has full permission for all users??? There is already one! and it's called tmp!
    – Fabby
    Commented Jan 11, 2016 at 22:49
  • Thanks for replying , yes that i want to do but please what do you mean by There is already one! and it's called tmp!
    – sam
    Commented Jan 11, 2016 at 22:54
  • 2
    /tmp is a system directory with a temporary filesystem which uses RAM memory. Anything put there will be deleted upon reboot. Commented Jan 11, 2016 at 23:05
  • @EduardoCola: it actually uses disk, but yes, it's deleted upon reboot! (You can see this happening when you remove quiet splash from the boot parameters...) ;-)
    – Fabby
    Commented Jan 11, 2016 at 23:12
  • Isn't /tmp used with tmpfs? Which uses RAM? Commented Jan 11, 2016 at 23:43

4 Answers 4

113

Press Ctrl+Alt+T to go to a terminal and type:

sudo mkdir /var/szDirectoryName
sudo chmod a+rwx /var/szDirectoryName

Where szDirectoryName is the name of the directory you would like, a means "all" (users) + means "add the following rights" and rwx means read, write and execute respectively...

Note: there already is such a directory in /var which all users have access to: tmp (full path: /var/tmp) which itself is symlinked to /tmp.
Beware however that all files in /tmp are deleted at boot time.

For any further information, here is a great resource on all directories in Linux.

5
  • but what is that mean after i executed your command i got total 0 when i wrote ls -l /var/nameoffolder?
    – sam
    Commented Jan 11, 2016 at 23:04
  • i know that command ls .. used for listing what is in that folder but -l give me the permissions rigth ?
    – sam
    Commented Jan 11, 2016 at 23:08
  • sorry , you edited your answer with statement i want to ask about there is already a directory in /var that all users have access to: tmp which is symlinked to /tmp this means that folders that i will created in /var will be deleted liken in /tmp
    – sam
    Commented Jan 11, 2016 at 23:21
  • After this i am still getting error -bash: cd: folder: Permission denied , when trying cd folder
    – YourHelper
    Commented May 14, 2022 at 17:56
  • @YourHelper Please ask a new question and provide more details there as to what goes wrong where exactly... It might help to include a link to this question for reference.
    – Fabby
    Commented May 14, 2022 at 23:32
92

Open Terminal

Create Directory with mkdir:

sudo mkdir /var/DirectoryName

To give all permissions to a folder give chmod -R 777:

sudo chmod -R 777 /var/DirectoryName
3
  • 1
    This works for me, since I also need to give all the sub folders the permissions. Commented Jul 14, 2020 at 3:06
  • Do we need to type full path here? Commented Feb 19, 2021 at 7:43
  • yes. we need to move to the path or we need to type the full path for the folder Commented Feb 23, 2021 at 5:56
8

Below gives all permissions to everybody to all files and subdirectories:

chmod -R a+rwx path
1
  • Is this true for any new files/directories made or only for existing files and directories? Commented Oct 9, 2022 at 19:39
4

To give all permissions to all the users, use the following command:

chmod -R a+rwx /path/....

Note: It's Usually not recommended to give every user every permission of a directory, be careful while using this command.

To give permissions to a specific user:

sudo chown -R username:grouname /folder_path

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .