22 Unix Interview Questions on Basic Commands

1) How can you navigate to a directory?

cd dir

cd /demo/test/

2) How can you create a new directory?

mkdir dstemp

3) How can you see the path of the current directory?

pwd

4) How can you see the list of files in a directory?

ls

ls -ltr


5) How can you list the hidden files in a directory?

ls -al

6) How do you create a new file?

cat filename

7) How can you create a copy of the file?

cp file1 file2

8) How can you rename a file?

mv file1 file2

9) How can you delete a file?

rm filename

rm -f filename


10) How can you create a dummy file with no data for testing?

touch filename

11) How can you browse through the data in file?

cat filename

more filename


12) How can you view the top 10 records in a file?

head -10 filename

13) How can you view the bottom 10 records in a file?

tail -10 filename

14) How can you view only the 10th record of a file?

head -10 | tail -1 filename


15) How can you concatenate two files?

cat file1 > file2

16) How can you concatenate data from two different files into a third file?

cat file1 file2 >> file3

17) How can you count the number of characters in a file?

wc filename

18) How can you count the number of files in a directory?

ls -ltr | wc -l

19) How can you change the permissions on a file?

chmod 777 filename

20) How can you display unix server date?

date

21) How can you find out the user who is logged in?

whoami

22) How can you find out the unix version installed?

uname -a



Post a Comment

Previous Post Next Post

Contact Form