What’s the command to find out today’s date?


What’s the command to find out users on the system?


How do you find out the current directory you’re in?


What is the command to see the location of command?

Whereis  <commandname>

How do you find out your own username? 

Whoami    (or)  logname

How to close the current user account?



How to create empty file?

Touch <filename>

How do you remove a file?

Rm <filename>

How to join multifile files vertically?

Cat   file1  file2  file3 ……

The file for which we do not have write permission can be deleted using the command?

rm -f  <filename>

How do you remove a directory and its subdirectories ?

rm –rf <directoryname>

How to rename a file?

Mv <filename>

How to copy multiple files and directories into some other directory?
cp -r source_directory destination_directory

How to see hodden files?

Ls –a

How to see files and subdirectories files recursively?

Ls –R

How to see files in long list format page wise?

Ls –l | more

How to identify whether a file is normal file or directory?
$ls -l filename/directoryname

if the first digit is – then it is file,

if it is d then it is directory file


What is the difference between “ls -r” and “ls -R”?


ls -r lists the files in reverse alphabetical order… whereas ls -R lists the files and directories recursively


The difference between a soft link and a hard link?
A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system.

what are the different commands used to create files?

1.touch – to create empty files (e.g) – touch <filename>

2.vi <filename>

  1. cat>filename


List some wild card characters?

? -à Iit matches any single character

* -à It matches zero or more characters

[] -à It matches any single character in given list

. –à It matches any single character except enter key character

what is the output of the follwing command : ls [a-mno-r]*


list all the files in the current directory starting alphabet

is between a to m  or n or between o to r

How do you count words, lines and characters in a file?

Wc <filename>

which command is used to identify the type of the file?

“grep” means

Globally search a regular expression and print it


How do you search for a string inside a given file?

grep string filename

How do you search for a string inside a  current directory?

grep string *
How do you search for a string in a directory with the subdirectories recursed?

grep -r string *

Difference between grep, egrep and fgrep


grep : does not accept more then one expression


egrep : accepts more than one pattern for search. Also accepts patterns from a file.


fgrep : accepts multiple patterns both from command line and file but does not accept regular expressions only strings. It is faster than the other two and should be used when using fixed strings.


What are line patterns?

^ -à start of the line

$ -à End of the line


How to search empty lines in a given file?

Grep “^$” <filename>


How to count no of blank lines in a file?

Grep –c “^$” <filename>

How to remove Empty lines form a given file?

Grep –v “^$”  filename > temfilename

Mv  tempfilename  filename

What is pattern to search 4 digit word in a file?

Grep “\<[0-9] [0-9] [0-9] [0-9]\>” filename

What is pattern to search the line having only three characters?

Grep “^…$” filename

What is pattern to display lines ending with “$” character in a given file?

Grep “\$$” filename


How to display 2 and 4 th fileds from a given file if the delimetr is “:”?

Cut –d”:” –f 2,4 filename

How to display unique lines from a given file?

Sort –u filename

How to eliminate completely duplicate lines from a given file?

Uniq –u filename

How to remove all duplicate lines from a file?

Uniq –u filename > tempfilename

Mv  tempfilename  filename

How to delete “hello” word from a given file?

Sed “s/hello//” filename

How to compare two files are same or not?


How to display the first 10 lines from a file?

Head  -10  filename

Write a one line command to convert all the capital letters of a file “test” into lower case?

cat filename | tr “[A-Z]”  “[a-z]”


The pipeline to list the five largest files in the current directory is


ls -l | tr -s ‘ ‘ | sort -t ‘ ‘ -fnr +4 -5 | head –5


The pipeline to find out the number of times the character ? occurs in the file is

tr -dc ‘?’ < file | wc -c   ( Delete all the characters except ? and then make a word count.)


How to count total no. of users working in the system?

Who | wc –l


How to display the lines from 5 to 10 from a given file?

Head -10 filename | tail +5


what will be output of following command?

echo “Tecnosoft” | wc –c



What is the default umask?


What is the default permission for File & Directory ?

The Default privileges for file : 644

The default privileges for directory :  755

What UNIX command will control the default file permissions when files are created?

Explain the read, write, and execute permissions on a UNIX directory.

Read allows you to see and list the directory contents.

Write allows you to create, edit and delete files and subdirectories in the directory.

Execute gives you the previous read/write permissions plus allows you to change into the directory and execute programs or shells from the directory.

What is chmod, chown and chgrp?

Chmod : It is used for to change permissions on files

Chown : It is used for to change ownership of a file

Chgrp : It is used for to change group of the file

If the owner doesn’t have write permission on a file, but his/her group has, can he/she edit it?

No. He/she can’t,because the owner’s permission overrides the group’s.

To see list of files and directories ,what permission required?

Read permission
What are PIDs?

They are process IDs given to processes. A PID can vary from 0 to 65535.

How do you list currently running process?


How do you stop a background process?

kill pid
How do you find out about all running processes?

ps -ag
How do you stop all the processes, except the shell window?

kill 0
How do you fire a process in the background?

./process-name &

What does the command “kill -9 $! ” do?

kills the last background process


if there is a process u want to run even after exiting the shell what is the

command used?



 which command will get executed even after you log out?



which signal cannot be trapped?

kill –9


How to redirect standard error to a file? Answer
2> filename

What does the top command display?

top command displays the current ammount of memory occupiedby the currently executing processes and the details. In addition to memory usage top command displays cpu usage and process details


What is the command to send message to all users who are logged in?



What is the command to send mail to other user?

Mail username

How to open secondary mail box?

Mail -f

What do you do if you don’t want to be interrupted by other users’ messages?

Ans. mesg n

Leave a Reply