LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 01: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, 01:54 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,959

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
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, 06: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, 06:25 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 2,955

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
Or, in two steps:
Code:
sudo bash
ls /root/
 
1 members found this post helpful.
Old 12-27-2012, 08: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07: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 06: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 08:56 PM
alsa work with root or sudo but not user walterbyrd Linux - Hardware 5 10-24-2005 02:53 PM
root password doesn't work when I use sudo ... bucovaina78 Linux - Security 5 11-10-2004 03:50 PM


All times are GMT -5. The time now is 06:51 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration