new 31
new 31
txt
Q 2. How to print the hidden files? --> ls -a/ls -lart
Q 3. How to display the files in a directory, size less than 4 MB? --> find . -type
f -size -4M
Q 4. How to transfer files from one application Server to another server? --> scp
[email protected]:/home/opengenus/iq/information.txt . / scp -r
[email protected]:/home/opengenus/iq/ . r to copy entire directory
Q 5. How to connect to DB from Unix Server? --> sqlcmd -S SERVERNAME -U User -P pwd
-d DatabaseName -Q "SELECT TOP 5 Id FROM dbo.MyTable;"
Q 6. What is the first line of the Script (shebang) and what it denotes/indicates?
On Linux, a shebang (#!) is a special line at the beginning of a script that tells
the operating system which interpreter to use when executing the script. This line,
also known as a hashbang, shabang or "sharp-exclamation", is the first line of a
dash and starts with "#!" followed by the path to the interpreter
Q 8 . How do you find the number of occurrences of the word in the file? (wc -w) --
> $ grep -o -i needs inspire.txt | wc -l
Q 11. How do you find the line count for the matching pattern? grep -o -i mauris
example.txt | wc -l
Q 12. Write a command to print the lines that ends with the word "specific_word"?
grep 'unix$' your_file | sort
Q 13. Write a command to print the lines matching with exact word? grep 'unix$'
your_file | sort
Q 14. Match all words starting with “Particular String”. grep -w 'warning\|error\|
critical' /var/log/messages
Q 15. Match all pattern which starts with q and doesn’t follow by u?
Q 16. To show below and above 2 lines of the matching pattern?
Q 17. How to zip and unzip the files? unzip and zip
Q 18. How to display files names which contain given word?
Q 19. How to search for multiple matching string in the file?
Q 20. To delete the file which is having permission 644?
Q 21. How to change the permission of any file?
Q 22. How to set default permission of any file?
Q 23, What is the default permission newly created file and directory?
Q 24. Create a 0 byte file with 477 permission?
Q 25. If file content is space separated, then how to show only last field of the
file?
Q 26. Print all input lines from filename that have more than 4 fields.
Q 27. Print the total number of lines in the filename to the screen.
Q 28. If the files having 4 fields and if any field is blank then delete that
particular line?
Q 29. How to replace 4th occurrence of any pattern with given new pattern?
Q 30. How to replace the word from the 11th to 19th line only?
Q 31. How to replace all the occurrences of any word with given word in a file?
Q 32. How to print from 34th to 45th line with repeating the line?
Q 33. Write a command to print the lines that do not contain the word "run"?
Q 34. What is the difference between ‘cmp’ and ‘diff’ commands?
Q 35. How to open the file from 60th line?
Q 36. How to search any ERROR string in VI editor and navigate it? (upward &
downward)
Q 37. How to copy and delete any line in VI?
Q 38. How to go into Insert mode from Command mode?
Q 39. How to save the changes and exit from VI?
Q 40. How to go to 56th line in VI? Q: How you will find %memory & %CPU
utilization? (TOP command and it’s output)
Q 41. How to replace all occurrences of some specific character?
(:%s/oldText/newText/g)
Q 42. How to append a file to current file using VI editor?
Q 43. What is the UNIX command to list files/folders in alphabetical order and
sorted with modified time?
Q 44. What ‘more’ command does?
Q 45. How to display 57th line of the file? (with head and tail command)
Q 46. What is Zombie Process and how you get Zombie process in unix?
a zombie process or defunct process is a process that has completed execution (via
the exit system call) but still has an entry in the process table: it is a process
in the "Terminated state".
Q 47. What is the command to find maximum memory taking process on the server? Top
Q 48. What is the command to find the currently running process in Unix Server? ps
-ef
Q 49. What is the command to find remaining disk space] in the UNIX server? df -H
--output=source,size,used,avail
Q 50. What is the UNIX command to confirm a remote host is alive or not? --- ping -
s hostname
Q 51. What is the method to see command line history? -- doskey /history
Q 52. What is the command to find if the system is 32 bit or 64 bit? -- uname -a
Q 53. What is the purpose of the “echo” command? -- allows users to display lines
of text or strings that are passed as arguments
Q 54. Write a command to erase all files in the current directory including all its
subdirectories. rm -r /path/to/dir/*
Q 55. Which command is used for remote login? Telnet
Q 56. Which command determines the IP address and domain name?
Nslookup is the name of a program that lets users enter a host name and find out
the corresponding IP address or domain name system (DNS) record.
Stores the number of command-line arguments that were passed to the shell program
Q 58. How do you find status of the last command executed? (meaning of 0 & 1) fc -s
Q 59. Name the command that is used to take the backup?
dump [-level#] [-a autosize] [-A file] [-B records] [-b blocksize]
[-d density] [-D file] [-e inode numbers] [-E file] [-f file]
[-F script] [-h level] [-I nr errors] [-jcompression level] [-L label]
[-Q file] [-s feet] [-T date] [-y] [-zcompression level] files-to-dump
dump [-W | -w]
if [condition]
then
statement1
else
statement2
fi
#!/bin/bash
m=1
n=2
if [ $n -eq $m ]
then
echo "Both variables are the same"
else
echo "Both variables are different"
fi
#!/bin/bash
a=2
b=7
if [ $a -ge $b ]
then
echo "The variable 'a' is greater than the variable 'b'."
else
echo "The variable 'b' is greater than the variable 'a'."
fi
#!/bin/bash
printHello(){
echo "Hello World!"
}
printHello
while [ condition ]
do
command1
command2
done
#!/bin/bash
if(( ! $a == "true" ))
then
echo "a" was initially false.
else
echo "a" was initially true.
fi
Arithmetic Operators
Relational Operators
Boolean Operators
Bitwise Operators
File Test Operators