To list just directories, use this command:
ls -l | egrep '^d'
If you just want the directories name without detail, then use this command:
ls -l | egrep '^d' | awk '{print $NF}'
To list just files, use this command:
ls -l | egrep -v '^d'
If you just want the file names without detail, then use this command:
ls -l | egrep -v '^d' | awk '{print $NF}'
Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts
Thursday, April 25, 2013
Wednesday, April 10, 2013
"su: No directory!" and "su: No shell" error
Problem:
You can log in as root, but when you try to switch to other user by running "su - username", you get "su: No directory!" error.
example:
command ran:
su - testuser
error:
su: No directory!
You also get "su: No shell" error when you try to run a command as a user by running " su username -c 'echo test' "
example:
su testuser -c 'echo test'
error:
su: No shell
Solution:
The permission on / is set up incorrectly. you probably have drwx for /. Other user need to have execute permission on / in order to solve this problem.
you can fix this by running this command:
chmod o+x /
Old permission:
# ls -la /
drwx------ 19 root root 22 Sep 28 2009 .
drwx------ 19 root root 22 Sep 28 2009 ..
New permission:
# ls -la /
drwx-----x 19 root root 22 Sep 28 2009 .
drwx-----x 19 root root 22 Sep 28 2009 ..
You can log in as root, but when you try to switch to other user by running "su - username", you get "su: No directory!" error.
example:
command ran:
su - testuser
error:
su: No directory!
You also get "su: No shell" error when you try to run a command as a user by running " su username -c 'echo test' "
example:
su testuser -c 'echo test'
error:
su: No shell
Solution:
The permission on / is set up incorrectly. you probably have drwx for /. Other user need to have execute permission on / in order to solve this problem.
you can fix this by running this command:
chmod o+x /
Old permission:
# ls -la /
drwx------ 19 root root 22 Sep 28 2009 .
drwx------ 19 root root 22 Sep 28 2009 ..
New permission:
# ls -la /
drwx-----x 19 root root 22 Sep 28 2009 .
drwx-----x 19 root root 22 Sep 28 2009 ..
Redirect nohup output to another file
Normally, nohup save the output to nohup.out file. But you can change that using the following command:
nohup some_command > nohup_new_output.out 2>&1&
Subscribe to:
Posts (Atom)