88

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?

Fabby
  • 34,259
sam
  • 1,333
  • 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 '16 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 '16 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. – Eduardo Cola Jan 11 '16 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 '16 at 23:12
  • Isn't /tmp used with tmpfs? Which uses RAM? – Eduardo Cola Jan 11 '16 at 23:43

4 Answers4

111

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.

Fabby
  • 34,259
  • but what is that mean after i executed your command i got total 0 when i wrote ls -l /var/nameoffolder? – sam Jan 11 '16 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 '16 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 '16 at 23:21
  • After this i am still getting error -bash: cd: folder: Permission denied , when trying cd folder – YourHelper May 14 '22 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 '22 at 23:32
89

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
7

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

chmod -R a+rwx path
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
Nooriallah
  • 41
  • 1