LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-23-2012, 09:54 AM   #1
raverz1
LQ Newbie
 
Registered: Jun 2012
Posts: 3

Rep: Reputation: Disabled
Running super command at login in one line


Good morning everyone,
I've been trying to figure this out for a few hours now and hopefully somebody can point me in the right direction. I am logging in remotely to a linux box using plink from a windows box to run some scripts. The issue im having is that when I log into the linux box it requires that the super command be issued to get from the SERVERNAME$ to the SERVERNAME# prompt. Ive tried su - username -c and also su root -c but it didnt work. As a test I was using the command cat /var/log/messages because this is a root access log file. It works for the username account (and of course for root) from the SERVERNAME# prompt. I need to find a way to loging to the linux box all in one line directly to the SERVERNAME# prompt. Any assistance that could be provided would be greatly appreciated.
 
Old 06-23-2012, 10:02 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Couple of things:

1) su stands for "switch user", not "super user"
2) a prompt is just a prompt, you can make it look like anything just by setting an environment variable, it's completely customizable. There's nothing special about a prompt that ends in # versus one that ends in $.

So how do you switch from your regular login to the login that grants you the access you want? You said that "su - username -c" and "su root -c" don't work, so what does work? What distro is this?

It sounds like all you're doing is issuing "su", which is switching you to root. In that case, what you're actually looking for is a way to SSH into the machine as root, which is not advisable.

Last edited by suicidaleggroll; 06-23-2012 at 10:05 AM.
 
Old 06-23-2012, 10:05 AM   #3
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
I believe the OP just wants to switch to root.
It can be done simply by issuing
Code:
su
or
Code:
su -
if the environment should be reset to that of a just logged in root user.
 
1 members found this post helpful.
Old 06-23-2012, 11:26 AM   #4
raverz1
LQ Newbie
 
Registered: Jun 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
SSH as root

This is a Red Hat 5 box. Forgive me if im not using the correct terminology. Im not completely Linux literate. I have verified that the account I am using is a super-user account. When I use putty and login to the box it brings me to the normal terminal command line SERVERNAME$. At this prompt if i type the following command cat /var/log/messages I get permission denied. I have also issued the su username -c cat /var/log/messages and su root -c cat /var/log/messages to which I receive permission denied. Only after i have typed super am I able to issue any of these commands and get a response. Once again I apologize for any inaccuracies or incorrect terminoly. I am learning slowly.
 
Old 06-23-2012, 12:10 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
When you use the -c flag to su, you need to put the command in quotes:
Code:
su root -c "cat /var/log/messages"
This should prompt you for a password, and if you enter it correctly it should work.

There is only one super-user account, and that is root.

I have never heard of the "super" command.

Maybe it would help to post what's going on in your terminal, IE:
Code:
user@hostname:~> tail -n 1 /var/log/messages
tail: cannot open `/var/log/messages' for reading: Permission denied
user@hostname:~> su root -c "tail -n 1 /var/log/messages"
Password:
Jun 23 11:08:32 hostname su: (to root) user on /dev/pts/0
user@hostname:~> su -
Password:
hostname:~ # tail -n 1 /var/log/messages
Jun 23 11:08:44 hostname pure-ftpd: (ftpuser@IP) [INFO] Logout.
 
1 members found this post helpful.
Old 06-23-2012, 02:18 PM   #6
raverz1
LQ Newbie
 
Registered: Jun 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
SSH to root

What I meant by super-user account was an account with comparable permissions to root. Thank you for all of your assistance and dealing with my lack of knowledge. I added the quotes around the command and it seems to have worked. A few hours of annoyance for quotation marks. I appreciate everything. Have a great day.
 
  


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
How to login to command line mossen Ubuntu 5 11-14-2011 02:03 AM
unable login via GUI but can login via Putty (command line) linuxandtsm Linux - Newbie 10 06-09-2011 02:08 PM
Fedora 15 command line login asifbasha Linux - Newbie 1 05-30-2011 11:14 AM
how do i get just a command line after login? Compton420 Linux - Newbie 7 09-18-2004 09:13 PM
Changin Graphical Login to command line login 3DLirio Linux - Newbie 2 10-16-2003 09:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:32 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