Skip to content

Instantly share code, notes, and snippets.

@maysam-h
Created May 29, 2017 21:03
Show Gist options
  • Save maysam-h/6987039d729ca0896e008bbe077018b4 to your computer and use it in GitHub Desktop.
Save maysam-h/6987039d729ca0896e008bbe077018b4 to your computer and use it in GitHub Desktop.

Linux Exam Examples

1. Where do I find the file docutils-common.xml?

find / -name "docutils-common.xml"

2. Determine the mime type of etc/w3m/mailcap

file -i /etc/w3m/mailcap

3. Find files starting with A,B,C,a,b,c

find / -name "[ABCabc]???"

4. Use cls as clear for all users

ln -s /usr/bin/clear /usr/bin/cls

5. Find the filetype of clear

file `which clear`
# or
file $(which clear)

6. Add a user called bonobo without a password, with full name Nonkey McRee, who lives in room 666 and has a work phone 555--123456

adduser -gecos "Monkey Shines,666,555-12345" bonobo --disabled-password

7. What is the file type of adduser

file $(which adduser)

8. As what user are you logged in right now?

whoami

9. What's the name of your server?

hostname

10. What is your domain name?

cat /etc/resolv.conf | grep "domain "
# or
hostname -d # another result

11. Find out if user user can sudo

grep user /etc/sudoers # no result = no sudo
# or
grep $USER /etc/sudoers
# or
grep $(whoami) /etc/sudoers

12. How much swap space is being used / is available?

free -h | grep Swap # case sensitive !

13. Generate a ssh public/private keypair with empty passphrase called my_key/my_key.pub for your user

ssh-keygen -t rsa -N "" f my-key

14. Create an empty file called empty_file

touch empty_file

15. How many times is the word the in the man page of ssh-keygen?

man ssh-keygen | grep "[Tt]he " | wc -w 
# or
men ssh-keygen | grep -iw "the" | wc -w # a little different

16. Bzip a file, but make sure any errors are written to /tmp/bzip_errors.log

bzip2 dddddd 2>>/tmp/bzip_errors.log # file `dddddd` does not exist
# `>` is write, `>>` is append
# check the errors:
cat /tmp/bzip_errors.log

17. Show only the hidden files

ls -ld .?*

18. check HOW MANY of your installed packages can be updated. Suppress any warning (DO NOT actually update)

apt update

19. Check which of your installed packages can be updated

apt list --upgradable

20. Create a named pipe /tmp/mypipe

mkfifo /tmp/mypipe

21. Show the first 10 lines of the passwd man page

man passwd | head -n 10

22. Show the last 20 lines of the manual page for dd

man dd | tail -n 20

23. Allow everyone to do anything with (a file called) love

touch love && chmod 777 love

24. Give (a file called) love to root

chown root love # as root
sudo shown root love # as a normal user

25. Search for a package with the word radius

apt search radius

26. Backup your home directory TO TAPE (hint: /dev/rmt would be a tape device if it were present)

tar cvf /dev/rmt ~ # if using `cf` instead of `cvf`, the files are not shown

27. Which processes are currently running as root

ps -ef | grep root

ps -ef | grep root | wc -l # count them
# or
ps -auroot | wc -l

28. Kill the bash shell you are running in

ps -C bash -o pid=  # find bash process id's
skill -u root

29. Which command do you use to show your networking information?

ip addr

# for eth0:
ifconfig eth0
# or
ip addr show dev eth0

30. Change DHCP to static

nano /etc/network/interface 
# change this file to static
#   add `auto eth0`
#   add `iface eth0 inet static`
#   add `address 192.168.146.10`
#   add `...`

service networking restart # restart network

31. Install a webserver

# 1. change interfaces file and make static
# 2. ping
# 3. apt update
# 4. apt-get install [webserver like apache or something]

Linux Exam Examples EMPTY

1. Where do I find the file docutils-common.xml?

2. Determine the mime type of etc/w3m/mailcap

3. Find files starting with A,B,C,a,b,c

5. Find the filetype of clear

6. Add a user called bonobo without a password, with full name Nonkey McRee, who lives in room 666 and has a work phone 555--123456

7. What is the file type of adduser

8. As what user are you logged in right now?

9. What's the name of your server?

10. What is your domain name?

11. Find out if user user can sudo

12. How much swap space is being used / is available?

13. Generate a ssh public/private keypair with empty passphrase called my_key/my_key.pub for your user

14. Create an empty file called empty_file

15. How many times is the word the in the man page of ssh-keygen?

16. Bzip a file, but make sure any errors are written to /tmp/bzip_errors.log

17. Show only the hidden files

18. check HOW MANY of your installed packages can be updated. Suppress any warning (DO NOT actually update)

19. Check which of your installed packages can be updated

20. Create a named pipe /tmp/mypipe

21. Show the first 10 lines of the passwd man page

22. Show the last 20 lines of the manual page for dd

23. Allow everyone to do anything with (a file called) love

24. Give (a file called) love to root

25. Search for a package with the word radius

26. Backup your home directory TO TAPE (hint: /dev/rmt would be a tape device if it were present)

27. Which processes are currently running as root

28. Kill the bash shell you are running in

29. Which command do you use to show your networking information?

30. Change DHCP to static

31. Install a webserver

OS Concepts (Linux) Mock Exam

1. When booting, what is NOT done during the firmware stage ?

  1. Power-on self test
  2. Load Drive partition table
  3. Load first stage bootloader
  4. Initialize hardware drivers

2. Where will you find the magic byte string ?

  1. In the partition table header
  2. In a script
  3. in the ACL
  4. in the /etc/shadow file

3. The founders of UNIX wanted to create...

  1. An all-in one system that provided everything in a total, complete, monolithic package so you can get started immediately.
  2. A revenue-yielding business-solution by design
  3. A minimalist system that admins had to tweak by themselves
  4. Wrong A world without beards

4. Which 1 of the following are NOT (part of) one of the 4 Core Principles of UNIX ?

  1. Don't insist on interactive input
  2. Wrong Design and build software, even operating systems, to be tried early, ideally within weeks. Don't hesitate to throw away the clumsy parts and rebuild them
  3. Make your program do many things well. To do a new job, expand an existing program instead of writing a new program that the user has to be informed about.
  4. Use tools in preference to unskilled help to lighten a programming task, EVEN if you have to detour to build the tools and expect to throw some of them out after you've finished using them

5. In a non-systemd linux system, which command would NOT work ?

  1. telint 6
  2. chkconfig httpd on
  3. systemctl -a
  4. service httpd start

6. The very first true UNIX system was programmed in...

  1. Assembler
  2. C Language
  3. Fortran
  4. B Language

7. If I wanted to keep tabs on my CPU usage in Linux, I'd use which command ?

  1. Free
  2. Top
  3. Head
  4. Dmesg

8. Your UMASK is set to 000. You touch a file called my_file.sh. What would the start of ls -al my_file.sh look like ?

  1. -rw-rw-rw-
  2. -rwxrwxrwx-
  3. -rwx-rw-rw-
  4. rwxrwxrwx-

9. Which of the following statements is incorrect concerning the /proc partition type ?

  1. /proc is linked to a device
  2. /proc is a pseudo filesystem
  3. /proc is a gateway to the linux kernel
  4. /proc contains files that you can read / write to

10. Which of the following statements is CORRECT ?

  1. When using a HDD, the file system must be mounted on a partition.
  2. You can only have one partition per file system
  3. The root of the filesystem (/) is virtual and never really STORED anywhere physically
  4. Your file system is always seen as a tree structure. Parts of a tree (a branch) can be located on a different partition or disk but NOT on another medium (network storage, DVD, USB stick, ...).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment