Find the answer to your Linux question:
Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    still can't run certain commands when su root?


    When I log in as a normal user, when I want to run commands such as fdisk -l
    I get this: bash: fdisk: command not found

    I'm assuming that fdisk is not defined in the bash script of the user. But when I su to root and try to run the same command I get the same thing. But if I log out completely and log back in as root, I can run the command.

    I thought running su will afford you the priviledge of running as root and having access to all commands.

  2. #2
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,619
    After doing su, try:
    Code:
    /sbin/fdisk
    Some distros do not set the PATH to include /sbin.

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  3. #3
    Linux Guru budman7's Avatar
    Join Date
    Oct 2004
    Location
    Knee deep in Grand Rapids, Michigan
    Posts
    3,901
    Slight difference with the commands.

    "su" will give you root privileges with your regular user path

    "su -" will give you roots path
    If you want to learn more about linux take a linux journey
    https://linuxjourney.com/
    Use CODE tags when posting output of commands. Thank you.
    https://www.linuxcounter.net/cert/608410.png

  4. $spacer_open
    $spacer_close
  5. #4
    Quote Originally Posted by budman7
    Slight difference with the commands.

    "su" will give you root privileges with your regular user path

    "su -" will give you roots path
    o.k I tried su - and it worked. So whats the sense of using su if you still have the shell commands of a regular user? Is it to run certain root level functions from a regular user shell granted you have the commands defined in your user shell?

  6. #5
    Linux Guru budman7's Avatar
    Join Date
    Oct 2004
    Location
    Knee deep in Grand Rapids, Michigan
    Posts
    3,901
    For most things I use su, because I do not need roots path.

    And distros do things differently, like Fedora, if you use just su and try to use fdisk, you will get command not found.
    But if you try the same thing in Gentoo, the command will work.
    If you want to learn more about linux take a linux journey
    https://linuxjourney.com/
    Use CODE tags when posting output of commands. Thank you.
    https://www.linuxcounter.net/cert/608410.png

  7. #6
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,732
    Like Budman, I rarely ever su - to do anything. In most cases, su is enough, so there's no point in risking machine security. It's amazing to me how many new Linux users want to run their machines on a constant basis as root simply because it's convenient.

    Note though, that I'm not saying that's what you are wanting to do, teknoratti.

  8. #7
    Linux User
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    326
    Quote Originally Posted by teknoratti
    o.k I tried su - and it worked. So whats the sense of using su if you still have the shell commands of a regular user? Is it to run certain root level functions from a regular user shell granted you have the commands defined in your user shell?

    man su

    su = substitute user identity : By default, the environment is unmodified with the exception of USER, HOME, and SHELL.

    -, -l, --login Simulate a full login. The environment is unmodified except for HOME, SHELL, PATH, TERM, and USER.


    remember su works for users other than root...
    far...out

Posting Permissions

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