HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Automate switch user
Operating System - Linux
        1839903
        Members
    
    
        4196
        Online
    
    
        110157
        Solutions
    
Forums
        Categories
Company
Local Language
                
                  
                  back
                
        
                
        
                
        
                
        
        
        
                
        
                
        
        
        
                
        
              
              Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
                
                  
                  back
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
            
                
            
                
            
                
            
                
            
            
                
            
                
            
            
                
            
                
              
            Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
        Information
        Community
Resources
Community Language
        Language
        Forums
Blogs
	
		
			
            
                
            Go to solution
        
            
		
		
			
            	
	
		
        
		
	
	
		Topic Options
			
				
					
	
			
		
	- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2010 03:52 AM
07-05-2010 03:52 AM
			
				
					
					
						Hi, it's possible to automate the use of "su" command??
I refer to the issue of the introduction of the password.
There is something like this:
su - username/password???
Thanks.
	
			
				
		
			
			
			
			
			
			
		
		
		
	
	
	
I refer to the issue of the introduction of the password.
There is something like this:
su - username/password???
Thanks.
Solved! Go to Solution.
		3 REPLIES 3
	
	            
            
		
		
			
            
                - Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2010 08:18 AM
07-05-2010 08:18 AM
			
				
					
						
							Re: Automate switch user
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						You can use "sudo" instad of su. Or maybe a combination of both, for example:
sudo su - user -c "command"
You need to configure the sudoers file with the visudo command.
Check for information about sudo in google.
Cheers.
		
		
	
	
	
sudo su - user -c "command"
You need to configure the sudoers file with the visudo command.
Check for information about sudo in google.
Cheers.
	Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
			
			
				
			
			
			
			
			
			
		- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2010 09:26 AM
07-05-2010 09:26 AM
Solution
			
				
					
					
						Combining su and sudo means you're first transitioning to root, and then to target user. The logs will reflect that. Sometimes, seeing a message about JoeUser becoming root can cause undue agitation in security auditors.
If you have a relatively modern version of sudo, the effect of:
sudo su - -c 
can be exactly replicated with:
sudo -u -i 
It will also consolidate all the essential information into one log line: JoeUser becomes for the purpose of running the .
Of course, to use "sudo -i" effectively, your sudoers file must be written to say what you really mean: instead of
JoeUser ALL=(root) su - 
you should write:
JoeUser ALL=() ALL
If you need to allow JoeUser to execute a particular command automatically, without prompting a password, you might write:
JoeUser ALL=() NOPASSWD: 
(OK, I admit: this is my pet peeve. But I see "sudo su - ..." as a nothing more than a bad habit, encouraged by sloppy sudoers rule writing practices.)
MK       
					
				
			
			
				
		
		
	
	
	
If you have a relatively modern version of sudo, the effect of:
sudo su -
can be exactly replicated with:
sudo -u
It will also consolidate all the essential information into one log line: JoeUser becomes
Of course, to use "sudo -i" effectively, your sudoers file must be written to say what you really mean: instead of
JoeUser ALL=(root) su -
you should write:
JoeUser ALL=(
If you need to allow JoeUser to execute a particular command automatically, without prompting a password, you might write:
JoeUser ALL=(
(OK, I admit: this is my pet peeve. But I see "sudo su - ..." as a nothing more than a bad habit, encouraged by sloppy sudoers rule writing practices.)
MK
	MK
			
			
				
			
			
			
			
			
			
		- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2010 10:05 PM
07-05-2010 10:05 PM
			
				
					
						
							Re: Automate switch user
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						THX.
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
		
		
	
	
	
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
		
	
	
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP
