LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-11-2015, 02:59 AM   #1
fetal
Member
 
Registered: Nov 2011
Distribution: Ubuntu 16.04
Posts: 34

Rep: Reputation: Disabled
Using sudo with tab complete


Using Centos.

I'm logged in as user bob. How do I configure tab completion with sudo
to access user tom's files, or roots.

Thanks!
 
Old 12-11-2015, 03:41 AM   #2
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Using sudo with tab complete

It depends on your PATH variable.

For temporary add use export.
For permanent edit .bashrc

I'd rather use su imho...
 
Old 12-11-2015, 04:02 AM   #3
fetal
Member
 
Registered: Nov 2011
Distribution: Ubuntu 16.04
Posts: 34

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Tonus View Post
It depends on your PATH variable.

For temporary add use export.
For permanent edit .bashrc

I'd rather use su imho...

Could you elaborate?
Unfortunately su is not an option

This is the contents of /etc/sudoers

bob ALL=(ALL:ALL) NOPASSWD: ALL, !/bin/su
 
Old 12-11-2015, 12:06 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
That tab completion is being performed by your current shell, which might not even have read access to other users' home directories. Without that, there's no way it could do tab completion for file names there. Even with read access, it's asking a lot to expect the shell to know ahead of time what the CWD will be when that command runs and expand the names of files that are there. It's like typing
Code:
cd /var/log; tail messag[TAB]
and expecting that to expand to "messages". Sorry, but the shell is working in the here and now, not in some future environment.

That said, you can do a lot of tricky things in /etc/bash_completion.d, but setting that up to do anything like what you are asking is a bit beyond my pay grade.
 
Old 12-11-2015, 12:14 PM   #5
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Using sudo with tab complete

To have autocomplete, add what you want to be autocompleted to your path.

Type the command then go to beginning of the line and add sudo
 
  


Reply

Tags
centos, sudo, tab



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
Tab does not auto-complete in terminal General Fedora 8 09-12-2013 01:48 AM
How can I disable autocomplete or tab complete? JeffreyMoore Linux - General 4 11-09-2008 06:12 PM
Bash script using tab complete sadarax Programming 6 01-30-2007 08:21 PM
having tab key complete the filename rajeev1982 AIX 1 05-11-2006 01:58 PM
tab complete Frustin AIX 4 07-19-2004 02:31 AM

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

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