LinuxQuestions.org
Visit Jeremy's Blog.
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 12-27-2012, 12:27 AM   #1
figure20012
Member
 
Registered: Apr 2012
Posts: 75

Rep: Reputation: Disabled
sudo ls /root/* does not work


sudo ls /root/*
ls: cannot access /root/*: No such file or directory

Can anyone please help me
 
Old 12-27-2012, 12:54 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
You need to invoke a shell to do the pathname expansion for "*". As you have it written, sudo invokes the ls command directly, not through a shell, so ls is trying to find a file named literally "*" in the /root directory. You need to do it this way:
Code:
sudo sh -c "ls /root/*"
 
1 members found this post helpful.
Old 12-27-2012, 05:02 AM   #3
RaviTezu
Member
 
Registered: Nov 2012
Location: India
Distribution: Fedora, CentOs, RHEL
Posts: 164

Rep: Reputation: 24
You can simply use the following command to list the files/directories in /root.
Quote:
sudo ls -l /root/
 
2 members found this post helpful.
Old 12-27-2012, 05:25 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Or, in two steps:
Code:
sudo bash
ls /root/
 
1 members found this post helpful.
Old 12-27-2012, 07:12 AM   #5
figure20012
Member
 
Registered: Apr 2012
Posts: 75

Original Poster
Rep: Reputation: Disabled
thanks a lot for helping
Love Linux
 
  


Reply

Tags
sudo



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
sudo: effective uid is not 0, is sudo installed setuid root? awladnas Linux - Newbie 10 08-30-2014 06:03 PM
[SOLVED] Arg! Virtual machine, sudo won't work, can't log in as root, visudo won't work Arg! edpatterson Linux - Newbie 2 01-03-2012 05:33 PM
Can't use sudo, only account that's not root is not a sudo'ers [Ubuntu 9.10] randyriver10 Linux - Desktop 1 01-09-2010 07:56 PM
alsa work with root or sudo but not user walterbyrd Linux - Hardware 5 10-24-2005 01:53 PM
root password doesn't work when I use sudo ... bucovaina78 Linux - Security 5 11-10-2004 02:50 PM

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

All times are GMT -5. The time now is 03:12 AM.

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