LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   i need to access the /ec/hosts file (https://www.linuxquestions.org/questions/debian-26/i-need-to-access-the-ec-hosts-file-4175419093/)

tbrownarcher 07-28-2012 12:35 PM

i need to access the /ec/hosts file
 
I am in the terminal and trying to access the /etc/hosts but i get the message "Permission denied so I run the command 'su' it asks for my password I type in the password and then do the command to go to /etc/hosts and it tells me permission denied.... what is it i'm doing wrong ??



nate@Nate3 ~ $ /etc/hosts
bash: /etc/hosts: Permission denied
nate@Nate3 ~ $ su
Password:
Nate3 nate # /etc/hosts
bash: /etc/hosts: Permission denied
Nate3 nate #

thanks,
Nate

Nylex 07-28-2012 01:04 PM

/etc/hosts isn't a script or anything, it's basically just a configuration file. So, trying to run it on the command line as you are makes no sense. FWIW, you get the permission denied message because the file doesn't have execute permissions (again, because that makes no sense for the type of file it is). You need to edit it with whichever editor you use.

lithos 07-28-2012 01:18 PM

Quote:

Originally Posted by Nylex (Post 4740105)
/etc/hosts isn't a script or anything, it's basically just a configuration file.
...
You need to edit it with whichever editor you use.

Code:

#vim /etc/hosts  <--- edit
#cat /etc/hosts    <--- view output in terminal


Nylex 07-28-2012 01:19 PM

You can also use pagers (e.g. less, more, most) to view the file.

tbrownarcher 07-28-2012 04:32 PM

Thanks , I got it

Nate

tbrownarcher 07-28-2012 04:42 PM

Thanks , I got it

Nate

Dutch Master 07-28-2012 09:06 PM

In addition, nano is an easier editor to use if you can't (be bothered to) memorise the incredible amount of short cuts/key strokes you'd need for vim or emacs :)


All times are GMT -5. The time now is 11:55 AM.