Find Interview Questions for Top Companies
Ques:- how is the oppurtunities for unix in the software
Asked In :-
Comments
Admin May 17, 2020

Unix has a great oppertunites in IT fiels. Be it
Development , Support ot Tech Support.

Ques:- How u convert string “hi pravin how are you?” to “Hi Pravin How Are You?”
Asked In :- Payoda,
Comments
Admin May 17, 2020

use a perl one liner like this
perl -e '$var="hi pravin how are you";@arr=split("
",$var);foreach $wrd(@arr){print ucfirst($wrd)." ";}'

Admin May 17, 2020

The file "test" contains "hi pravin how are you?".
sed -e "s/^[a-z]/U&/" -e "s/[[:space:]][a-z]/ U&/g" test

Ques:- wats the she bang statment with syntax?
Asked In :-
Comments
Admin May 17, 2020

shebang is also called as hashbang.This basically used for
interpretation.This should be the 1st line of any shell
script which indicate the script to run in specified shell.
For ex. If the 1st line of a shell script is #!/bin/ksh
then the program has to run under korn shell.If you do not
specified any shebang then it will run under default shell.

Admin May 17, 2020

a shebang (also called a hashbang, hashpling, or pound
bang) refers to the characters "#!. The shebang is looked
for and used when a script is invoked directly.
Because the "#" character is often used as the comment
marker in scripting languages, the contents of the shebang
line will be automatically ignored by the interpreter
itself; the shebang line only exists to specify the correct
interpreter to be used.

Ques:- is there any command to find user password?
Asked In :-
Comments
Admin May 17, 2020

No way one can get the password of other user even if root
also can not get the password unless untill there is an
readble entry in /etc/passwd file. But for the super user,
it doesn't need to know the user's passwrod to access his
docs.

Admin May 17, 2020

No, No one can't know the passwd because it is stored in in
/etc/shadow file as MD5 Hash ,
and link at /etc/passwd.
We can convert Value(passwd) to Hash but not Hash to
value(passwd)
Super user is also not able to retrive passwd......
By Choyal

Ques:- write a shell script that counts a number of unique word contained in the file and print them in alphabetical order line by line?
Asked In :-
Comments
Admin May 17, 2020

cat filename | uniq -u | sort -n

Admin May 17, 2020

#!/bin/csh
# Here tr -s ' ' replaces all multiple ' ' with single ' '
# next pipe the above stream to replace each ' ' with 'n'
# next pipe the above stream to get a sorted list of words
# then pipe the unique words to outfile
tr -s ' ' < $1 | tr ' ' 'n' | sort | uniq > $1.out

Ques:- what is the meaning of First line of shell script ,what is meaning of #! pleas explain brifly
Asked In :-
Comments
Admin May 17, 2020

it shows the path for the interpreter

Admin May 17, 2020

#! indicates from where the path of the interpretor should
be considered and also directs that the contents of the
file which will be following will be executed under the
guidelines of this interpretor being used.

Ques:- how to read systems current date and time
Asked In :-
Comments
Admin May 17, 2020

In Unix, to know the current date and time, the command is
date.

Admin May 17, 2020

$date -u +%r -->02:26:38 PM
$ date -u +%T -->14:26:48

Ques:- There are three departments A,B and C.Write a query to display the names of all the persons( in departments other than A) who are paid higher than the person receiving the lowest salary in DEPT A
Asked In :-
Comments
Admin May 17, 2020

select E.name from department D, emp E
where D.name = E.dname
and E.dname <> 'A'
and E.sal > (select min(E.sal) from department A, emp E
where A.name = E.dname
And E.dname = 'A')

Ques:- There is a record with fields namely name,roll no.,salary,grade etc.Now,write a script to create a file with multiple records have same combination of fields but with unique roll numbers.The script should work for different names in the input file.
Asked In :-
Comments
Admin May 17, 2020

Don't mind my answer is lengthy....
Let file name be employee
name, rollno., salary, grade
cut each of records in each field to temp files as follows:
-----------------------------------------------------------
cut -f1 employee > /sm.tmp.$$
cut -f2 employee > /sn.tmp.$$
cut -f3 employee > /so.tmp.$$
cut -f4 employee > /sp.tmp.$$
Paste them as required in to another file as follows
----------------------------------------------------
paste /sn.tmp.$$ /sm.tmp.$$
paste /sn.tmp.$$ /so.tmp.$$
paste /sn.tmp.$$ /sp.tmp.$$

Ques:- how can you execute the shell scripts?
Asked In :-
Comments
Admin May 17, 2020

sh File_Name.sh
then press enter

Admin May 17, 2020

If the path variable does not contain ur current
directory,then you can execute the script by giving
$./scriptname
If you include your current directory in path variable then
$scriptname
or
If u want to invoke new shell
$ ksh scriptname

Ques:- how do you write sql queries using shell script for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO columns in EMP table how you display EMPNO,SAL FIELDS from emp in SHELL SCRIPT please explain with an example
Asked In :-
Comments
Admin May 17, 2020

create a variable for your query like
sql1='select empid,empname,.... from emp;' in your script
then call sqlplus in your shell script as
slplus user/password@sql1
you can redirect the output or format it as you like.
you can pass userid pwd as parameters as arguments to your
shell script and use them as parameters $1 and $2. you can
check if all the parameters are given with Usage [$# eq. 2 ]
etc.

Admin May 17, 2020

sqlplus username/userpassword@oracle<<eof
>select * from emp;
>select empno,ename,sal,deptno;
........what ever commands u wanna execute of sql u can
write here
>hit ctrl+d
these are called as here documents

Ques:- A file has multiple records each having three 30-bit long fields(field1,field2,field3).There is also a lookup file,LOOK_UP.dat.Now, we need to consider only the last ten digits of field1 and lookup the file LOOK_UP.dat. If there a match then field2 and field3 should replaced with corresponding data from the lookup file. otherwise that particular record,for which there is no match, should be stored in a seperate file.
Asked In :-
Comments
Admin May 17, 2020

If we would knew the structure of LOOK_UP.dat (like the
structure of file is mentioned) then the script could be
more precisely written.

Ques:- what are bootlevel in linux?which level is booting by default.
Asked In :-
Comments
Admin May 17, 2020

6 levels is correct,XIn Red Hat Linux, the default boot
level is 3, unless booting into an X Windows login, the
default boot level then is 5.
Runlevels Generic mode
0 halt
1 Single user mode
2 Multiuser, without Networking
3 Full multiuser mode
4 unused
5 X11
6 reboot
You can view the settings of default runlevel
in /etc/inittab. The command /sbin/chkconfig --list is used
to display a list of all runlevels and services.

Admin May 17, 2020

There are 6 levels
init 0 :- Shutdown (halts)
init 1 :- Single user mode or emergency mode, that means no network no multitasking is present in this level, only root user has access in this run level.
init 2 :- NO network but multitasking is present
init 3 :- Network and multitasking is present but without GUI
init 4 :- Unused level.
init 5 :- Boot up a full multi user system and to automatically start X-Wnindows
init 6 :- System restart in this level.

Ques:- How to rename all the files in a folder having specific extension? Example: I have some files with extension (.txt) in a folder name ‘Test’. I have to rename all the .txt files in a test and its subdirectories to .my extension.
Asked In :-
Comments
Admin May 17, 2020

for file in `ls` ; do NEW=`echo $file | sed 's/.txt/.my/g'`
; mv $file $NEW ; done

Admin May 17, 2020

for i in `find . -name "*.txt"`
> do
> mv $i ${i%.txt}.my
> done

Ques:- What is the command for ” how many shell is running in your system or how many shell supported by your system ” ?.
Asked In :- SignOff Semiconductors,
Comments
Admin May 17, 2020

how many shell supported by your system
check the file /etc/shells

Admin May 17, 2020

> ps -a |grep -E 'sh$' |wc -l
-a is for to list process of all users
-E extended grep to filter the shells (since they end with sh like bash, tcsh, ksh, sh
-$ to match only at the end of the line where the process is printed

Ques:- The information of the two files should be redirect to Third file in such a way that, the third file contain the information like this. 1st line in third file should be from 1st file 2nd line in Third file should be from 2nd file 3rd line in Third file should be from 1st file 4th line in Third file should be from 2nd file – – so on
Asked In :-
Comments
Admin May 17, 2020

paste -d"n" file1 file2 > file3

Admin May 17, 2020

Unix utility sed can be used serve the purpose
Assuming file1.txt and file2.txt are two input files and
file3.txt is the third file.
Contents of the file1.txt
line 1
line 2
line 3
Contents of the file2.txt
LINE 1
LINE 2
LINE 3
After executing below mentioned command
sed -n -e '{
> R file2.txt
> p
> }' file1.txt > file3.txt
The third file file3.txt will be
line 1
LINE 1
line 2
LINE 2
line 3
LINE 3

Ques:- HOW TO CREATE 10 USERS IN UNIX(HP-UX) USING SHELL SHELL SCRIPT?
Asked In :-
Comments
Admin May 17, 2020

#!/bin/sh
for i in {1..10)
do
echo "creating user"$i;
useradd user$i;
done
to list the created users.
cat /etc/passwd

Admin May 17, 2020

My dear friends,
you have used 'useradd' command in the script through which we can only add the user name. But for adding password you should use 'passwd' command because password is also mandatory.

Ques:- I want to upload a file to remote server through ftp daily.Can anyone suggest how to make a shell script for that.I hv credentials for that ftp
Asked In :-
Comments
Admin May 17, 2020

#!/bin/bash
/bin/ftp -inv ip_address_of_target_station<<ENDFTP
user ftpusername ftpuserpassword
cd folder_on_target
bin
lcd folder_on_local
put filename.txt
bye
ENDFTP
# Alternatively some ftp packages let you put a script in
$HOME/.netrc

Ques:- write a shell script to find the largest number from 3 given numbers.
Asked In :-
Comments
Admin May 17, 2020

if [ $# -ne 3 ]
then
echo "$0: number1 number2 number3 are not given" >&2
exit 1
fi
if [ $1 -eq $2 ] && [ $1 -eq $3 ]
then
echo "All the three numbers are equal"
elif [ $1 -eq $2 ] && [ $1 -gt $3 ]
then
echo "$1 and $2 numbers are equal and are largest
numbers among $1 $2 and $3"
elif [ $1 -eq $3 ] && [ $1 -gt $2 ]
then
echo "$1 and $3 numbers are equal and are largest
numbers among $1 $2 and $3"
elif [ $2 -eq $3 ] && [ $2 -gt $1 ]
then
echo "$2 and $3 numbers are equal and are largest
numbers among $1 $2 and $3"
elif [ $1 -eq $2 ] && [ $1 -lt $3 ]
then
echo "$3 is largest number among $1 $2 and $3"
elif [ $1 -eq $3 ] && [ $1 -lt $2 ]
then
echo "$2 is largest number among $1 $2 and $3"
elif [ $2 -eq $3 ] && [ $2 -lt $1 ]
then
echo "$1 is largest number among $1 $2 and $3"
elif [ $1 -gt $2 ] && [ $1 -gt $3 ]
then
echo "$1 is largest number among $1 $2 and $3"
elif [ $2 -gt $1 ] && [ $2 -gt $3 ]
then
echo "$2 is largest number among $1 $2 and $3"
elif [ $3 -gt $1 ] && [ $3 -gt $2 ]
then
echo "$3 is largest number among $1 $2 and $3"
else
echo "I can not figure out which number is
largest"
fi

Admin May 17, 2020

mr imran/vipul
when i run this script it always say number not given
what is the reason and how would this ask for the those 3 numbers to be sorted ??

Ques:- write a program to display all the files from the current directory which are created in particular month
Asked In :-
Comments
Admin May 17, 2020

#include<stdio.h>
#include<stddef.h>
#include<dirent.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<time.h>
#include<stdlib.h>
int main(int argc,char *argv[])
{
char in[100],st[100],*ch,*ch1,c,buff[512];
DIR *dp;
int i;
struct dirent *ep;
struct stat sb;
char mon[100];
dp=opendir("./");
if(dp!=NULL)
{
while(ep=readdir(dp))
{
if(stat(ep->d_name,&sb)==-1)
{
perror("stat");
exit(EXIT_SUCCESS);
}
strcpy(mon,ctime(&sb.st_ctime));
ch=strtok(mon," ");
ch=strtok(NULL,",");
ch1=strtok(ch," ");
if((strcmp(ch1,argv[1]))==0)
{
printf("%s tt %s",ep->d_name,ctime(&sb.st_ctime));
}
}
(void)closedir(dp);
}
return 0;
}

Admin May 17, 2020

Create time is not kept in the inode. Times for Access,
Modify, and Change is all you get.



The Unix category on takluu.com is designed for IT professionals and developers preparing for interviews that require a strong understanding of Unix operating systems. Unix has been the backbone of many enterprise systems due to its stability, security, and multitasking capabilities.

This section covers key topics such as Unix file system architecture, shell scripting, process management, file permissions, user management, and networking commands. You will also learn about vi editor, cron jobs, package management, and system monitoring tools.

Interview questions often assess your proficiency in writing shell scripts, automating tasks, troubleshooting system issues, and managing user permissions. Candidates may be tested on commands like grep, awk, sed, find, and piping techniques, as well as understanding system boot processes and kernel basics.

Roles such as Unix Administrator, DevOps Engineer, System Engineer, and Backend Developer often require expertise in Unix environments. This category also includes best practices for security hardening, backup strategies, and performance tuning in Unix systems.

At Takluu, we offer detailed tutorials, practical exercises, and interview question sets that will help you build confidence and excel in your Unix-related interviews.

Whether you’re a beginner or looking to deepen your Unix skills, this category equips you with comprehensive knowledge to manage Unix systems efficiently and advance your career.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users