Basic UNIX/Linux commands for Interview Questions – Part 1 | SQL with Manoj
source link: https://sqlwithmanoj.com/2010/04/11/basic-unixlinux-commands-for-interview-questions-part-1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Basic UNIX/Linux commands for Interview Questions – Part 1
Some basic UNIX/Linux commands:
… from College notes !
Q1. Start UNIX/Linux while logging in remotely to telnet
Ans: [student@localhost student]$ telnet 192.168.0.4
Q2. Enter the user name as student and password as student.
Ans: [student@localhost student]$
Q3. Display all files starting with a dot and filename more than three characters.
Ans: [student@localhost student]$ ls .???*
Q4. Create files chap01,chap02,chap05,chap07,chap*,chap[0-3]
Ans: [student@localhost student]$ cat > chap01
[student@localhost student]$ cat > chap02
[student@localhost student]$ cat > chap05
[student@localhost student]$ cat > chap07
[student@localhost student]$ cat > chap0*
Q5. Display all files starting with an alphabet irrespective of the case.
Ans: [student@localhost student]$ ls [a-Za-z]*
Q6. Try the command pwd to see the present working directory
Ans: [student@localhost student]$ /home/student
Q7. Create files namely abc.txt ,aby.txt ,xdf ,x02,x04,ab4.
Ans: [student@localhost student]$ cat > abc.txt
[student@localhost student]$ cat > aby.txt
[student@localhost student]$ cat > xdf
[student@localhost student]$ cat > x02
[student@localhost student]$ cat > x04
[student@localhost student]$ cat > ab4
Q8. Display the files starting with a or t and second character b or x and length of the files should be only 3 characters.
Ans: [student@localhost student]$ ls [a,t][b,x]?
Q9. Create directories namely dir1,dir2,dir3
Ans: [student@localhost student]$ mkdir dir1,dir2,dir3.
Q10. Create three files in each of the directory.
Ans: [student@localhost student]$ cat > /home/student/dir1/file01
[student@localhost student]$ cat > /home/student/dir2/file02
[student@localhost student]$ cat > /home/student/dir3/file03
Q11. Copy all the files from these directories to the current directory.
Ans: [student@localhost student]$
Q12. Copy recursively the three directories include , bin, lib from / to directory.
Ans: [student@localhost student]$ cp –R { nitin1,nitin2,nitin3 }
/home/student/kap
Q13. Remove the file chap*
Ans: [student@localhost student]$ rm chap*
Q14. Display the file contents of file chap[0-3].
Ans: [student@localhost student]$ cat chap[0-3]
Q15. Create a file hello.
Ans: [student@localhost student]$ cat > hello
Q16. Create a hard link of the file hello name it as hai.
Ans: [student@localhost student]$ ln hello hai
Q17. Display the listing of both hello and hai files along either their i-node number.
Ans. [student@localhost student]$ ls –i hello hai
Q18. Create the symbolic link of file hello as hellohai
Ans. [student@localhost student]$ ln –s hello hai
Q19. Display the listing of both hello and hellohai files along with their i-node number.
Ans. [student@localhost student]$ ls –i hello hellohai
Q20. Display the process status of all the processes running on linux.
Ans. [student@localhost student]$ ps
Q21. Display the hidden files and also marked them as executable and directory.
Ans. [student@localhost student]$ ls –Fa
Q22. Display all the directories, sub- directories and files.
Ans. [student@localhost student]$ls -R
Q23. Create a file name in file at 3 to 4 line of text to it.
Ans. [student@localhost student]$cat >infile
Q24. Count number of lines, words and characters in the filename infile.
Ans. [student@localhost student]$wc –lwm infile
Q25. Count number of words in infile with and without redirection.
Ans. [student@localhost student]$wc –w<infile
Q26. In a single command except data as well as display contents of the file infile.
Ans. [student@localhost student]$cat infile –
Q27. Display all the files starting with an alphabetic irrespective of the case.
Ans. [student@localhost student]$ls [a-zA-Z]*
Q28. Display the number of users logged on.
Ans. [student@localhost student]$who | wc-l
Q29. Display the number of files present in the current directory.
Ans. [student@localhost student]$ls –l | wc-l
Q30. Count number of bytes of all the .c files individually present in the current directory.
Ans. [student@localhost student]$wc –c *.c
Q31. Count total number of bytes of all the .c files present in the current directory.
Ans. [student@localhost student]$wc –c *.c | tail -1 –
Q32. Display the statement as there are _ files in the current directory using command substitution.
Ans. [student@localhost student]$echo “There are `ls –l –R | wc –l` files in current dir.”
Q33. Try the two statement echo the average pay is $1000
echo ‘the average pay is $1000’
echo “the average pay is $1000”
Ans. [student@localhost student]$echo ‘the average pay is $1000’
the average pay is $1000
echo “the average pay is $1000”
the average pay is 000
Q34. Create a shell variable as work and store the present working directory in it and display the same.
Ans. [student@localhost student]$ work=`pwd`
Q35. Try the command cat alone without using an argument.
Ans. [student@localhost student]$cat
(With only cat command with no file name it only read standard input.)
Check [Part-2] for next set of Questions.
Related
Recommend
-
6
50 Most Frequently Used UNIX / Linux Commands (With Examples) by Ramesh Natarajan on November 8, 2010
-
7
Top 15 Basic DevOps Interview Questions: 2021 EditionDecember 31st 2020
-
7
TSQL Interview Questions – Part 2 Next part of TSQL Interview Questions, contd. from my previous post.
-
6
TSQL Interview Questions – Part 1 These are the following common question that I faced in various TSQL interviews. … I’ll be updating this post with more questions. 1. Differen...
-
6
Basic Linux Commands for Beginners Knoldus Blog Audio Reading Time: 8 minutes Le...
-
7
Basic C Interview Questions These are few basic Interview questions in C .....1)How do we check whether a linked list is circular?2)What is the output of this program?#include ##include
-
8
3 basic Linux user management commands every sysadmin should know How to use the useradd, usermod, and userdel commands is e...
-
6
3 basic Linux group management commands every sysadmin should know How to use the groupadd, groupmod, and groupdel commands...
-
15
Jdk Posted on Nov 17 ...
-
2
Getting started Python is one of the most popular coding languages in the world—from building web apps to powering AI innovations. Its widespread usage can be attributed to its simplicity, robust community support, and versatility. As...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK