Recently, I was going through some *nix questions and I stuck on few ones.
Can you guys help me on these?
*These are the questions:*
* Identify which IP address and port the Apache daemon listens on.
Is it a valid solution? I think by scanning on port 80 using nmap we can
find out what ip's apache daemon listens. Perhaps, I could be wrong.
Correct me if I am mistaken.
# nmap -sS -O -p 80 <web server ip>
* Find all IP addresses between your server and www.google.com
* Create an empty directory and change the permissions so that the owner
can execute, read and write, the group can execute and read and the others
cannot do anything.
# mkdir demo && chmod 750 demo
* Print all the lines from /var/log/demon.log having the string ntp and NTP
but not NtP.
* Write a shell script to get the third element delimited by ":" from a
file (passing the file name as an argument to the script) and the format of
the file is same as of /etc/passwd file and then add up all the numbers. Do
not use <awk, sed, cut...>
lightdm:x:112:118:Light Display Manager:/var/lib/lightdm:/bin/false
colord:x:113:121:colord colour management
hplip:x:114:7:HPLIP system user,,,:/var/run/hplip:/bin/false
The third element is: 112 113 114 115
Total is: 454
while IFS=: read -r f1 f2 f3 f4 f5 f6 f7
echo "Third field is = $f3"
sum=`expr $sum + $f3`
done < $filename
I tried to accomplish this by using "IFS" and the script is as follows.
Please review it and if there is any other simple solution then please
I hope such questions will help others too.