Find Interview Questions for Top Companies
Ques:- Hi All, Is it possible to create one file name only space or space in file name in UNIX and we can able to run that on Unix?
Asked In :- iOPEX,
Right Answer:
No, it is not possible to create a file with only a space as its name in UNIX. However, you can create a file with spaces in its name, but it must have at least one non-space character.
Comments
Admin May 17, 2020

Yes..:)
just open unix prompt
vi " " or vi "ab cd"
echo "jagadeeb"
:wq
just give permission :)like
chmod 777 " " or chmod 777 "ab cd"
and run that like
./" " or ./"ab cd"
out put like
jagadeeb
jagadeeb@gmail.com

Admin May 17, 2020

Unix-legitimate filenames are any combination of these
three classes of characters: Upper and lower case letters:
A - Z and a - z
Numbers 0 - 9
Periods, underscores, hyphens . _ -
Note that line spaces (aka "whitespace") are not allowed in
filenames. The Unix shell will think you mean more than one
file.

Ques:- In a file , how to retrieve the lines which are the multiples of 50 ? like 50,100,150th lines etc.
Asked In :-
Right Answer:
You can use the following command in a shell script to retrieve lines that are multiples of 50 from a file:

```bash
awk 'NR % 50 == 0' filename
```

Replace `filename` with the name of your file.
Comments
Admin May 17, 2020

awk 'NR % 50 == 0' print

Admin May 17, 2020

awk 'NR % 50 ==0 {print}' filename

Ques:- if i have 2 files file1 and file2…. file1 contains 2 columns like b a 11 aa 12 as 13 ad 15 ag 11 ar 13 ah 15 ak file2 contains b c 10 ds 11 at 15 gh 15 jk 13 iu 11 fg 13 yy can any 1 give me the program to display in this way? a b c aa 11 at ar 11 fg ad 13 iu ah 13 yy ag 15 gh ak 15 jk
Asked In :-
Comments
Admin May 17, 2020

Sorry Sudhir,
Your syntax is wrong.It should be
paste file1 file2|cut -d " " -f2,3,4
But this command is n't providing the correct result.
Piz try another.

Admin May 17, 2020

paste file1 file2 | cut -f 2,3,4 -d " "

Ques:- Create a bash shell script that reads a line from the user consisting of 5 words and then prints them out in reverse order. Name this script “reverse.sh”
Asked In :-
Comments
Admin May 17, 2020

read line;
echo $line | awk '{ for ( i = NF; i > 0; i--) print $i}' |
tr "n" " "

Ques:- Create a bash shell script that reads in a number from the user. If the number is 1, print out the date. If the number is 2, list the files in the current directory. If the number is 3, print out who is currently logged onto the system. If the number is anything else, print out an error message and exit. Name this script “various.sh”
Asked In :-
Comments
Admin May 17, 2020

cho "Enter Choice"
read num
case $num in
1) echo `date`
;;
2) ls
;;
3) who
;;
*) echo "Wrong option press 1 2 3 only"
;;
esac

Admin May 17, 2020

echo "Enter the number"
read i
if [ $i -eq 1 ];then
echo `date`
elif [ $i -eq 2 ];then
ls
elif [ $i -eq 3 ];then
who
else
echo "Nothing"
fi

Ques:- Hi, all Scripting professional. Q. I have written script1.sh and calling script2.sh in script1.sh file using bash shell as interpreter and my log in shell also bash shell.My code like Script1 #!/bin/bash echo “My script2 call” . script2.sh Here script2.sh file run successfully but when I have changed my interpreter bash to ksh like #!/bin/ksh Error are comming script2.sh command not found. Guid me how to call other script in our main script.
Asked In :-
Comments
Admin May 17, 2020

write code like this :
#!/bin/bash
echo "My script2 call"
/bin/bash ./script2.sh [ or /bin/ksh ./script2.sh ]
It will run ..... enjoy !!!!!!

Admin May 17, 2020

instead of
. script2.sh
Just try
sh script2.sh
It will Run

Ques:- What are the 4 basics of OOP?
Asked In :-
Right Answer:
The four basics of OOP are:

1. Encapsulation
2. Abstraction
3. Inheritance
4. Polymorphism
Comments
Admin May 17, 2020

1.Data Abstraction
2.Data Encapsulation
3.Polymorphism
4.Inheritance

Ques:- How to sort a result of Ls -l command based on columns. Ex. i want to sort 5th column from output of ls -l command.
Asked In :-
Right Answer:
You can sort the output of the `ls -l` command based on the 5th column (file size) using the following command:

```bash
ls -l | sort -k5,5n
```
Comments
Admin May 17, 2020

$ ls -al | sort -n -k5
The -n in my example means "sort numerically", and the -k5
option means to key off of column five. Like other Unix
commands, these options can be combined and shortened, like
this:
$ ls -al | sort -nk5

Admin May 17, 2020

ls -l|sort -nk5

Ques:- madhar chod unix ke 10 commands dhang se likh nahi sakta hai
Asked In :-
Right Answer:
1. `ls` - List directory contents
2. `cd` - Change directory
3. `pwd` - Print working directory
4. `cp` - Copy files and directories
5. `mv` - Move or rename files and directories
6. `rm` - Remove files or directories
7. `mkdir` - Create a new directory
8. `rmdir` - Remove an empty directory
9. `touch` - Create an empty file or update the timestamp
10. `chmod` - Change file permissions
Ques:- 1.Write a script, which converts a number from binary to hexadecimal format or vice versa.
Asked In :-
Right Answer:
```bash
#!/bin/bash

if [[ $1 =~ ^[01]+$ ]]; then
# Convert binary to hexadecimal
hex=$(printf '%xn' "$((2#$1))")
echo "Hexadecimal: $hex"
elif [[ $1 =~ ^[0-9a-fA-F]+$ ]]; then
# Convert hexadecimal to binary
bin=$(printf '%bn' "$(echo "obase=2; ibase=16; $1" | bc)")
echo "Binary: $bin"
else
echo "Invalid input. Please enter a binary or hexadecimal number."
fi
```
Comments
Admin May 17, 2020

echo 'obase=16 ; ibase =2 ; binaryno'|bc #print hexadecimal
echo 'obase=2 ; ibase=16; hexa no'|bc #print binary no

Ques:- is this growing field and what is average package in this?
Asked In :-
Right Answer:
Yes, shell scripting is a growing field, especially in DevOps and automation. The average salary for shell script developers varies by location and experience, but it typically ranges from $70,000 to $120,000 per year in the United States.
Ques:- In a single command how do you run the previous command in the command prompt.
Asked In :-
Right Answer:
You can run the previous command in the command prompt by using `!!`.
Comments
Admin May 17, 2020

type "r". It will execute the last executed command

Admin May 17, 2020

esp + p enter
upper arrow enter

Ques:- Please anyone suggest atleast 2 good training institutes in Hyderabad, INDIA where i can learn unix shell scripting.
Asked In :-
Right Answer:
1. Naresh IT
2. Simplilearn
Comments
Admin May 17, 2020

follow sunitabh Das unix book

Ques:- Where cron file kept?
Asked In :-
Right Answer:
Cron files are typically kept in the `/var/spool/cron/` directory for user-specific cron jobs, and system-wide cron jobs can be found in `/etc/crontab` and the `/etc/cron.d/` directory.
Comments
Admin May 17, 2020

It is in /var/spool/cron/crontabs
Each user have seperate file in this location. moreover
normal user cannot view this file, only root user can
access.

Admin May 17, 2020

Check which packages are installed. Your best bet is here:
/etc/anacrontab
/etc/cron.d
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
/etc/crontab
/var/spool/anacron
/var/spool/cron
/var/spool/anacron/cron.daily
/var/spool/anacron/cron.monthly
/var/spool/anacron/cron.weekly

Ques:- How to know that your remote server is ruing smoothly or not in unix?
Asked In :-
Right Answer:
You can use the `ping` command to check if the remote server is reachable, and the `ssh` command to log in and check system status. Additionally, you can use commands like `top`, `htop`, or `uptime` after logging in to monitor system performance. For automated monitoring, tools like `Nagios`, `Zabbix`, or `Munin` can be set up to track server health.
Comments
Admin May 17, 2020

login to the remote server using ssh and use top -d1 command
, it will show the load average on the server.

Ques:- Devise a script that takes file name as arguement(which must present in the current directory)and locates from your home directory tree all thpath names of its links.Then mail the list to self.
Asked In :-
Right Answer:
```bash
#!/bin/bash

# Check if a filename is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 filename"
exit 1
fi

filename=$1

# Check if the file exists in the current directory
if [ ! -e "$filename" ]; then
echo "File '$filename' does not exist in the current directory."
exit 1
fi

# Find all symbolic links to the file in the home directory tree
links=$(find ~ -type l -exec test -e {} ; -print | grep "$(realpath "$filename")")

# Mail the list to self
if [ -n "$links" ]; then
echo "$links" | mail -s "Links to $filename" $(whoami)
else
echo "No links found for '$filename'."
fi
```
Ques:- Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.
Asked In :-
Right Answer:
```bash
# db_connection.sh
#!/bin/bash
DB_USER="your_username"
DB_PASS="your_password"
DB_NAME="your_database"

connect_db() {
mysql -u $DB_USER -p$DB_PASS $DB_NAME
}

# create_table.sh
#!/bin/bash
source db_connection.sh

create_table() {
connect_db <<EOF
CREATE TABLE IF NOT EXISTS PRADEEP_DATA (
name VARCHAR(255),
value VARCHAR(255)
);
EOF
}

create_table

# menu.sh
#!/bin/bash
source db_connection.sh

menu() {
echo "1) Insert to the database"
echo "2) Delete from the database"
read -p "Choose an option: " option

case $option in
1)
read -p "Enter name: " name
read -p "Enter value: " value
connect_db <<EOF
INSERT INTO PRADEEP_DATA (name, value
Ques:- Write a shell script in Linux to shift all characters in a file forward by five characters (e.g., ‘a’ becomes ‘f’).
Asked In :-
Comments
Admin May 17, 2020

cat test.txt | tr '[a-z A-Z]' '[f-za-e F-ZA-E]'

Admin May 17, 2020

cat abc.txt | tr '[a-z A-Z]' '[f-za-e F-ZA-E]' > xyz.txt

Ques:- How shell works?
Asked In :-
Comments
Admin May 17, 2020

Shell is a program that takes commands as an input from the
user and interact with the Operating system to execute
those commands.Shell is a wraper around the Operating
system and passes on the information in form of the
commands to get the task done.

Ques:- Write a shell program to test whether a given number is even or odd?
Asked In :-
Comments
Admin May 17, 2020

echo -n "Enter numnber : "
read n
rem=$(( $n % 2 ))
if [ $rem -eq 0 ]
then
echo "$n is even number"
else
echo "$n is odd number"
fi

Admin May 17, 2020

echo "Enter the Number"
read a
b=`echo "$a % 2"|bc`
if [ $b -eq 0 ]
then
echo "Given Number is Even "
exit
fi
echo " Given Number is odd"



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