Linux Shell Script Questions and Answers #1

What is UMASK?

When user creates a file or directory it will be created with  permission. The default value is 022.
If we create a file or directory the file will be created with 755 permission.
The calculation is the difference between 777 and the  umask value.
ie. 777-022=755.
If umask is 022 then
Owner will have read, write, execute permissions
Group will have read, execute permissions
Others will have read, execute permissions
 

How will you delete last ten days records in OS level?

$ find . –mtime -10 exec rm {} \
 

What is RPM? How will you install RPMS?

RPM Package Manager (originally Red Hat Package Manager, abbreviated RPM) is a package management system.
$ rpm -Uvh rpmname.rpm
 

How will you find how many users were connected to a database named “sss”  from linux level?

ps –ef|grep –i local|grep sss
 

How will you get the count of all arguments that is passed in a Shell script?

echo $#
 

How to check whether the last command executed successfully or not?

Echo$?
if the result is 0(zero) then the command is successfully executed  else if the number is from 1 to 255 it is failed.
 

From Linux how will you find how many users were connected to the database “sakthi”?

ps -ef|grep -i local|grep -i sakthi|wc -l
 

How will you view Alertlog file from different directory?

tail -f /home/oracle/db/bdump/alertlog.log
 

How will you see  all the arguments in shell script?

echo $*
 

How will you configure host name and ipaddress?

Connect to root user and use neat command to add the hostname and ipaddress. Then restart the network service using
# service network restart
In /etc/hosts add the ipaddress and hostname.
 

How will execute a shell script in background?

./script.sh &
or
nohup ./script.sh &
which will create a nohup.out in the current directory.
 

Where will you find the OS level errors?

In /var/log/messages and
$ dmesg

How to view last 15 lines of a file?
$Tail -15 filename

How to copy a folder from one server to another?

First compress the folder using tar command
$tar -zcvf directory_name.tar.gz directory_name
Scp oracle@192.168.1.140:/home/sss/directory_name.tar.gz oracle@192.168.1.130:/home/oracle/sss/

or

using FTP you can transfer a file
or using third party utilities like winscp, Wsftp etc.
 

How to edit the crontab? How will you schedule on a file January 26 10:30 am?

crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file
Jan 26 10:30 am assign one job in crontab
30 10 26 1 * . text.sh
 

How to find the size of a directory and a file?

$du –sh directory_name
$ls -lrth filename
 

How will you find the modified the files in a home directory?

$find $HOME –type f –mtime 0
$find ~ –type f –mtime 0
 

What is Chmod –R?

chmod -R 755 directory (-R set permissions recursively , ie changes the permission to current directory,sub direstory and files)
 

How will you find obsolete path of “sqlplus”?

$which sqlplus
$type sqlplus
 

What are the Compress commands?

Gzip
Zip
Tar
Compress
cpio

Linux Tips

More Linux Questions

Have a Linux Problem
Linux Forum - Do you have a Linux Question?

Linux Books
Linux Certification, System Administration, Programming, Networking Books

Linux Home: Linux System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.