QT Lab 08 by 17-16TL20
QT Lab 08 by 17-16TL20
Lab# 08
Exercise
1. The command to display your current directory is pwd .
2. The command to change to the /etc directory is .cd/ etc
3. The command to go to the parent directory of the current directory is .cd ..
4. The command to go to the root directory is cd /
5. The command to list the contents of the root directory is ls /
6. The command to list the contents of /etc directory is ls
7. The command to list all the files (including hidden files) in your home directory is-a
8. The command to list the files in /boot in a human readable format is ls -h.
9. The command to change to the /etc directory, stay here and create a directory newdir in your
home directory is mkdirnewdir
10. To create in one command the directories /dir1/dir2/dir3 (dir3 is a subdirectory from dir2,
and dir2 is a subdirectory from dir1) would be mkdir -p~/ dir1/dir2/dir3
11. The command to display the type of file of /bin/cat, /etc/passwd and /usr/bin/passwd is file
/bin/car- /etc/passwd /usr/bin/passwd
12. The command to rename filename.jpg to filename.pdf is .ren b:jpg*.* b:*.pdf
13. The command to create a directory /touched and enter it is mkdir -/touched ; cd -/touched
14. To create the files today.txt and yesterday.txt using touch command is touch today. t,xt,
yest.erday . txt
15. The command to create a directory called /testbackup and copy all files from /touched into it
is mkdir -/testbackup ; cp -r -/touched -/testbackup/
16. Use one command to remove the directory /testbackup and all files into it is .rm -rf -
/testbackup
Submitted by Saad Khan
Roll No. 17‐16TL20
Queueing Theory
Lab# 08
17: Create a directory /etcbackup and copy all *.conf files from /etc into it. Did you include
all subdirectories of /etc ? Display the snapshot as a proof.
Ans:
Proof:
Submitted by Saad Khan
Roll No. 17‐16TL20
Queueing Theory
Lab# 08
20: Use cat to create a file named count.txt that looks like this:
Submitted by Saad Khan
Roll No. 17‐16TL20
Queueing Theory
Lab# 08
21. Use cp to make a backup of this file to cnt.txt
23. Display catcnt.txt, but with all lines in reverse order (the last line first)
25. Display the readable character strings from the /usr/bin/passwd command.
27. Use cat to create a file name tailing.txt that contains the contents of trailing.txt followed
by the contents of /etc/passwd.
Submitted by Saad Khan
Roll No. 17‐16TL20
Queueing Theory
Lab# 08
28. What is the size of the Linux kernel file(s) (vmlinu*) in /boot?
Ans: ls ‐lh /boot/vm*
Ans: The file should contain at least one line with Intel or other cpu.
30. Use cal command to quickly view a calendar on terminal in Linux. Try it and show the
display.
Ans:
31. Is it true that date command on Linux terminal would display current Time. Try it and
show the display.
Ans:
Submitted by Saad Khan
Roll No. 17‐16TL20
Queueing Theory
Lab# 08
32. bc (Basic Calculator) is a command line utility that offers everything you expect from a
simple scientific or financial calculator. Explain the output of the following command.
Ans:
33. egrep is an acronym for Extended Global Regular Expressions Print. It is a program
which scans a specified file line by line, returning lines that con-tain a pattern matching a
given regular expression. Describe the use of egrep in the following examples.
Ans:
34. find command can be used to find files and direct-ories and perform subsequent
operations on them. It supports searching by file, folder, name, cre-ation date, modification
date, owner and permis-sions. Describe the use of find in the following examples.
Ans:
35. Ctrl R command in terminal is used to search for any command in command history. In
the terminal, hold down Ctrl and press R to invoke reverse-i-search and type a letter to get
a match for the most recent command in your history that starts with that letter. Keep
typing to narrow your match. How to cycle through other previously typed matching
commands?
Ans:
36. Display the last 5 commands you typed.
Submitted by Saad Khan
Roll No. 17‐16TL20
Queueing Theory
Lab# 08
37. Show how to create multiple directories using ter-minal. Lets say 100 directories.
Ans: saad@ubuntu:~$ mkdir ‐p {dir1,dir2,dir3,dir4, ..., dir100}
38. Show how to move a folder containing files and sub-folders to another folder using
terminal.
39. Try rename command and show how to rename multiple files and directories.
Ans:
40. Show how to open an image from the linux terminal.
Submitted by Saad Khan
Roll No. 17‐16TL20