50

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 '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
  • 1
    /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
54

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.

3
  • 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
43

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
4
  • 1
    This works for me, since I also need to give all the sub folders the permissions. – Jonjie Jul 14 '20 at 3:06
  • 2
    sudo chmod -R 777 / now my life is less stressful, thanks – Bersan Dec 7 '20 at 22:53
  • Do we need to type full path here? – Goran_Ilic_Ilke Feb 19 at 7:43
  • yes. we need to move to the path or we need to type the full path for the folder – Pradeep Kumar Prabaharan Feb 23 at 5:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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