Editing a conf file

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Hallux

Editing a conf file

Post by Hallux »

Obviously, I'm new to Linux and still thinking in Windows terms. I feel stupid even asking this, but here goes.
I'm trying to configure DansGuardian and Squid on my computer. The walkthrough on linux.com (http://www.linux.com/archive/feature/113733) says to add a few lines to the .conf files. I can find the files easily through nautilus, but can't open them in a text editor. I assume this is because I am trying to change system files (what's the linux term there?) while logged in as my normal account as opposed to root.

I tried opening terminal and using 'su gedit [filename]'. That brought up the files in a text editor (Are they supposed to be empty?), but I get error messages when I try to save it.

What am I doing wrong? How do I edit a plaintext file?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Biker
Level 5
Level 5
Posts: 517
Joined: Sat Apr 17, 2010 1:58 am
Location: Where my hat is

Re: Editing a conf file

Post by Biker »

You either need to specify the location of the file in addition to the file name, or change directory to the location of the file and edit there (in terminal, of course).

For example, let's say you wanted to edit grub.cfg, which resides in /boot/grub. You would type:

su gedit /boot/grub/grub.cfg

or

You would change directory by typing:

cd /boot/grub/

and then type: su gedit grub.cfg
Linux User #384279
vrkalak

Re: Editing a conf file

Post by vrkalak »

AS Biker said ... Yes, you are correct ... you cannot change/edit anything in a file, unless you are the 'root' user.

Look at your "sources.list" for example:

You can find the config file through your File Manager but it will be 'Read Only'

If you want to change the config.files you must be 'root' (super-user) (System Administrator in Windows terminology)

Open a Terminal, type in: sudo gedit /etc/apt/sources.list Enter password when prompted. Click 'enter'
A window to the Text Editor will open. Make your changes to said file. Don't forget to 'Save' Then, Exit.
No need to re-boot, all changes should take place immediately. Though in rare cases, you might have to re-start your desktop.

sudo = super-user / root account
gedit = text editor, enter the name of whatever text editor you use.
/etc/apt/sources.list = the 'path' to your desired files

Terminal, CLI = is your friend
mick55

Re: Editing a conf file

Post by mick55 »

The preferred method is to invoke "gksudo" if you are using a graphical editor such as gedit.

Code: Select all

gksudo gedit /etc/apt/sources.list
"sudo" is OK if you are using a non graphical editor such as nano

Code: Select all

sudo nano /etc/apt/sources.list
"su" plus 75 cents will buy you a cup of coffee. :wink:

Linux Mint does not understand the command "su" used in this way.

Code: Select all

su gedit /etc/apt/sources.list
For someone new to Linux, Gedit is your best choice.

mick
Locked

Return to “Beginner Questions”