78

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
    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
    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. 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
    Jan 11, 2016 at 23:12
  • Isn't /tmp used with tmpfs? Which uses RAM? Jan 11, 2016 at 23:43

4 Answers 4

94

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
    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
    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
    Jan 11, 2016 at 23:21
  • After this i am still getting error -bash: cd: folder: Permission denied , when trying cd folder
    – YourHelper
    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
    May 14, 2022 at 23:32
78

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. Jul 14, 2020 at 3:06
  • Do we need to type full path here? 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 Feb 23, 2021 at 5:56
5

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? Oct 9, 2022 at 19:39
3

I gave all permissions to all users by following command

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

And gave full permissions to a user

sudo chown -R username:grouname /folder path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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