Linux permission denied on folder

Permission denied to create files in particular directory under home directory

I copied a folder recursively from the /www/ directory to one of my directories under my home directory. Now, every time I want to create a file or a folder in this copied directory, it says permission denied . So, I have to use sudo every time. The problem is that I can create files/folders in other directories under the home directory, except this one. I tried changing the permission of this directory recursively to 755 but still the same problem. Can anyone point out what the exact problem I am facing is? And how do I get around this?

3 Answers 3

The folder, quite obviously, is property of the root user, which is why you have to use sudo in order to interact with the folder. I don’t think chown is able to apply permission changes to a folder, so you would have to go for the graphical route, as explained below.

[EDIT] A folders location typically doesn’t affect it’s permissions level or owner. For example, I could be the owner of a folder sitting in /usr/share/, but root could be the owner of a folder on my desktop. If you’re wondering why it is this way, I’d say ask Bell Labs. They started it. 🙂

(I used Nemo, but the steps are the same for Nautilus)

First, open a terminal and type sudo nautilus (again, I used Nemo, but it’s the same procedure), and enter your sudoer’s password.

sudo nautilus (in this case, nemo)

When Nautilus opens, navigate to the folder you wish to change permissions on. Depending on what program you use, you may see and «Elevated Privileges» notice. This is to remind the user to be careful with what they do, as root permissions could damage the computer if used the wrong way.

Navigate to the folder desired

Now right click the folder you want to change and choose «Properties» go to the «Permissions» tab, and it should look something like this:

Root permissions on folder

Select the dropdown menu for Owner and Group, and change them from «root» to your username (in my case, ben). It should look like this now:

How it should look

If desired, click «Apply Permissions to Enclosed Files». Then close Nautilus and exit the terminal.

Источник

How to fix permission denied error in Linux? [Solutions]

When you are working with the Linux Operating system then a common error occurs i.e. permission denied, In this article, you will get to know about how to ‘permission denied’ error in Linux?[linux permissions denied]

Читайте также:  Linux роутер d link

How to fix permission denied error in Linux? [Solutions]

List of content you will read in this article:

In the Linux operating system, you cannot execute any command without proper permission. Every file and directory has some permission or privilege (read, write, or execute) associated with them. If you are not authorized to access the file or directory, executing any command on that will result as a “permission denied” error in Linux. This prevalent common can only be resolved by getting the proper access to that file and directory. In this article, we will help you with how to fix the permission denied errors in Linux and what type of error this is with the help of various Linux commands.

What is Linux Permission Denied Error?

This type of error will occur whenever you run a command for which you do not have the execute permission. Similarly, you cannot perform read or write actions if you do not have read or write permission for any file or directory. These Linux permissions are the primary reason behind the security of Linux, as they will help in protecting the data from unauthorized access.

Linux system has three types of permissions

So, if you want to solve a Linux permission denied error, you can check your privileges for the specific file or folder using the following command.

This command will display the long listing of all files and folders along with the permission, as shown below.

As shown below, we have created a shell script “hello.sh” without the execute permission. On executing “hello.sh”, you will get a “permission denied” error.

How To Fix Permission Denied Error in Linux?

For solving this error, you need to add the correct permissions to the file to execute. However, you need to be a “root” user or have sudo access for changing the permission. For changing the permission, Linux offers a chmod command. The chmod stands for change mod. This command has a simple syntax, as shown below.

chmod flags permissions filename
  • Flags are the additional options that users can set.
  • Permissions can either be read, write or execute in the file. You can represent them in symbolic form (r, w, and x) or octal numbers.
  • The Filename specifies the file’s name for changing the permissions.

Representation of permissions

Below is the symbolic and octal representation of the user’s permissions while executing the “chmod” command. First, we will understand the representation before using it.

Читайте также:  Открыть права доступа linux

Symbolic representation

  • r specifies the read permissions
  • w specifies the write permissions
  • x specifies the execute permissions
  • Octal representation-
  • 4 specifies the read permissions
  • 2 specifies the write permissions
  • 1 specifies the execute permissions
  • 0 means no permissions issued.

How to Solve Bash Permission Denied?

Now, we are aware of the error, as shown below.

Giving the appropriate permission to the user will solve the problem. Thus, we are giving the execute permission to the user to run the “hello.sh” shell script. Execute the below command to provide execute permission.

Now, we can see the change in the permission of the “hello.sh” script file. The above command provides the execute permission to the file. As you can see, the root user can make the required changes. If we execute the shell script, we should not get the error. Let’s try by running the below command.

After executing the “hello.sh”, we get the output that displays the “hello.” Changing permission has solved the problem of bash permission denied.

Conclusion

If you are a regular Linux user, you might have faced the “permission denied” error while executing various commands. This might be due to the incorrect privileges to run that command. Only a root user or user with sudo access can change the permissions for the file or directory you want to access or execute. If you are the correct user to make the required permission changes, you can run the “chmod” command and add the desired permission.

This is all about how you can solve/fix permission denied errors in Linux with the help of the above-listed commands/methods. If you think there are other alternatives to achieve the goal, you can put them down via the comment box. Also, you can buy a Linux VPS server to run and test the above-listed commands.

Источник

Ошибка «Permission denied» в Linux

Все операционные системы семейства Linux имеют четко разграниченные права доступа. В своей домашней директории пользователь может делать все, что ему угодно, до тех пор, пока укладывается в отведенные рамки. Попытка выйти за них приводит к появлению ошибки «Permission Denied».

Изменение прав в терминале

Рассмотрим вариант, в котором необходимо прочесть текстовый документ, созданный другим пользователем. Файлы TXT в Linux можно просматривать непосредственно в терминале с помощью команды «cat».

    Заходим в каталог с интересующим нас документом. Набираем команду «cat filename», подставляя вместо «filename» имя нужного файла. На скриншоте показана ошибка «Permission Denied», выглядящая в русской локализации как «Отказано в доступе».

Ошибка «Permission Denied»

Получаем ошибку «Permission Denied» при попытке просмотреть содержимое файла

Просмотр прав доступа командой «ls»

Проверяем права доступа к документу используя команду «ls -l»

Читайте также:  Document root in linux

Изменение прав доступа командой «chmod»

Используем команду «chmod» и административные права для получения доступа

Просмотр текстового файла командой «cat»

Просматриваем содержимое текстового документа командой «cat»

Изменение прав в файловом менеджере

Разберемся, как выполнить рассмотренную выше операцию в графическом интерфейсе, используя файловый менеджер из дистрибутива.

    Как видно на скриншоте, значок файла изначально имеет дополнительные символы, указывающие на то, что доступ у нему ограничен. При попытке посмотреть содержимое получаем графический вариант ошибки «Permission Denied».

Графический вариант ошибки «Permission Denied»

При попытке открыть текстовый документ получаем ошибку «Permission Denied»

Переключение файлового менеджера в режим root

Открываем меню «Файл» и перезапускаем файловый менеджер от имени root

Окно аутентификации root

Набираем пароль root в окне аутентификации

Контекстное меню файлового менеджера

Открываем параметры файла с помощью контекстного меню

Вкладка «Права» в свойствах файла

На вкладке «Права» разрешаем доступ для группы root и остальных пользователей

Файл, открытый в режиме чтения

Открываем ранее недоступный файл в режиме чтения и изучаем содержимое

В заключение

Как видим, избавиться от ошибки Permission Denied достаточно просто. Решив изменить правда доступа к системным файлам, лишний раз убедитесь, что полностью уверены в своих действиях и понимаете последствия вносимых изменений.

Источник

Create file in folder: permission denied

I have a problem copying files to a directory on Ubuntu 12.04. I create a directory in the home directory so that the path where I want to copy to is:

francisco-vergara@Francisco-Vergara:/home/sixven/camp_sms/inputs$ touch test_file.txt touch: can not make `touch' on «test_file.txt»: permission denied 

I can not copy files directly in that directory. How can I assign permissions with the chown & chmod commands to copy the files? I do not know which user and group to use.

From what you have copy-pasted, you are running touch as user francisco-vergara , but your directory is in /home/sixven is that really the home of user francisco-vergera or does it belong to a sixven user ? You should clarify what you want to do exactly. Write in another user’s home ? Share that directory among a group ?

3 Answers 3

First of all you have to know that the default permission of directories in Ubuntu is 644 which means you can’t create a file in a directory you are not the owner.

you are trying as user:francisco-vergara to create a file in a directory /home/sixven/camp_sms/inputs which is owned by user:sixven .

So how to solve this:

    You can either change the permission of the directory and enable others to create files inside.

sudo chmod -R 777 /home/sixven/camp_sms/inputs 
sudo chown -R francisco-vergara:francisco-vergara /home/sixven/camp_sms/inputs 

So i advise you to use Option 1.

Or if this directory will be accessed by both users you can do the following trick:

change ownership of the directory to user:francisco-vergara and keep the group owner group:sixven .

sudo chown -R francisco-vergara /home/sixven/camp_sms/inputs 

Like that both users can still use the directory.

But as I said you before It’s easiest and more efficient to use option 1.

Источник

Оцените статью
Adblock
detector