LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-10-2003, 12:27 PM   #1
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
whoami question


I'm (attempting) to write a bash script to do some of my more common tasks on boot up...however, I need to know which user is currently logged in, which theoretically I can do by running 'whoami'....but what exactly does that return? I mean,
Code:
if [ "whoami" = "<username here>" ]; then
doesn't work...no error message, but no result, either. What am I doing wrong?
 
Old 01-10-2003, 01:02 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Because on system boot you are not logged in as a user.
Can you give us a clue what you're trying to do?
 
Old 01-10-2003, 01:18 PM   #3
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
all I really want to do is run wmsetbg <insert image file here> to set my desktop background (silly, I know, but asthetics have their benefits)...but I don't want to run it for any other user except me...they can do their own shell scripting
Is this possible?
 
Old 01-10-2003, 01:19 PM   #4
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
btw, Mandrake 9.0 w/ Windowmaker (most of the gnome libraries are installed, though, to make my software-installing life easier)
 
Old 01-10-2003, 01:53 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Putting the command in your ~/.Xclients-default or ~/.xinitrc should work.
 
Old 01-10-2003, 02:01 PM   #6
taivu
LQ Newbie
 
Registered: Oct 2002
Location: Spain
Distribution: Ubuntu, Debian Sarge, FreeBSD
Posts: 19

Rep: Reputation: 0
Can you not use $UID, which contains the Unix (numerical) UID?
 
Old 01-10-2003, 02:31 PM   #7
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
ok, to the last two posts: does ~/.xinitrc only run when I log in?? (yes, I know it's in home, but I'm still a little new at this so humor me please :-/ )If so, wunderbar, thankyouverymuch, problem solved :-D
But just for the sake of learning something new, taivu, how do I find out what my own UID is?
 
Old 01-10-2003, 02:53 PM   #8
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
it is stored in your /etc/passwd as the third field in the line that starts with your loginname.
OR
use id from the command prompt.

id <loginname> to find out someone elses userid and primary group id
groups <loginname> to find out the groups that <loginname> belongs to.
 
Old 01-10-2003, 03:03 PM   #9
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
thanks much!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM
samba smb.config question (quick question) TheDOGG Linux - Networking 1 03-02-2004 07:19 AM
whoami jovo jovo LinuxQuestions.org Member Intro 2 07-31-2003 05:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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