TODO
What does this command
find / -size +10M -exec ls -l {} \;
do?It finds all files using
ls -l
and hands them off to the find command to display.It finds all files older than 10 minutes and long lists them using the
ls
command.It finds all files larger than 10 MB and long lists them using the
ls
command.It uses the
ls
command to find all files in the filesystem matching the {} wildcard.
Which command will tell you how long a system has been running?
log
uptime
runtime
access
Which command in Bash executes the last line in the shell history that starts with
ls
?!
!!
!*
!ls
Why doesn’t
passwd -l
keep a user from logging in via other methods?The passwd command is not used for locking passwords.
There is no password
-l
option.It locks only the password, not the account, so users can still authenticate with keys or other methods.
It does lock the account, keeping users from logging in even if they are using other authentication methods.
Why might you use the usermod command?
to log out a user
to lock a user’s account
to change global user account settings
to set a user’s password
With most GNU commands, if an option is a word, not a letter, what will it be preceded by?
two dashes –
a backslash
a slash /
one dash -
nothing
Which command do you use to rename a file in Linux?
mv
rn
rename
ren
What is the command to change the owner of a file?
chown
chowner
chownfile
chownf
What is the command to get a list of all the users on a system?
users
who
whoami
w
What is the command to check if a port is used?
port
portcheck
lsof
netstat
How can we see how much disk is used?
df
du
ls
cd
How can we see how much memory is used?
df
du
ls
free
How can we see how much CPU is used?
df
du
ls
top
How can we see how much network is used?
df
du
ls
netstat
How can remove a service from the system?
systemctl stop
systemctl disable
systemctl remove
systemctl delete
How can I check if a service is running?
systemctl status
systemctl check
systemctl test
systemctl run
Note
Some things Man was never meant to know. For everything else, there’s Google.
Solutions to TODOs
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. TheM
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, thels -l
command is executed on each file. Thels
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.
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 commandslog
,runtime
,access
are not valid.
Answer: b. !ls
Explanation:
! - 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.
!! - This is a shortcut to repeat the last command. It’s equivalent to executing the very last command you ran.
!* - 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.
!ls - In Bash, the command !ls will execute the last command in the shell history that starts with “ls”.
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.
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.
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.
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. Thern
,rename
, andren
commands are not valid.
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. Thechowner
,chownfile
, andchownf
commands are not valid.
Answer: b. who
Explanation:
The
who
command is used to display information about users who are currently logged in. Theusers
command is used to display the users who are currently logged in. Thewhoami
command is used to display the current user. Thew
command is used to display information about users who are currently logged in and what they are doing.
Answer: c. lsof and d. netstat
Explanation:
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.
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.
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. Thedu
command is used to display disk usage for a directory. Thels
command is used to list files in a directory. Thecd
command is used to change directories.
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. Thedf
command is used to display disk usage. Thedu
command is used to display disk usage for a directory. Thels
command is used to list files in a directory.
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. Thedf
command is used to display disk usage. Thedu
command is used to display disk usage for a directory. Thels
command is used to list files in a directory.
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:
df - Used to display disk space usage of file systems.
du - Used to estimate file space usage.
ls - Used to list directory contents.
So, out of the provided options, the answer is:
netstat
However, if you’re specifically interested in bandwidth usage or throughput, you’d want to use tools like
iftop
,nload
, orbmon
, which are not listed among your choices.
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. Thesystemctl stop
command is used to stop a service. Thesystemctl remove
command is used to remove a service. Thesystemctl delete
command is used to delete a service.
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. Thesystemctl check
command is used to check the configuration of a service. Thesystemctl test
command is used to test a service. Thesystemctl run
command is used to run a service.