-
two more questions
1: What exactly is a Shadow Password?
I know that when using a setuid program in the example of a program to allow a user to change their own password, it changes the contents of /etc/passwd and /etc/shadow so what is the shadow password exactly?
2: say I have a script like
foreach arg (*)
if (-d $arg)
echo $arg
endif
end
which lists all directory files under the current working directory, is that correct? and if so how would it differ if I wanted it to list all file names under a directory? what about just executable files?
Would this script differ if I was using bash instead of tcsh?
Thats my final question and thank you for your time
-
can I also just add, what would your write for a script that is to list all symbolic links under your home directory if the command line argument lnk exists
heres what I would think:
foreach arg (argv[*])
if (arg == "lnk")
and then somehow print out just symbolic links if any, would that just be: echo -l
???
Thanks
-
Bash has not foreach.
This lists all directories in current directory:
Code:
for arg in *; do
if [ -d $arg ]; then
echo $arg;
fi;
done
If you want to list symbolic links, use -L instead of -d. See man test for all of the parameters.
Note that [ something ] is similar to test something.
-
Thanks
If I was to have the shell script run only when the command line argument "something" is entered
would I do it like this for tcsh:
if (arg == "something") then
cd $argv
foreach arg (*)
echo $arg
endif
end
-
Did you want to check every argument and bash or tcsh?
Code:
#!/usr/bin/env tcsh
foreach arg ($argv)
if ($arg == "something") then
echo "something entered as an argument"
break
endif
end
Code:
#!/usr/bin/env bash
for arg in $*
do
if [ $arg == "something" ];then
echo "something entered as an argument"
break
fi
done
I just noticed your first queston. ;) /etc/shadow is a separate file from /etc/passwd and normal user has no reading permission to it unlike to /etc/passwd. Passwords are now stored there using some not-so-secure des encryption. That is why only root has right to read that file.
-
Thank you so much, I am studying for an exam and these were a few specifics I was still unclear on.