Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
Showing results for 
Search instead for 
Did you mean: 




1.what is the commandline to print all the hidden files in the current working directory sorted in reverse alphabetical order?

2.what is the command line to print the usernames that have active processes running on the system.The commandline should print the user names only once(no repetition).

thanks in advance....
Khalid A. Al-Tayaran
Valued Contributor

Re: commandline


ls -ahl (on RedHat)


ps -euf | more
ps -eu | more

Jerome Henry
Honored Contributor

Re: commandline

Whow !
You were tough with Khalid, who did give you the corract answer :-))
'ls' is command for listing current directory, and you had arguments with '-' to precise the command :
-a says to show also hidden files, starting with . (you didn't precise if you needed to see only those file, so we assume that you want to see them all)
-h is not necessary, but asks that sizes are printed in human readable format (kb, mb instead of bytes only)
-l uses long listing format.
He left behind 'r', which completes your need by printing those files in reverse order. Your answer comes to :
ls -alr
If you want only hidden files to be sorted, then you have to go a little further, on sorting only those files by the 'grep' command :
'ls -alr | grep .'
Same as before, sorting only what include that hidden code, '.'.

Same for second command : I would use a slight variation :
ps command of course, to list processes running.
I would add :
-a to list them all (even those not belonging to you)
-u to sort by user
-x to select processes without controlling ttys.
I would use for your confort a redirection to 'sort', to have them once (no repetition), with -d for example to get them in alphabetical order.
Your command becomes :
'ps -aux | sort -d'.

Note that you can precise on 'ps' '--user' to select by effective user name or ID.
You can lean only on what resists you...
Charles Coombs
Occasional Advisor

Re: commandline

A general piece of advice regarding unix commands. Try using man, it is a beautiful thing and one of the things that can get you adjusted to linux command line (presumably you are getting wheened off windoze).

e.g. type this at command prompt:

man ls

Tells you everything you needed. Between man and an understanding of pipes, |, the world is your oyster.

Run-of-the-mill dumbfounded J2EE developer.
Khalid A. Al-Tayaran
Valued Contributor

Re: commandline


// No Points Please //

Thanks Jerome.... Good detailed answer.