'sudo ls /root/monitor/' outputs, 'sudo ls /root/monitor/*' does not
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
'sudo ls /root/monitor/' outputs, 'sudo ls /root/monitor/*' does not
Hi:
Code:
semoi@host_1:/almacen/SLACK10$ sudo ls /root/monitor/
README kbd_monitor kbd_monitor.c read_keyboard_status.txt
semoi@host_1:/almacen/SLACK10$ sudo ls /root/monitor/*
ls: cannot access /root/monitor/*: No such file or directory
semoi@host_1:/almacen/SLACK10$
Who is to blame (maybe me)? Anything to do with globbing? Thanks in advance.
GNU bash, version 3.1.17(2)-release (i486-slackware-linux-gnu)
Slackware 12.0
semoi@host_1:/almacen/SLACK10$ sudo ls /root/monitor/
README kbd_monitor kbd_monitor.c read_keyboard_status.txt
semoi@host_1:/almacen/SLACK10$ sudo ls /root/monitor/*
ls: cannot access /root/monitor/*: No such file or directory
semoi@host_1:/almacen/SLACK10$
Who is to blame (maybe me)?
GNU bash, version 3.1.17(2)-release (i486-slackware-linux-gnu)
Slackware 12.0
Hi std02,
I guess your shell tries to expand the "*" before actually invoking the ls command with superuser rights. For example, compare the outputs of these two commands:
echo /tmp/*
echo "/tmp/*"
I have been playing with different incarnations of this. Unexpected shell expansions are a common stumbling block.
Invoking a new shell still has some surprises.
Unless there is some good reason for not using ls /root/monitor/ (without the splat), just use that form, or su to root.
[EDIT]
It is important to note that the cause is NOT something "wrong".
It is just too many cooks in the kitchen - sudo, bash, ls, CWD - with conflicting jobs and precedence order. Instead of forcing them to all work on the same omlette, simplify the task (use the one that works) or step into the next kitchen (su to really be root).
[/EDIT]
I was trying to sudo cp from /root/monitor to semoi's dir and, of course, with the same problem. But I presume that would leave root's permissions there. As this is a recent reinstalation perhaps I did something different.
I was trying to sudo cp from /root/monitor to semoi's dir and, of course, with the same problem. But I presume that would leave root's permissions there. As this is a recent reinstalation perhaps I did something different.
Well, on my system, the following works just fine:
sudo bash -c "cp /root/install/* ."
(/root/install/ contains some files I installed as root such as nvidia drivers)
On second thought, maybe I had never used such a command before. I'll have to use double quotes then or to adhere to astrogee's advice. Thanks for the posts.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.