Operating System - HP-UX
1753254 Members
4708 Online
108792 Solutions
New Discussion юеВ

Re: ls -A, problem with hidden files

 
maki hakapeszi
Occasional Advisor

ls -A, problem with hidden files

'ls -A' behaves different, if you're root

For example:
/home/oper/test#whoami
oper
/home/oper/test#touch '.hiddenfile'
/home/oper/test#ls -A
.hiddenfile
/home/oper/test#sudo su
/home/oper/test#ls -A
/home/oper/test#
/home/oper/test# ls
.hiddenfile

If you are root, 'ls -A' doesn't list hidden files.

Thanks

Maki
HP-UX B.11.31 U ia64
7 REPLIES 7
Patrick Wallek
Honored Contributor

Re: ls -A, problem with hidden files

Apparently the '-A' is a "switch" that turns the display of hidden files on or off.

Note the 'ls' man page entry for '-A'

-A The same as -a, except that the current directory . and parent directory .. are not listed. For a user with appropriate privileges, this flag defaults to on, and is turned off by -A.

In a nutshell -- Since root already has the ability to display hidden files, the '-A' switch turns OFF the display of hidden files.
likid0
Honored Contributor

Re: ls -A, problem with hidden files

From man:

-A The same as -a, except that the current directory . and
parent directory .. are not listed. For a user with
appropriate privileges, this flag defaults to on, and is
turned off by -A.
Windows?, no thanks
vishnu.khandare
Respected Contributor

Re: ls -A, problem with hidden files

Hi Maki,

Use ls with -a option,

As -A option : -A The same as -a, except that the current directory . and parent directory .. are not listed. For a user with
appropriate privileges, this flag defaults to on, and is
turned off by -A.


Regards
Vishnu Khandare
You should deserve before U desire!!!!
maki hakapeszi
Occasional Advisor

Re: ls -A, problem with hidden files

Thank you for fast reply.

Would you define the user 'with appropriate privileges', is it only root?


Thanks
Maki


Pete Randall
Outstanding Contributor

Re: ls -A, problem with hidden files

A user with "appropriate privileges" would be root or the owner.


Pete

Pete
Pete Randall
Outstanding Contributor

Re: ls -A, problem with hidden files

Actually, in the case of the on/off behavior of the switch, I think the only users this applies to would be root, as shown in your initial test.


Pete

Pete
maki hakapeszi
Occasional Advisor

Re: ls -A, problem with hidden files

Thank you.