Find the answer to your Linux question:
Results 1 to 7 of 7
When I type visudo as root in console, it opens up, a sudoers.tmp nano screen. The tmp, ending confuses me, is this the screen where I uncomment as needed ? ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Aug 2009
    Posts
    156

    Not sure where to start with Visudo


    When I type visudo as root in console, it opens up, a sudoers.tmp nano screen. The tmp, ending confuses me, is this the screen where I uncomment as needed ? I have a log viewer program that I would like to view as regular user, but I get permissions denied. So, that is what I am hoping I can change with visudo. Also is this the screen, where I type visudo commands to change settings? Frank

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Yes, visudo is opening up a temporary copy of /etc/sudoers, so that it can check the syntax for typos after you're done editing it. Then it saves it to /etc/sudoers when it has confirmed that.

    Say the command you are using to view the log is tail and say the log you are talking about is /var/log/messages, and say your username is frank - then you might insert a line like this, in visudo:

    Code:
    frank ALL = (root) NOPASSWD: /usr/bin/tail /var/log/messages

  3. #3
    Linux Newbie
    Join Date
    Aug 2009
    Posts
    156
    Quote Originally Posted by atreyu View Post
    Yes, visudo is opening up a temporary copy of /etc/sudoers, so that it can check the syntax for typos after you're done editing it. Then it saves it to /etc/sudoers when it has confirmed that.

    Say the command you are using to view the log is tail and say the log you are talking about is /var/log/messages, and say your username is frank - then you might insert a line like this, in visudo:

    Code:
    frank ALL = (root) NOPASSWD: /usr/bin/tail /var/log/messages
    That line would be inserted in /etc/sudoers.tmp? If so where , bottom, any white space? Would I need to uncomment any lines in /etc/sudoers.tmp? Thanks for your quick reply, Atreyu

    I later entered at the bottom of sudoers.tmp the line you suggested and did not get any error messages. To run the graphical application log file viewer, with root privileges, what sudo command do I type? I have opened nautilus before with gksudo, would this work in a similar way?
    Last edited by frank56; 07-27-2011 at 09:14 AM.

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Just to be clear, you'd have to run visudo (as root) and let IT create suderos.tmp. The visudo program should load the tmp file in your default editor (I think you said nano). Then you'd use the nano commands to insert a new line at the bottom of the file, then save and quit nano. Then the visudo program will move the tmp file into place (to /etc/sudoers).

    The command you'd run as 'frank' would be:
    Code:
    sudo /usr/bin/tail /var/log/messages
    In your bash profile (~/.bashrc) you could put something link:
    Code:
    alias taillog='sudo /usr/bin/tail /var/log/messages'
    Last edited by atreyu; 07-28-2011 at 12:18 PM.

  5. #5
    Linux Newbie
    Join Date
    Aug 2009
    Posts
    156
    What does putting the alias taillog line in bashrc do, or what is it purpose?

  6. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Sorry, forgot to explain - that would create (via Bash's builtin alias function) a command, "taillog", that your user could run on the command line, to tail the log, instead of doing the whole sudo line. i.e., instead of:

    Code:
    sudo /usr/bin/tail /var/log/messages
    You could just do:
    Code:
    taillog
    It's not required or anything, just a common shortcut that many people do for sudo commands they have to run a lot.

    EDIT: My alias statement was incorrect in the other post (was missing the sudo part, duh) - fixed it

  7. #7
    Linux Newbie
    Join Date
    Aug 2009
    Posts
    156
    Thanks, Atreyu, you have made learning Gentoo fun, or a part of it. I can use all the shortcuts, I can get my hands on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •