Unable to list folder contents | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Unable to list folder contents

UNIX for Dummies Questions & Answers


Tags
bash, filesystem, linux, shell commands, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-10-2013
pmn pmn is offline
Registered User
 
Join Date: Nov 2013
Last Activity: 10 December 2013, 5:27 PM EST
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Linux Unable to list folder contents

I'm unable to list the contents of a directory once I move into it. I have full permissions on this directory (called "Scripts" in the below example). The scenario is shown below in detail:


Code:
Command 'ls' works fine to begin with:

1: pmn@linuxhost /home/pmn > cd /opt/smt/proiv
2: pmn@linuxhost /opt/smt/proiv > ls -ld scripts/
drwxrwxrwx 24 smt smt 69632 Nov 11 10:58 scripts/
3: pmn@linuxhost /opt/smt/proiv >

3: pmn@linuxhost /opt/smt/proiv > ls scripts | wc -l
850
4: pmn@linuxhost /opt/smt/proiv >

4: pmn@linuxhost /opt/smt/proiv > ls scripts/
-ef                                       btfg2rbc.sh.back                menu_utilities                         QA_FAS
ALL                                       btfg_file.bkup                  menus                                  QA_RFS
CDIFF                                     btfg_file.sh                    audit.sh                               RACPOC_RFS
...
...
5: pmn@linuxhost /opt/smt/proiv >

Once I move into the "scripts" directory, the ls command is not able to list anything, anywhere! This is shown below...


Code:
Command 'ls' unable to display anything:

6: pmn@linuxhost /opt/smt/proiv > cd scripts/
7: pmn@linuxhost /opt/smt/proiv/scripts > ls -ld
8: pmn@linuxhost /opt/smt/proiv/scripts > ls -lart
9: pmn@linuxhost /opt/smt/proiv/scripts > ls
10: pmn@linuxhost /opt/smt/proiv/scripts > ls | wc -l
0
11: pmn@linuxhost /opt/smt/proiv/scripts >
11: pmn@linuxhost /opt/smt/proiv/scripts > ls -lart /tmp | wc -l
0
12: pmn@linuxhost /opt/smt/proiv/scripts > ls -lart / | wc -l
0
13: pmn@linuxhost /opt/smt/proiv/scripts >

However, when I move into another directory (which is either a sub-directory of "Scripts" or outside), the ls command starts working.


Code:
Command 'ls' works fine here on:

 1. From directory "menus" that is a sub-directory of "Scripts": 

13: pmn@linuxhost /opt/smt/proiv/scripts > cd menus/
14: pmn@linuxhost /opt/smt/proiv/scripts/menus > ls  | wc -l
50
15: pmn@linuxhost /opt/smt/proiv/scripts/menus > ls
accounts_sqlplus.menu       dev_mlm.menu                   main.menu          reg_main.menu         sqlplus.menu                 
...
...
16: pmn@linuxhost /opt/smt/proiv/scripts/menus >

16: pmn@linuxhost /opt/smt/proiv/scripts/menus > ls -lart /tmp | wc -l
180
17: pmn@linuxhost /opt/smt/proiv/scripts/menus >

17: pmn@linuxhost /opt/smt/proiv/scripts/menus > ls -lart / | wc -l
42
18: pmn@linuxhost /opt/smt/proiv/scripts/menus >


 2. From my home directory which is outside of "Scripts": 

From my home directory which is outside of "Scripts":
19: pmn@linuxhost /home/pmn > ls -lart /tmp | wc -l
180
20: pmn@linuxhost /home/pmn > ls
screen_test.sh  test1
21: pmn@linuxhost /home/pmn >

21: pmn@linuxhost /home/pmn > id -a
uid=4471(pmn) gid=1000(ccusers) groups=351(fsdev),381(epdev),610(devl),1000(ccusers)
22: pmn@linuxhost /home/pmn >

I'm not the owner of Scripts, nor am I in the "smt" group - however, the folder permissions on "Scripts" indicate full access to anyone. Despite this, ls doesnt work - which I'm unable to explain. Does anyone know the answer to this?
Sponsored Links
    #2  
Old 11-11-2013
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 20 August 2014, 3:34 PM EDT
Location: Switzerland - GE
Posts: 5,634
Thanks: 152
Thanked 387 Times in 366 Posts
Can you show me your PATH content?
my 2 cents:
You could imagine having: PATH=.:$PATH
if now in /opt/smt/proiv/scripts you would have a script with perms 755 called ls with content: echo
What would you thing you would see when you go in that directory and type?

Code:
 ls
ls -al
ls -lrt
...

P.S.
(my env is for ksh, please adapt to your shell...
The Following 3 Users Say Thank You to vbe For This Useful Post:
pmn (11-12-2013), rajesh4you (11-12-2013), wisecracker (11-13-2013)
Sponsored Links
    #3  
Old 11-12-2013
pmn pmn is offline
Registered User
 
Join Date: Nov 2013
Last Activity: 10 December 2013, 5:27 PM EST
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Linux

Brilliant! That was exactly the reason! My path variable did have a "." in it before the system bin folders, thus pulling in a local (empty) file from the Scripts folder called 'ls'!

Thanks, vbe.


Code:
4: pmn@linuxhost  /home/pmn > echo $PATH
/opt/rational/projects/ruby/bin:.:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/sbin:/home/pmn/bin:/opt/oraclest/product/11.1.0/client/bin
5: pmn@linuxhost  /home/pmn >

5: pmn@linuxhost  /home/pmn > cd /opt/smt/proiv/scripts/
6: pmn@linuxhost  /opt/smt/proiv/scripts > which ls
alias ls='ls --color=tty'
        ./ls
7: pmn@linuxhost  /opt/smt/proiv/scripts > /bin/ls -lart | wc -l
856
8: pmn@linuxhost  /opt/smt/proiv/scripts >

8: pmn@linuxhost  /opt/smt/proiv/scripts > /bin/ls -lart ls
-rwxrwxrwx 1 smt smt 0 Apr 21  2009 ls
9: pmn@linuxhost  /opt/smt/proiv/scripts >

    #4  
Old 11-12-2013
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 20 August 2014, 3:34 PM EDT
Location: Switzerland - GE
Posts: 5,634
Thanks: 152
Thanked 387 Times in 366 Posts
Your welcome!
Youve learned now why you should avoid dot in PATH for root... ( or if really necessary, be at the end...), otherwise you could very well be a victime of spoofing...
Sponsored Links
    #5  
Old 11-12-2013
pmn pmn is offline
Registered User
 
Join Date: Nov 2013
Last Activity: 10 December 2013, 5:27 PM EST
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Linux

I agree.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Folder contents getting appended as strings while redirecting file contents to a variable vivek d r Shell Programming and Scripting 2 03-29-2013 04:13 AM
How to copy all the contents of a list of files present in a folder to a particular file? Pranav Bhasker Shell Programming and Scripting 3 03-04-2013 07:37 AM
copy folder and its contents to another folder amvarma77 Shell Programming and Scripting 1 06-06-2012 08:50 AM
dtterm to list a folder contents in new window golfcents UNIX for Dummies Questions & Answers 4 06-03-2011 07:41 PM
Folder Contents spencer UNIX for Dummies Questions & Answers 6 07-11-2003 07:48 AM



All times are GMT -4. The time now is 04:26 PM.