Some Helpful Linux and Shell Script Questions and Answers
- How to disable ssh login for root user
vi /etc/ssh/sshd_config
Change this line: #PermitRootLogin yes
Edit to this: PermitRootLogin no
2. Write a shell script that prompts the user for a name of a file or directory and reports if it is a regular file, a directory, or another type of file. Also perform an ls command against the file or directory with the long listing option.
#!/bin/bash
echo “Enter the file path”
read FILE
if [ -f “$FILE” ]
then
echo “$FILE is a reguler file”
elif [ -d “$FILE” ]
then
echo “$FILE is a directory”
else
echo “$FILE is another type of file”
fi
3. Find cronjab of perticular user
We can get cron jobs for users from path — /var/spool/cron
4.