UNIX Assignment
1. What will be the output of following commands?
a. $ cat file1>file1
cat: file1: input file is output file
b. $ date ; who
Displays the current date and time
Who – shows a list of users who are currently logged into a computer.
c. $ ls > file1
Lists all the files in the current directory in the ‘file1’ file.
2. What does the command “$who | sort –logfile > newfile” do?
3. How many types of Shell are there?
The Bourne shell (sh)
The C shell (csh)
The Korn shell (ksh)
The Z-Shell (zsh)
The POSIX shell
The Bourne Again SHell (Bash)null
4. Use a grep command to display all the lines from following Sunday.log file, where ‘Sunday’ is
the starting word.(not where it comes in middle or end)
Today is Sunday
Sunday is a good day
No one go to school on Sunday
Sunday we meet our friends
5. How do we kill all the processes with one command?
kill is a command that is used in several popular operating systems to send signals to running
processes, for example to request the termination of this process.
killall
6. Can you write command to give read and write user group permissions to xyz.log file?
Chmod g+rw file_name
7. How can I delete all the files in current and all its sub directories?
rm*
8. How do I navigate from 3rd line to 1st line in Vi Editor?
9. What will be the output of following command
${HOME}
Bash: {HOME} command not found
10. Is it possible to count total no of lines or characters in a file?
YES. wc –l ‘file_name’
11. Give some command to make use of pipes (|)
% who | sort
command1 | command2
12. How many commands are there to check processes (including foreground and background)
%ps, %jobs
13. What are the different modes in Vi Editor?
14. How can you change the shell in UNIX? Command?
$ echo $0
/bin/bash
$ exec /bin/sh
$ echo $0
/bin/sh
This changes the shell from ‘bash’ to ‘sh’.
15. How can I display only first 5 lines of a file? Command?
% head -5 filename