TODO

  1. What does this command find / -size +10M -exec ls -l {} \; do?

    1. It finds all files using ls -l and hands them off to the find command to display.

    2. It finds all files older than 10 minutes and long lists them using the ls command.

    3. It finds all files larger than 10 MB and long lists them using the ls command.

    4. It uses the ls command to find all files in the filesystem matching the {} wildcard.

  2. Which command will tell you how long a system has been running?

    1. log

    2. uptime

    3. runtime

    4. access

  3. Which command in Bash executes the last line in the shell history that starts with ls?

    1. !

    2. !!

    3. !*

    4. !ls

  4. Why doesn’t passwd -l keep a user from logging in via other methods?

    1. The passwd command is not used for locking passwords.

    2. There is no password -l option.

    3. It locks only the password, not the account, so users can still authenticate with keys or other methods.

    4. It does lock the account, keeping users from logging in even if they are using other authentication methods.

  5. Why might you use the usermod command?

    1. to log out a user

    2. to lock a user’s account

    3. to change global user account settings

    4. to set a user’s password

  6. With most GNU commands, if an option is a word, not a letter, what will it be preceded by?

    1. two dashes –

    2. a backslash

    3. a slash /

    4. one dash -

    5. nothing

  7. Which command do you use to rename a file in Linux?

    1. mv

    2. rn

    3. rename

    4. ren

  8. What is the command to change the owner of a file?

    1. chown

    2. chowner

    3. chownfile

    4. chownf

  9. What is the command to get a list of all the users on a system?

    1. users

    2. who

    3. whoami

    4. w

  10. What is the command to check if a port is used?

    1. port

    2. portcheck

    3. lsof

    4. netstat

  11. How can we see how much disk is used?

    1. df

    2. du

    3. ls

    4. cd

  12. How can we see how much memory is used?

    1. df

    2. du

    3. ls

    4. free

  13. How can we see how much CPU is used?

    1. df

    2. du

    3. ls

    4. top

  14. How can we see how much network is used?

    1. df

    2. du

    3. ls

    4. netstat

  15. How can remove a service from the system?

    1. systemctl stop

    2. systemctl disable

    3. systemctl remove

    4. systemctl delete

  16. How can I check if a service is running?

    1. systemctl status

    2. systemctl check

    3. systemctl test

    4. systemctl run

Note

Some things Man was never meant to know. For everything else, there’s Google.

Solutions to TODOs

  1. Answer: c. It finds all files larger than 10 MB and long lists them using the ls command

Explanation:

The find command is used to search for files and directories in a specified location. In this case, the search is being performed on the root directory /. The -size option is used to specify the size of the files to search for. The + sign indicates that the search should be for files larger than the specified size, which in this case is 10 megabytes. The M indicates that the size is in megabytes. The -exec option is used to execute a command on each file that is found. In this case, the ls -l command is executed on each file. The ls command is used to list the files in a directory, and the -l option is used to display the file details in a long format. The {} is a placeholder for the file name that is found by the find command. The \; is used to indicate the end of the command. Overall, this command is useful for finding large files on a system that may be taking up too much space.

  1. Answer: b. uptime

Explanation:

The uptime command is used to display how long a system has been running. It also displays the number of users currently logged in and the system load averages for the past 1, 5, and 15 minutes. The commands log, runtime, access are not valid.

  1. Answer: b. !ls

Explanation:

  1. ! - This is used to reference events in the command history. You use it with a number or a string to reference specific commands. For instance, !5 would re-execute the fifth command in the history.

  2. !! - This is a shortcut to repeat the last command. It’s equivalent to executing the very last command you ran.

  3. !* - This references all the arguments of the previous command. For example, if you typed echo hello world, then typing cat !* would be equivalent to typing cat hello world.

  4. !ls - In Bash, the command !ls will execute the last command in the shell history that starts with “ls”.

  1. Answer: c. It locks only the password, not the account, so users can still authenticate with keys or other methods.

Explanation:

The passwd command is used to change a user’s password. It locks only the password, not the account, so users can still authenticate with keys or other methods.

  1. Answer: d. to set a user’s password

Explanation:

The usermod command is used to modify a user account. It can be used to change the user’s home directory, shell, and group. It can also be used to set a user’s password.

  1. Answer: a. two dashes --

Explanation:

With most GNU commands, if an option is a word, not a letter, it will be preceded by two dashes --. For example, the --help or -h option is used to display the help information for a command.

  1. Answer: a. mv

Explanation:

The mv command is used to move or rename files and directories. For example, mv file1 file2 would rename file1 to file2. The rn, rename, and ren commands are not valid.

  1. Answer: a. chown

Explanation:

The chown command is used to change the owner of a file or directory. For example, chown user1 file1 would change the owner of file1 to user1. The chowner, chownfile, and chownf commands are not valid.

  1. Answer: b. who

Explanation:

The who command is used to display information about users who are currently logged in. The users command is used to display the users who are currently logged in. The whoami command is used to display the current user. The w command is used to display information about users who are currently logged in and what they are doing.

  1. Answer: c. lsof and d. netstat

Explanation:

  1. lsof

You can use it with the -i option followed by the port number to check if the port is in use. For instance: css

lsof -i :80
# This would check if port 80 is in use.
  1. netstat

This command displays network connections, routing tables, interface statistics, masquerade connections, etc. To check if a specific port is in use, you can use:

netstat -tuln | grep :80
# This would check if port 80 is in use.

From the provided options, the correct answers are lsof and netstat. However, if you were looking for a single answer, I’d lean towards netstat as it’s more commonly associated with this task.

  1. Answer: a. df

Explanation:

The df command is used to display disk usage. It displays the amount of disk space available on the file system. The du command is used to display disk usage for a directory. The ls command is used to list files in a directory. The cd command is used to change directories.

  1. Answer: d. free

Explanation:

The free command is used to display memory usage. It displays the amount of free and used memory in the system. The df command is used to display disk usage. The du command is used to display disk usage for a directory. The ls command is used to list files in a directory.

  1. Answer: d. top

Explanation:

The top command is used to display information about processes and system resources. It displays the processes that are currently running and their resource usage. The df command is used to display disk usage. The du command is used to display disk usage for a directory. The ls command is used to list files in a directory.

  1. Answer: d. netstat

Explanation:

netstat (Network Statistics) displays active connections, listening ports, routing tables, interface statistics, and more. While it does not show the actual “bandwidth” being used, it provides information about active network connections.

The other options are related to file and directory operations:

  1. df - Used to display disk space usage of file systems.

  2. du - Used to estimate file space usage.

  3. ls - Used to list directory contents.

So, out of the provided options, the answer is:

  1. netstat

However, if you’re specifically interested in bandwidth usage or throughput, you’d want to use tools like iftop, nload, or bmon, which are not listed among your choices.

  1. Answer: b. systemctl disable

Explanation:

The systemctl disable command is used to disable a service. It prevents the service from starting automatically at boot time. The systemctl stop command is used to stop a service. The systemctl remove command is used to remove a service. The systemctl delete command is used to delete a service.

  1. Answer: a. systemctl status

Explanation:

The systemctl status command is used to check if a service is running. It displays the status of a service. The systemctl check command is used to check the configuration of a service. The systemctl test command is used to test a service. The systemctl run command is used to run a service.