When I try to edit the ipsec
tools I get the permission denied
error.
$ /etc/ipsec.conf
bash: /etc/ipsec.conf:permission denied.
How can I solve this problem?
The command /etc/ipsec.conf
attempts to run /etc/ipsec.conf
as a program or script. But it isn't an executable you wish to run--instead, it is a configuration file you wish to edit.
Happily, it does not have execute permissions set on it, so this fails.
To edit a file, start with the program you wish to use to edit it, and then (after a space) supply the name of the file you want to edit. The general form of such a command is: editor file
As bntser says, this file is owned by root so you must edit it as root. (That is not the cause of the "permission denied" message, though, which is from trying to execute a file that does not have executable permissions.) To do so, use sudo
, or gksudo
.
To edit with a non-graphical editor, use sudo
and provide the name of the editor. nano
is easy to use. I recommend invoking it as nano -w
for editing configuration files. This makes it so that when there's a line in the file that is wider (in number of characters) than your terminal, you scroll left and right to edit it. In other words, it disables "soft" word wrapping. Word wrapping can be confusing when editing configuration files, because unless you're quite familiar with the file's contents, you might not be sure where one line ends and the next begins.
sudo nano -w /etc/ipsec.conf
To open the file with a graphical editor like gedit
or leafpad
, use gksudo
:
gksudo gedit /etc/ipsec.conf
If you don't have gksudo
, you can install the gksu package to get it, or you an use
sudo -H
or sudo -i
:
sudo -H gedit /etc/ipsec.conf
However, you should avoid sudo gedit
without -H
or -i
(and similar commands with gedit
replaced by the name of another graphical program).