LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 07-16-2018, 07:33 AM   #1
JHugh
Member
 
Registered: Jul 2017
Posts: 33

Rep: Reputation: Disabled
Question How to Run Everything as Root?


Is there any way that I can run everything as root without running from the terminal?

For example, I would like to just double click a program on the desktop and have it run as root.

I'm fine if this is not secure, since this computer is off the network.

Thanks.
 
Old 07-16-2018, 07:39 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by JHugh View Post
Is there any way that I can run everything as root without running from the terminal? For example, I would like to just double click a program on the desktop and have it run as root. I'm fine if this is not secure, since this computer is off the network.
While you *CAN* log in as root through the GUI (and with RHEL, you need to make some changes before you can do that), the better question is WHY??? Regardless of whether your system is net connected or not, you need to understand how system security works and why, and work within the framework. Running as root is plain dangerous, and should be avoided at all costs; when used, it should be SPARINGLY, and only to accomplish certain tasks that require it.
 
Old 07-16-2018, 07:46 AM   #3
petelq
Member
 
Registered: Aug 2008
Location: Yorkshire
Distribution: openSUSE(Leap and Tumbleweed) and a (not so) regularly changing third and fourth
Posts: 627

Rep: Reputation: Disabled
Quote:
Originally Posted by JHugh View Post
Is there any way that I can run everything as root without running from the terminal?

For example, I would like to just double click a program on the desktop and have it run as root.

I'm fine if this is not secure, since this computer is off the network.

Thanks.
Most newcomers to linux learn how to use it as it should be. You have to accept linux is different. There's no special magic to using linux. If the ms way suits you better, just stick with it.
But you'll like the flexiblity of linux if you persevere.
 
1 members found this post helpful.
Old 07-16-2018, 07:59 AM   #4
JHugh
Member
 
Registered: Jul 2017
Posts: 33

Original Poster
Rep: Reputation: Disabled
I completely agree that it is more secure to not let everything run as root; however, I have a specific issue, which I can't get around by using Windows.

The Linux machine that I am running is going to be used as a controller (my program manager says it has to be a Linux machine), so it needs to be able to open a specific program with root privileges always. Mainly because the program will not see my tty ports unless the program is running with root privileges. In addition, it needs to be able to keep these root privileges to this specific program even on a reboot.

The program is LabVIEW if that matters at all.

Is this possible and how would I do it?

And yeah... I'm still pretty new to Linux, but I've got to use it for my job, so I am willing to learn the rules/syntax and appreciate your help.

Thanks!
 
Old 07-16-2018, 07:59 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
in general, no, there is no way to run everything as root. I mean really everything.
But you can run [almost] any program as root. You may need to understand how sudo works to do that. But there are also some apps which will refuse to work as root.
 
Old 07-16-2018, 08:02 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
Quote:
Originally Posted by JHugh View Post
the program will not see my tty ports unless the program is running with root privileges
No you need to configure the user (better to say group) who executed that program to access that tty port too. That is the regular way.

Otherwise check how sudo works.
 
Old 07-16-2018, 08:53 AM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by JHugh View Post
I completely agree that it is more secure to not let everything run as root; however, I have a specific issue, which I can't get around by using Windows.

The Linux machine that I am running is going to be used as a controller (my program manager says it has to be a Linux machine), so it needs to be able to open a specific program with root privileges always. Mainly because the program will not see my tty ports unless the program is running with root privileges. In addition, it needs to be able to keep these root privileges to this specific program even on a reboot.

The program is LabVIEW if that matters at all. Is this possible and how would I do it? And yeah... I'm still pretty new to Linux, but I've got to use it for my job, so I am willing to learn the rules/syntax and appreciate your help.
This is a much more reasonable question. Running a SINGLE program as root isn't a bad thing. As said, root should be used ONLY when needed. Depending on your desktop environment (probably Gnome or KDE), you can easily modify the shortcut to have it execute "gksu <program name>" or "kdesu <program name>", and it will prompt you for the root password. Enter it, and you're off to the races.

You posted this in the Red Hat forum...are you using RHEL, and if so, you're paying for it, right? RHEL support should be able to assist you.
 
Old 07-16-2018, 09:29 AM   #8
JHugh
Member
 
Registered: Jul 2017
Posts: 33

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
You posted this in the Red Hat forum...are you using RHEL, and if so, you're paying for it, right? RHEL support should be able to assist you.
Yeah. I am using RHEL, but it was installed by my IT, so I don't have a user account with RH to get support and my IT says they cannot give me the credentials I need.


How would I configure my tty ports to be recognized and accessed by all users? That does seem like the most secure way to approach this problem, instead of just bashing it with root.
 
Old 07-16-2018, 09:38 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
I assume by tty port this is a serial port and to allow access by a regular user you need to add them to the dialout group. As root or sudo

usermod -a -G dialout username
 
Old 07-16-2018, 09:39 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by JHugh View Post
Yeah. I am using RHEL, but it was installed by my IT, so I don't have a user account with RH to get support and my IT says they cannot give me the credentials I need. How would I configure my tty ports to be recognized and accessed by all users? That does seem like the most secure way to approach this problem, instead of just bashing it with root.
Well if you don't have the credentials, then that's a thing your IT people need to deal with. They can configure the menu application to run as root using the sudo command, but you cannot configure that if you don't have the credentials. And you cannot configure the tty ports to have different permissions without root credentials, either.

Simplest thing would be for your IT people to configure your system to have the tty port permissions to be set correctly after each boot. Then you run LabView as your regular user and be done. If you have IT people, that's a job for them, because you can't configure ANYTHING without the root password in this instance.
 
Old 07-16-2018, 10:01 AM   #11
JHugh
Member
 
Registered: Jul 2017
Posts: 33

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
I assume by tty port this is a serial port and to allow access by a regular user you need to add them to the dialout group. As root or sudo

usermod -a -G dialout username
I tried that command before and it seemed to do nothing, since I still can't see the serial ports. I tried restarting after I ran the command.

TERMINAL COMMANDS:
Code:
[hughj@delisserlinuxrh7 ~]$ sudo usermod -a -G dialout hughj
[hughj@delisserlinuxrh7 ~]$ whoami
hughj
[hughj@delisserlinuxrh7 ~]$ groups
hughj wheel
I also ran:
Code:
cut -d: -f1 /etc/group | sort
And dialout does appear in the list. My IT told me that the group wheel should have sudo rights.

Did I miss something?

@TB0ne My IT does not have that much experience with Linux, so they are not very helpful, but I do have the root/sudo password, so I can configure anything that I want to configure. I just need to know the commands to do it
 
Old 07-16-2018, 10:08 AM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by JHugh View Post
I tried that command before and it seemed to do nothing, since I still can't see the serial ports. I tried restarting after I ran the command.
TERMINAL COMMANDS:
Code:
[hughj@delisserlinuxrh7 ~]$ sudo usermod -a -G dialout hughj
[hughj@delisserlinuxrh7 ~]$ whoami
hughj
[hughj@delisserlinuxrh7 ~]$ groups
hughj wheel
I also ran:
Code:
cut -d: -f1 /etc/group | sort
And dialout does appear in the list. My IT told me that the group wheel should have sudo rights. Did I miss something?
Nope. You added your user to the dialout group.
Quote:
@TB0ne My IT does not have that much experience with Linux, so they are not very helpful, but I do have the root/sudo password, so I can configure anything that I want to configure. I just need to know the commands to do it
Since you DO have root/sudo access, that makes things easier. After running it and logging out/back in, did you run your software then? If so, what message(s) did you get? Because the tty ports *SHOULD* be read/write for the dialout group, of which you're a member. But, how are these serial ports connected? Because if you have a USB-to-serial device (common these days), the ttyUSBx ports may NOT be part of the dialout group, which may explain your lack of visibility on those ports.

As a test, go to a terminal, and type in "sudo chmod 777 /dev/tty*", and then see if things work. If so, then that narrows things down, and we can look at individual port permissions from there.
 
1 members found this post helpful.
Old 07-16-2018, 12:29 PM   #13
JHugh
Member
 
Registered: Jul 2017
Posts: 33

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Nope. You added your user to the dialout group.

Since you DO have root/sudo access, that makes things easier. After running it and logging out/back in, did you run your software then? If so, what message(s) did you get? Because the tty ports *SHOULD* be read/write for the dialout group, of which you're a member. But, how are these serial ports connected? Because if you have a USB-to-serial device (common these days), the ttyUSBx ports may NOT be part of the dialout group, which may explain your lack of visibility on those ports.

As a test, go to a terminal, and type in "sudo chmod 777 /dev/tty*", and then see if things work. If so, then that narrows things down, and we can look at individual port permissions from there.
Running "sudo chmod 777 /dev/tty*" from the terminal worked!

Thanks.

One last similar question, which I'm going to need to configure also soon.

How can I do the same thing (give read/write to all) with an Ethernet port?

I am going to need to connect my Linux computer to a Windows computer through Ethernet for testing my program and right now I cannot ping either computer, so I figure it could be a permission problem.

Thanks!
 
Old 07-16-2018, 12:34 PM   #14
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,622

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by JHugh View Post
Running "sudo chmod 777 /dev/tty*" from the terminal worked! Thanks.
You're welcome, but PLEASE view that as a test step only. The 'fix' is to figure out how to do it WITHOUT putting things into an insecure state. As asked before, how is this serial device connected??? USB-To-Serial? And post the results of an "ls -l /dev/tty*" (or just the applicable tty device that your LabVIEW software looks for).
Quote:
One last similar question, which I'm going to need to configure also soon. How can I do the same thing (give read/write to all) with an Ethernet port? I am going to need to connect my Linux computer to a Windows computer through Ethernet for testing my program and right now I cannot ping either computer, so I figure it could be a permission problem.
No, network devices don't work that way. If you can't ping, it's because:
  • You don't have a network route to the network(s) in question
  • You have a firewall/network security in place that prevents it
Whether your IT people like it or not, they need to support your device TOTALLY, or they need to take their hands off of it, and give you full permission to do whatever you need. Not half-way. Your network admins need to answer what networks the two machines are on (such as their IP addresses), then determine if pings (that is, ICMP) is allowed on your network.
 
Old 07-16-2018, 12:43 PM   #15
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Networking should be available to all users and there are many reasons that ping can fail. I agree there should be a way to allow a regular user to access the serial port without setting permissions to 777.

When you say you can not ping either computer does that imply the RHEL running labVIEW? Are you pinging by hostname or IP address?
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] User permitted to run command,execute program as root and after execution, exit root vjlxmi Linux - Newbie 12 04-17-2015 06:30 AM
[SOLVED] How to allow access to some commands having root privleges to be run bu non root user suryashikha Linux - Newbie 8 10-31-2009 01:05 PM
How can I have a script owned as root and run as root by a user: setuid? stickey bit? abefroman Linux - Newbie 9 04-19-2008 05:15 PM
why lftp command run failed when user isn't root, but ok when logining as root steven_yu Linux - Software 0 06-06-2007 08:36 PM
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 08:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 02:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration