1

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?

Aditya
  • 13,416
nina
  • 11

2 Answers2

2

If you have sudo privileges will need to use sudo vi /etc/ipsec.conf and enter your password.

If you aren't a vi fan, use any editor you want, such as a nano or gedit.

αғsнιη
  • 35,660
bntser
  • 1,456
2

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 Install 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).

Pang
  • 373
Eliah Kagan
  • 117,780