what is the command which lets you change your password?-passwd

 what is the command which lets you change your password?


Unix interview questions part-4

1.Write a command to display a file’s contents in various formats?
$od -cbd file_name c – character, b – binary (octal), d-decimal, od=Octal Dump.

2. What will the following command do?
$ echo *

It is similar to ‘ls’ command and displays all the files in the current directory.
3. Is it possible to create new a file system in UNIX?
Yes, ‘mkfs’ is used to create a new file system.

4. Is it possible to restrict incoming message?
Yes, using the ‘mesg’ command.

5.. What is the use of the command “ls -x chapter[1-5]”

ls stands for list; so it displays the list of the files that starts with ‘chapter’ with suffix ’1′ to ’5′, chapter1,
chapter2, and so on.

6. Is ‘du’ a command? If so, what is its use?
Yes, it stands for ‘disk usage’. With the help of this command you can find the disk capacity and free space
of the disk.

7. Is it possible to count number char, line in a file; if so, How?
Yes, wc-stands for word count.
wc -c for counting number of characters in a file.
wc -l for counting lines in a file.

8. Name the data structure used to maintain file identification?

‘inode’, each file has a separate inode and a unique inode number.

9. How many prompts are available in a UNIX system?

Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).
10. How does the kernel differentiate device files and ordinary files?

Kernel checks ‘type’ field in the file’s inode structure.

11. How to switch to a super user status to gain privileges?
Use ‘su’ command. The system asks for password and when valid entry is made the user gains super user
(admin) privileges.
12. What are shell variables?
Shell variables are special variables, a name-value pair created and maintained by the shell.
Example: PATH, HOME, MAIL and TERM
13. What is redirection?
Directing the flow of data to the file or from the file for input or output.
Example : ls > wc
14. How to terminate a process which is running and the specialty on command kill 0?
With the help of kill command we can terminate the process.
Syntax: kill pid
Kill 0 – kills all processes in your system except the login shell.
15. What is a pipe and give an example?
A pipe is two or more commands separated by pipe char ‘|’. That tells the shell to arrange for the output of
the preceding command to be passed as input to the following command.
Example : ls -l | pr
The output for a command ls is the standard input of pr.
When a sequence of commands are combined using pipe, then it is called pipeline.
16. Explain kill() and its possible return values.
There are four possible results from this call:
‘kill()’ returns 0. This implies that a process exists with the given PID, and the system would allow you to
send signals to it. It is system-dependent whether the process could be a zombie.
‘kill()’ returns -1, ‘errno == ESRCH’ either no process exists with the given PID, or security enhancements
are causing the system to deny its existence. (On some systems, the process could be a zombie.)
‘kill()’ returns -1, ‘errno == EPERM’ the system would not allow you to kill the specified process. This means
that either the process exists (again, it could be a zombie) or draconian security enhancements are present
(e.g. your process is not allowed to send signals to *anybody*).
‘kill()’ returns -1, with some other value of ‘errno’ you are in trouble! The most-used technique is to assume
that success or failure with ‘EPERM’ implies that the process exists, and any other error implies that it
An alternative exists, if you are writing specifically for a system (or all those systems) that provide a ‘/proc’
filesystem: checking for the existence of ‘/proc/PID’ may wWhat is relative path and absolute path.
Absolute path : Exact path from root directory.
Relative path : Relative to the current path may work.


Unix interview questions part-3

1. How do you find which processes are using a particular file?
By using lsof   command in UNIX. It will  list down PID of all the process which is using  a particular file.
2. How do you find  which remote hosts are connecting to your host on a particular port say 10123?
By using netstat  command execute netstat -a | grep “port” and it will list the entire host  which is connected to this host on port 10123.
4. What is ephemeral port in UNIX?
Ephemeral ports are  port used by Operating system for client sockets. There is a specific range on  which OS can open any port specified by ephemeral port range.
5. If one process is inserting data into your MySQL database? How will you check how many rows  inserted into every second?
“watch” command in UNIX  is  repeatedly used to execute command provided with specified delay.
6. There is a file Unix_Test.txt which contains words Unix, how will you replace all Unix to UNIX?
by using SED command in UNIX for example you can  execute sed s/Unix/UNIX/g fileName.
7. You have a tab  separated file which contains Name, Address and Phone Number, list down all  Phone Number without there name and Addresses?
you can either use  AWK or CUT command here.
8. Your application  home directory is full? How will you find which directory is taking how much  space?
By using disk usage
(DU) command in Unix for example du –sh . | grep G  will list down all
the directory which has GIGS in Size.
9. How do you find  for how many days your Server is up?
By using  uptime command in UNIX
10. You have an IP  address in your network how will you find hostname and vice
By using
nslookup command in UNIX, you can read more about networking command in  UNIX here.

Unix interview questions part-2

1.What is difference between ps -ef and ps -auxwww?

ps -ef will omit
process with very long command line while ps -auxwww will list those process as
2. How do you find  how many cpu are in your system and there details?
By looking into file
/etc/cpuinfo for example you can use below command:
cat /proc/cpuinfo
3. What is difference between HardLink and SoftLink in UNIX?
Unix Soft links are pointers to programs, files, or directories located
elsewhere (just like Windows shortcuts).
Unix Hard links are pointers to programs and files, but NOT directories
4. What is Zombie  process in UNIX? How do you find Zombie process in UNIX?
When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it -
7. In a file word UNIX is appearing many times? How will you count number?
grep -c “Unix” filename
8. How do you set  environment variable which will be accessible form sub shell?
By using export   for example export count=1 will be available on all sub
9. How do you check  if a particular process is listening on a particular port on remote host?
By using telnet command for example “telnet hostname port”, if it suceesfully  connects then some process is listening on that port.
10. How do you find whether your system is 32 bit or 64 bit ?
Either by using
“uname -a” command or by using “arch” command.

Unix interview questions part-1

1. Write command to  list all the links from a directory?
ls -lrt | grep
2. Create a read-only  file in your home directory?
chmod command you can also change your umask to
create read only file.
chmod 400
3. How will you find  which operating system your system is running
on in UNIX?
By using command
“uname -a” in UNIX
4. How will you run a  process in background? How will you bring that into foreground and how will you  kill that process?
For running a process  in background use “&” in command line. For bringing it back in foreground  use command “fg jobid” and for getting job id you use command “jobs”, for  killing that process find PID and use kill -9 PID command.
5. How do you know if  a remote host is alive or not?
  by using either ping or telnet command in UNIX.
6. How do you see  command line history in UNIX?
use history command along with grep to find any relevant command you have  already executed.
7. How do you copy  file from one host to other?
Many options but you  can say by using “scp” command.
8. How do you find  which process is taking how much CPU?
By using “top” command in UNIX.
9. How do you check  how much space left in current drive ?
By using “df”
command in UNIX. For example “df -h .” will list how full your current
drive is.
10. What is the  difference between Swapping and Paging?
Whole process is  moved from the swap device to the main memory for execution. Process size must  be less than or equal to the available main memory. It is easier to  implementation and overhead to the system. Swapping systems does not handle the  memory more flexibly as compared to the paging systems.
Only the required  memory pages are moved to main memory from the swap device for execution.  Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping  the virtual address space into the physical memory of the machine. Allows more  number of processes to fit in the main memory simultaneously. Allows the greater  process size than the available physical memory.