Linux Unhatched Assignments Assessment Exam Answers
Linux Unhatched Assignments Assessment Exam Answers 2024 and 2025
The Cisco NDG Linux Unhatched Assignments Assessment Exam Answers serve as an introductory step into the world of Linux, offering foundational knowledge and skills for beginners. As part of Cisco NetAcad’s initiative to prepare students for IT careers, the Linux Unhatched final exam evaluates learners on key concepts and hands-on tasks. Below, you’ll find the updated 2024 and 2025 exam answers, carefully curated to help students review, understand, and excel in their assessments.
-
What does CLI stand for?
- Core Line Interface
- Core Learning Interface
- Command Learning Interface
- Command Line Interface
Explanation & Hints: The correct answer is: Command Line Interface.
A Command Line Interface (CLI) is a text-based interface that allows users to interact with a computer system by typing commands. It provides direct control over operating systems and software applications, often used for administrative tasks, troubleshooting, and running scripts. Unlike graphical user interfaces (GUIs), CLIs rely on typed input, making them efficient and powerful for users familiar with the commands.
Why not the other options?
- Core Line Interface: This term is incorrect and not related to computing or software interfaces.
- Core Learning Interface: This is a fabricated term and does not exist in the context of computing.
- Command Learning Interface: While it may sound plausible, this is not the correct acronym or meaning for CLI.
Command Line Interface is the widely recognized and accurate definition.
-
Commands are case-sensitive.
True or False?
- True
- False
-
Explanation & Hints: The correct answer is: True
Commands in a Command Line Interface (CLI) are often case-sensitive, meaning that the system treats uppercase and lowercase letters as distinct. For example, typing
DIR
anddir
may produce different results or lead to errors depending on the operating system or software.Example:
- On Linux/Unix-based systems, commands like
ls
(lowercase) must be typed exactly as they are; typingLS
(uppercase) would result in an error. - On Windows, most commands in the Command Prompt are not case-sensitive, so
dir
andDIR
would work the same way. However, some applications may still enforce case sensitivity.
It’s always safer to assume that commands are case-sensitive unless explicitly stated otherwise.
- On Linux/Unix-based systems, commands like
-
When entering a command, do arguments or options typically come first?
- Options
- Arguments
-
Explanation & Hints: The correct answer is: Options.
In most command-line syntax, options (or flags) typically come first, followed by arguments. Options modify the behavior of the command, while arguments specify the target or input for the command.
Example:
- Options:
-l
(modifies the behavior ofls
to show detailed information) - Argument:
/home
(specifies the directory to list)
However, some commands allow flexibility, and the order can vary based on the command or operating system. Always refer to the command’s documentation for the exact syntax.
- Options:
-
Which of the following is NOT a correct way to combine options?
-rl
-r l
-lr
-l -r
-
Explanation & Hints: The incorrect way to combine options is: -r l
In most command-line tools, options can often be combined when they are single-character flags. The correct combinations depend on the syntax rules of the tool you’re using:
- -rl: ✅ Correct. This combines
-r
and-l
into a single flag group. - -lr: ✅ Correct. The order doesn’t matter; the tool interprets it the same as
-rl
. - -l -r: ✅ Correct. Writing them separately is also valid and equivalent to combining them.
- -r l: ❌ Incorrect. This syntax is invalid because it suggests
l
is an argument rather than an option. There should be no space between single-character options unless the command explicitly expects arguments.
Always check the specific tool’s documentation for combining options, as some may not support certain combinations.
- -rl: ✅ Correct. This combines
-
Which command will print your current location in the filesystem?
pcl
cd
pd
pwd
-
Explanation & Hints: The correct answer is: pwd
The
pwd
command stands for “print working directory”. It displays the full path of your current location in the filesystem.Example:
If you are in the
/home/user/Documents
directory and run thepwd
command, it will output:Why not the other options?
- pcl: This is not a valid command.
- cd: The
cd
command is used to change directories, not to display the current location. - pd: This is also not a valid command.
-
Which command will allow you to change your current directory?
chdir
cd
ls
ch
-
Explanation & Hints: The correct answer is: cd
The
cd
command (short for “change directory”) is used to navigate between directories in a filesystem. It allows you to change your current working directory to another location.Example:
This command changes the current directory to
/home/user/Documents
.Why not the other options?
- chdir: While
chdir
is a valid command in some operating systems (like Windows), it is less commonly used. On Linux and macOS,cd
is standard. - ls: The
ls
command is used to list the contents of a directory, not to navigate directories. - ch: This is not a valid command for changing directories.
- chdir: While
-
Which of the following is NOT an example of an absolute path?
Documents
/
/home/sysadmin
-
Explanation & Hints: The correct answer is: Documents
An absolute path specifies the full path to a file or directory starting from the root of the filesystem (denoted by
/
). It provides the complete location regardless of the current working directory.Examples of absolute paths:
/
: The root directory./home/sysadmin
: Starts from the root and specifies the complete path.
Why Documents is NOT an absolute path:
- Documents is a relative path, not an absolute one. A relative path depends on the current working directory. For instance, if your current directory is
/home/sysadmin
, the pathDocuments
refers to/home/sysadmin/Documents
.
Absolute paths always start with
/
, while relative paths do not.
-
Which of the following is NOT an example of a relative path?
/home
home/sysadmin/Documents/School/Art
Documents/Work
Documents
-
Explanation & Hints: The correct answer is: /home
A relative path specifies a location in the filesystem relative to the current working directory. It does not start with
/
, which denotes the root of the filesystem.Examples of relative paths:
- home/sysadmin/Documents/School/Art: This is relative because it does not start with
/
. It depends on the current working directory. - Documents/Work: This is a relative path pointing to the “Work” directory inside “Documents.”
- Documents: This is a relative path pointing to the “Documents” directory in the current working directory.
Why /home is NOT a relative path:
- /home is an absolute path because it starts with
/
, which means it specifies the location starting from the root of the filesystem, independent of the current working directory.
- home/sysadmin/Documents/School/Art: This is relative because it does not start with
-
The ~ (tilde) character is used to represent:
- The current directory
- Nothing, it doesn’t have a special meaning
- A user’s home directory
- The directory above the current directory
-
Explanation & Hints: The correct answer is: A user’s home directory
The
~
(tilde) character is a shorthand symbol in many shells (like Bash) that represents the home directory of the current user. This allows users to quickly reference their home directory without typing the full path.Example:
- If the current user’s home directory is
/home/sysadmin
, then:cd ~
will take you to/home/sysadmin
.ls ~/Documents
will list the contents of/home/sysadmin/Documents
.
Why not the other options?
- The current directory: The current directory is represented by
.
(a single dot), not~
. - Nothing, it doesn’t have a special meaning: The tilde has a defined purpose in shells like Bash.
- The directory above the current directory: The directory above is represented by
..
(two dots), not~
.
- If the current user’s home directory is
-
The .. (double period) characters are used to represent:
- The directory above the current directory
- A user’s home directory
- The current directory
- Nothing, it doesn’t have a special
-
Explanation & Hints: The correct answer is: The directory above the current directory
The
..
(double period) characters are used in command-line interfaces to represent the parent directory, which is the directory one level above the current working directory in the filesystem hierarchy.Example:
If you are in
/home/user/Documents
:cd ..
will take you to/home/user
.cd ../..
will take you two levels up, to/home
.
Why not the other options?
- A user’s home directory: The user’s home directory is represented by
~
, not..
. - The current directory: The current directory is represented by
.
(a single dot), not..
. - Nothing, it doesn’t have a special meaning: The
..
characters have a specific purpose in navigating the filesystem.
-
The . (period) character is used to represent:
- Nothing, it doesn’t have a special meaning
- The current directory
- The directory above the current directory
- A user’s home directory
-
Explanation & Hints: The correct answer is: The current directory
The
.
(period) character represents the current directory in a filesystem. It is commonly used in commands to explicitly refer to the current working directory.Examples:
- Executing a script in the current directory:
Here,
./
ensures the script is executed from the current directory. - Copying a file to the current directory:
This command copies the file into the current directory.
Why not the other options?
- Nothing, it doesn’t have a special meaning: The period has a specific meaning in the context of filesystems.
- The directory above the current directory: The directory above is represented by
..
, not.
. - A user’s home directory: The home directory is represented by
~
, not.
.
- Executing a script in the current directory:
-
The ls command without options or arguments…
- …lists the contents of the current directory.
- …generates an error as this command.
- …lists the contents of a user’s home.
- …prompts for a directory to list.
-
Explanation & Hints: The correct answer is: …lists the contents of the current directory.
When you run the
ls
command without any options or arguments, it lists the files and directories in the current working directory. This is the default behavior of thels
command.Example:
If your current directory is
/home/user
and you run:You will see the contents of
/home/user
.Why not the other options?
- …generates an error as this command: This is incorrect. The
ls
command works without options or arguments. - …lists the contents of a user’s home: The
ls
command lists the current directory, not necessarily the home directory. To list the home directory, you could usels ~
. - …prompts for a directory to list: The
ls
command does not prompt for input. It simply defaults to listing the current directory if no arguments are provided.
- …generates an error as this command: This is incorrect. The
-
The first character in a long listing ls -l indicates:
- File Type
- Permissions
- File Size
- Hard Link Count
-
Explanation & Hints: The correct answer is: File Type
When using the
ls -l
command (long listing format), the first character in the output represents the file type.Example Output of
ls -l
:- The first character here is
-
, which indicates a regular file. - Other possible values for the first character:
d
: Directoryl
: Symbolic linkc
: Character device fileb
: Block device files
: Socketp
: Named pipe (FIFO)
Why not the other options?
- Permissions: Permissions are represented by the next nine characters (e.g.,
rw-r--r--
). - File Size: The file size is displayed later in the listing, typically in bytes.
- Hard Link Count: The hard link count is shown as the first number after the permissions column.
- The first character here is
-
Which option to the ls will sort the output by file size?
-r
-s
-z
-S
-
Explanation & Hints: The correct answer is:
-S
The
-S
option for thels
command sorts the output by file size, displaying the largest files first.Example:
This command lists files in the long format (
-l
) and sorts them by size in descending order (largest to smallest).Why not the other options?
-r
: This reverses the sort order of any other sorting option but does not sort by size on its own.-s
: This shows the disk usage (in blocks) of each file but does not sort by size.-z
: This is not a valid option forls
.
-
Which of these commands will create a new shell logged in as the root user?
sudo
su
-
Explanation & Hints:The correct answer is: su
The
su
(short for “substitute user” or “switch user”) command allows you to switch to another user account, including the root user. When used without specifying a username,su
defaults to switching to the root user and creates a new shell as that user.Example:
This command prompts for the root user’s password. Once entered, you will be logged in as root.
Why not
sudo
?sudo
(short for “superuser do”) runs a single command as the root user or another user, rather than starting a new shell. To create a new shell as root usingsudo
, you would have to explicitly request it with:or
- By itself,
sudo
does not log you in as the root user permanently but only grants temporary elevated privileges for the specified command.
-
Which of the following sets has the owner permissions highlighted?
rw-rw-r--
is the correct answerrw-rw-r--
rw-rw-r--
rw-rw-r--
-
Explanation & Hints: In the context of Unix/Linux file permissions, “owner permissions” refer to the first triplet of characters in the permission set (
rw-
in these cases). This triplet defines what the file’s owner is allowed to do. Here’s the breakdown of the permission set:r
– Read permissionw
– Write permissionx
– Execute permission
Analysis of the given permission sets:
rw-rw-r--
- Owner permissions:
rw-
(Read and Write) - Group permissions:
rw-
(Read and Write) - Others permissions:
r--
(Read only)
- Owner permissions:
Since all examples provided are identical (
rw-rw-r--
), they all highlight the same owner permissions, specifically read (r) and write (w) access.To summarize:
- The owner permissions in all the examples are
rw-
, indicating that the owner can read and write the file but cannot execute it.
-
Which of the following sets has the group permissions highlighted?
rw-rw-r--
rw-rw-r--
rw-rw-r--
rw-rw-r--
is the correct answer-
Explanation & Hints: Here’s the second triplet of the permission set highlighted to show the group permissions:
rw-
rw-
r--
- The bold part (
rw-
) represents the group permissions. - This indicates that the group has read (r) and write (w) permissions, but no execute (
x
) permission.
- The bold part (
-
Which of the following sets has the other permissions highlighted?
rw-rw-r--
rw-rw-r--
rw-rw-r--
is the correct answerrw-rw-r--
-
Explanation & Hints: Here’s the last triplet of the permission set highlighted to show the other permissions:
rw-rw-
r--
- The bold part (
r--
) represents the other permissions. - This indicates that others (users not in the owner or group) have read (r) permission only and no write (
w
) or execute (x
) permissions.
- The bold part (
-
Which command will allow a user to change the permissions of a file?
perm
chmod
chown
chperm
-
Explanation & Hints: The correct answer is:
chmod
The
chmod
command is used to change the permissions of a file or directory. Withchmod
, users can set specific permissions for the owner, group, and others using symbolic or numeric modes.Example:
To give read, write, and execute permissions to the owner and read and execute permissions to the group and others:
Why not the other options?
perm
: This is not a valid command.chown
: Thechown
command is used to change the owner or group of a file, not its permissions.chperm
: This is not a valid command.
-
Which of the following permission sets indicates that others have only the read permission?
rwxrw-r-x
rw-rw-r--
r--r--r-x
rw-r--rwx
-
Explanation & Hints: The correct answer is:
rw-rw-r--
In the permission string format, the last three characters represent the permissions for others (everyone who is not the owner or in the group). Let’s analyze the options:
rwxrw-r-x
:- Others:
r-x
(read and execute permissions, not read-only).
- Others:
rw-rw-r--
:- Others:
r--
(read-only). ✅ This matches the question.
- Others:
r--r--r-x
:- Others:
r-x
(read and execute permissions, not read-only).
- Others:
rw-r--rwx
:- Others:
rwx
(read, write, and execute permissions, not read-only).
- Others:
Thus,
rw-rw-r--
correctly indicates that others have only read permission.
-
Which of the following commands is used to change the ownership of a file?
chperm
chown
chow
chmod
-
Explanation & Hints: The correct answer is:
chown
The
chown
command is used to change the ownership of a file or directory. It allows you to assign a new owner and/or group to the file.Example:
To change the owner of a file to
username
:To change both the owner and group:
Why not the other options?
chperm
: This is not a valid command.chow
: This is not a valid command.chmod
: This is used to change the permissions of a file, not its ownership.
-
Changing the user owner of a file requires administrative access.
True or False?
- True
- False
-
Explanation & Hints: The correct answer is: True
Changing the user owner of a file using the
chown
command requires administrative (root) access. Regular users cannot change the ownership of a file to another user unless they have the necessary privileges.Example:
If a non-administrative user attempts to change ownership:
It will result in a “Permission denied” error unless the user has administrative privileges (e.g., by using
sudo
):This restriction ensures that file ownership cannot be altered arbitrarily, which is important for system security and user isolation.
-
Which of the following commands can be used to rename a file?
mv
rn
name
cp
-
Explanation & Hints: The correct answer is:
mv
The
mv
command is primarily used to move files, but it can also be used to rename a file. Renaming is essentially moving a file to a new name within the same directory.Example:
To rename a file:
This changes the file’s name from
oldname.txt
tonewname.txt
.Why not the other options?
rn
: This is not a valid command for renaming files.name
: This is not a valid command for renaming files.cp
: Thecp
command is used to copy files, not rename them. While you could copy a file and delete the original to achieve a similar effect, this is not how files are typically renamed.
-
The mv command requires at least two arguments.
True or False?
- True
- False
-
Explanation & Hints: The correct answer is: True
The
mv
command requires at least two arguments:- Source: The file or directory you want to move or rename.
- Destination: The new name or location for the file or directory.
Example:
- To rename a file:
oldname.txt
: Sourcenewname.txt
: Destination
- To move a file:
file.txt
: Source/path/to/destination/
: Destination
If fewer than two arguments are provided, the
mv
command will fail and display an error.Why not False?
The
mv
command cannot function with only one argument, as it would not know where to move or rename the file. At least two arguments are mandatory.
-
Which command can be used to copy a file?
cy
rm
cp
mv
-
Explanation & Hints: The correct answer is:
cp
The
cp
command is used to copy files or directories in a filesystem. It creates a duplicate of the specified file or directory at the target location.Example:
To copy a file:
This creates a copy of
sourcefile.txt
nameddestinationfile.txt
.To copy a file to another directory:
Why not the other options?
cy
: This is not a valid command.rm
: Therm
command is used to remove (delete) files or directories, not copy them.mv
: Themv
command is used to move or rename files, not copy them.
-
The cp command requires at least two arguments.
True or False?
- True
- False
-
Explanation & Hints: The correct answer is: True
The
cp
command requires at least two arguments:- Source: The file or directory you want to copy.
- Destination: The location or name of the new copy.
Example:
- To copy a file to a new name:
file.txt
: Sourcenewfile.txt
: Destination
- To copy a file to a directory:
file.txt
: Source/path/to/destination/
: Destination
If only one argument is provided, the command will fail because it doesn’t know where to copy the file.
Why not False?
The
cp
command cannot work with just one argument because it would lack the necessary destination information to complete the operation.
-
Which command is used to copy files at the bit level?
cp
dd
-
Explanation & Hints: The correct answer is:
dd
The
dd
command is a low-level tool used to copy files at the bit or byte level. It is often used for creating disk images, cloning drives, or copying raw data, as it allows precise control over how data is read and written.Example:
- To create an exact copy of a file:
if=
: Input file (source)of=
: Output file (destination)
- To create a disk image:
This reads data from the device
/dev/sdX
and writes it todiskimage.img
.
Why not
cp
?The
cp
command works at the file level and is intended for standard file copying operations, not raw or bit-level data copying. While effective for most use cases, it does not provide the low-level control thatdd
offers. - To create an exact copy of a file:
-
The rm command requires at least two arguments.
True or False?
- True
- False
-
Explanation & Hints: False
The
rm
command does not require at least two arguments. It can operate with just one argument (the name of the file or directory to remove). For example:This command will delete the file named
filename
. Additional arguments or options can be provided, but they are not required.
-
Which option to the rm command will allow a user to delete directories?
-d
-r
-l
-a
-
Explanation & Hints: The correct option to allow a user to delete directories using the
rm
command is:-r
-r
(or--recursive
): Allows therm
command to recursively delete directories and their contents.- Example:
rm -r directory_name
- Example:
Other Options:
-d
: Deletes empty directories only. It won’t work if the directory contains files.-l
: Not a valid option forrm
.-a
: Not a valid option forrm
.
Correct Command to Delete a Directory:
If you want to delete a directory and all its contents:
-
Which of the following commands is used to filter text?
grep
text
dd
regex
-
Explanation & Hints: The correct command used to filter text is:
grep
grep
: This command is specifically designed to search and filter text based on patterns or regular expressions.- Example:
grep "pattern" filename
- It searches for the specified pattern in a file or input and displays the matching lines.
- Example:
Other Options:
text
: Not a valid command in Unix/Linux for filtering text.dd
: A command used for low-level data copying and conversion, not for filtering text.regex
: Refers to regular expressions, a pattern-matching technique, but it is not a command itself.
Example Usage of
grep
:This command filters and displays lines containing the word “error” from
logfile.txt
.
-
Which of the following commands will return only lines that begin with test?
grep '*test' file.txt
grep '[test]' file.txt
grep '$test' file.txt
grep '^test' file.txt
-
Explanation & Hints: The correct command to return only lines that begin with the word
test
is:grep '^test' file.txt
^
: In regular expressions, the caret (^
) is used to match the beginning of a line. So^test
ensures that only lines starting with the stringtest
are matched.
Why the other options are incorrect:
grep '*test' file.txt
:- The asterisk (
*
) in regular expressions matches zero or more of the preceding character, but here it is misused since it does not anchor to the start of a line. - This command won’t work as intended.
- The asterisk (
grep '[test]' file.txt
:- Square brackets
[ ]
match any one character within them. For example,[test]
would matcht
,e
,s
, ort
, not the wordtest
or lines beginning withtest
.
- Square brackets
grep '$test' file.txt
:- The dollar sign (
$
) is used to match the end of a line, so$test
would search for lines ending withtest
, not beginning with it.
- The dollar sign (
Example Usage:
This will return all lines in
file.txt
that start with the wordtest
.
-
Which of the following commands will return only lines that end with test?
grep '$test' file.txt
grep 'test$' file.txt
grep '^test' file.txt
grep 'test^' file.txt
-
Explanation & Hints:
The correct command to return only lines that end with the wordtest
is:grep 'test$' file.txt
$
: In regular expressions, the dollar sign ($
) matches the end of a line. Sotest$
ensures that only lines ending with the stringtest
are matched.
Why the other options are incorrect:
grep '$test' file.txt
:- The
$
is misplaced at the start of the pattern, which does not make sense in this context.$
is used to signify the end of the line.
- The
grep '^test' file.txt
:- The
^
matches the beginning of the line, so this command would return lines starting withtest
, not ending with it.
- The
grep 'test^' file.txt
:- The
^
is misplaced at the end of the pattern, which is invalid syntax for regular expressions.
- The
Example Usage:
This will return all lines in
file.txt
that end with the wordtest
.
-
Which of the following lines would be NOT returned by the grep ‘[^0-9]’ file.txt command?
My favorite food is avocados.
Hello my name is Joe.
3121991
I am 37 years old.
-
Explanation & Hints:
The line that would NOT be returned by thegrep '[^0-9]' file.txt
command is:3121991
The[^0-9]
pattern ingrep
matches any line that contains at least one character that is not a digit (0-9). The caret (^
) inside the square brackets negates the set, so it matches anything except digits.Analysis of each line:
My favorite food is avocados.
- Contains letters and spaces, which are not digits. This line would be returned.
Hello my name is Joe.
- Contains letters and spaces, which are not digits. This line would be returned.
3121991
- Contains only digits and no non-digit characters. This line would NOT be returned.
I am 37 years old.
- Contains letters, spaces, and digits. The non-digit characters mean this line would be returned.
Final Answer:
The line
3121991
would NOT be returned.
-
Which of the following lines would be returned by the
grep 'b[oe]t' file.txt
command?boet
bet
boot
beet
-
Explanation & Hints:
The commandgrep 'b[oe]t' file.txt
looks for lines matching the pattern:b
: A literalb
.[oe]
: Eithero
ore
.t
: A literalt
.
This means the command will match
bet
orbot
, but nothing else.Analysis of each line:
boet
:- Does not match because there are two characters (
oe
) betweenb
andt
. The pattern only allows one character (o
ore
) between them.
- Does not match because there are two characters (
bet
:- Matches because it starts with
b
, hase
(from[oe]
), and ends witht
.
- Matches because it starts with
boot
:- Does not match because there are two
o
s betweenb
andt
, which is not allowed by the pattern.
- Does not match because there are two
beet
:- Does not match because there are two
e
s betweenb
andt
, which is not allowed by the pattern.
- Does not match because there are two
Final Answer:
The only line that matches is:
bet
-
Which of the following commands will NOT shutdown the system immediately?
shutdown now 'Goodbye World!'
shutdown now
shutdown +0
shutdown
-
Explanation & Hints: The command that will NOT shut down the system immediately is:
shutdown
shutdown now 'Goodbye World!'
:- The
now
argument ensures the system shuts down immediately. The message ('Goodbye World!'
) is optional and will be broadcast to logged-in users.
- The
shutdown now
:- The
now
argument ensures an immediate shutdown.
- The
shutdown +0
:- The
+0
specifies a delay of 0 minutes, which effectively means the system will shut down immediately.
- The
shutdown
:- If run without any arguments, the
shutdown
command does not immediately shut down the system. Instead:- It schedules a shutdown with the default time (typically 1 minute from now).
- A message is displayed to users, and they are given time to save their work.
- If run without any arguments, the
Final Answer:
shutdown
does NOT shut down the system immediately.
-
Which of the following commands can be used to display network configuration information?
net
pwd
ifconfig
netconfig
-
Explanation & Hints: The correct command to display network configuration information is:
ifconfig
net
:- This is not a standard Linux/Unix command for displaying network configurations. It is a command used in Windows for various network operations but not for detailed network configuration.
pwd
:- This stands for “print working directory”. It displays the current directory in the filesystem but has no relation to network configuration.
ifconfig
:- This is the correct command to display network configuration information, such as:
- IP address
- Subnet mask
- Network interface status
- Example:
Output includes details about active network interfaces.
- This is the correct command to display network configuration information, such as:
netconfig
:- This is not a standard command for viewing network configurations. In some distributions, it may be a tool for setting up network configurations but not for displaying current configurations.
Modern Alternative to
ifconfig
In modern Linux distributions,
ifconfig
has been largely replaced by theip
command (from theiproute2
package). To display network configuration, you can use:
-
Which of the following commands will display every process?
ps -e
ps -a
ps --all
ps
-
Explanation & Hints: The correct command to display every process is:
ps -e
ps -e
:- This option displays all processes running on the system, regardless of the user or terminal.
- Equivalent to
ps --all
.
ps -a
:- This displays processes associated with all terminals, excluding session leaders (e.g., daemon processes).
ps --all
:- This is an alternative way to write
ps -e
(same functionality). It displays all processes running on the system.
- This is an alternative way to write
ps
:- Without any options, this command only displays processes running in the current shell/session. It does not show processes from other users or terminals.
Correct Command:
ps -e
or equivalentlyps --all
will display every process on the system.
-
The
ps
command requires administrative access.True or False?
- True
- False
-
Explanation & Hints: False
The
ps
command does not require administrative access to display information about processes.- The
ps
command is available to all users to view processes running on the system. - By default, it displays processes owned by the current user in the current shell/session.
Situations Where Administrative Access May Be Needed:
- If you want to view processes owned by other users or system-level processes, you can use the
ps
command with specific options (e.g.,ps -e
orps aux
), but this does not require administrative (root) privileges. - To view or interact with certain restricted processes (e.g., debugging or killing processes owned by other users), administrative access might be required.
Conclusion:
The
ps
command itself does not require administrative access, so the answer is False. - The
-
Which of the following commands will update all packages?
apt-get search
apt-get install
apt-get upgrade
apt-get update
-
Explanation & Hints: The correct command to update all packages is:
apt-get upgrade
Explanation of Each Command:
apt-get search
:- This command is used to search for specific packages in the repository.
- Example:
- It does not update or install any packages.
apt-get install
:- This command installs a specific package or updates a package if it is already installed.
- Example:
- It does not update all packages.
apt-get upgrade
:- This command upgrades all installed packages on the system to their latest versions, as available in the repositories.
- Example:
- This is the correct answer for updating all packages.
apt-get update
:- This command updates the package index (list of available packages and their versions) from the repository but does not upgrade any installed packages.
- Example:
- This must be run before
apt-get upgrade
to ensure the package list is up-to-date.
-
Which of the following will delete all of a package’s files?
apt-get trash
apt-get purge
apt-get remove
apt-get delete
-
Explanation & Hints: The correct command is:
apt-get purge
apt-get purge
: Removes the package and all its associated configuration files from the system. This is typically used when you want to completely get rid of a package and its settings.Other options:
apt-get remove
: Removes the package but leaves behind its configuration files. This is useful if you plan to reinstall the package and want to retain its settings.apt-get delete
: This is not a validapt-get
command.apt-get trash
: This is also not a validapt-get
command.
If you want a complete removal, use
apt-get purge
.
-
Which of the following commands should be executed before installing a package?
apt-get upgrade
apt-get search
apt-get update
apt-get install
-
Explanation & Hints: The correct command to execute before installing a package is:
apt-get update
apt-get update
: Updates the local package database with the latest information about available packages and their versions from the configured repositories. This ensures that you are installing the latest version of a package and resolves dependency issues.Other options:
apt-get upgrade
: Upgrades all installed packages to their latest versions. This is not directly related to preparing for a single package installation.apt-get search
: Searches the package database for a specific package or keyword. Useful for finding packages but not mandatory before installation.apt-get install
: Installs the specified package but does not update the package list beforehand. If the package database is outdated, you may encounter issues or install an older version of the package.
Recommended sequence:
- Run
apt-get update
to refresh the package list. - Then use
apt-get install <package_name>
to install the desired package.
-
Users can update their own passwords.
True or False?
- True
- False
-
Explanation & Hints:
TrueIn most systems, users are allowed to update their own passwords for security and account management purposes. The specific method for doing this depends on the operating system or environment:- Linux/Unix: Users can typically change their password using the
passwd
command. - Windows: Users can change their password through the “Change Password” option in the Control Panel or by pressing
Ctrl+Alt+Del
and selecting “Change a password.” - Web Applications: Many platforms provide a “Change Password” or “Reset Password” feature in the account settings.
This is an essential feature for maintaining security and ensuring users can manage their credentials independently.
- Linux/Unix: Users can typically change their password using the
-
The root user can change the password of any user.
True or False?
- True
- False
-
Explanation & Hints: True
The root user (or administrator) has full control over the system and can change the password for any user account without needing the existing password. This capability is often used for administrative tasks, such as resetting forgotten passwords or managing user accounts.
Example in Linux:
To change a user’s password, the root user can run:
The system will prompt the root user to enter a new password for the specified user.
This administrative privilege is one of the defining characteristics of the root account.
-
Which option can be used to view status information about the current user’s password?
-i
-s
-S
-I
-
Explanation & Hints: The correct option is:
-S
The
-S
option with thepasswd
command provides status information about the current user’s password. This includes details such as:- Password status (e.g., “enabled” or “disabled”).
- Last password change date.
- Password expiry and inactivity information.
Example:
To view the status of the current user’s password:
Output Example:
- P: Password is set (locked accounts will show
L
). - 12/15/2023: Last password change date.
- 0 99999 7 -1: Other password policy details (minimum/maximum days, warnings, inactivity).
Other Options:
-i
: Sets the number of inactive days after a password expires before the account is locked.-s
: This is not a valid option for thepasswd
command.-I
: Sets the number of days of inactivity after which the account becomes disabled.
The
-S
option is specifically used for viewing password status.
-
Which of the following commands can be used to print output to the terminal?
ls
echo
cp
chmod
-
Explanation & Hints: The correct command is:
echo
echo
: This command is explicitly used to display (or “print”) output to the terminal. It is often used to print text or the value of variables.
Example:
Output:
Other commands:
ls
: Lists files and directories in the current or specified directory. While it does produce output, it’s not specifically designed for arbitrary printing likeecho
.cp
: Copies files or directories. It does not print anything to the terminal unless an error occurs or used with a verbose flag like-v
.chmod
: Changes the permissions of a file or directory. It also does not print output unless used with the verbose flag-v
.
For explicitly printing output,
echo
is the correct choice.
-
The
>
character is used for which of the following file descriptors?- STDERR
- STDOUT
- STDIN
-
Explanation & Hints: The
>
character is used for theSTDOUT
file descriptor.STDOUT
(Standard Output): By default, the>
operator redirects the standard output (file descriptor1
) of a command to a file, overwriting its contents if the file already exists.Example:
This redirects the output of the
echo
command tooutput.txt
.Other File Descriptors:
STDIN
(Standard Input): Represents input to a command (file descriptor0
). Input redirection uses the<
operator.
Example:
This counts the number of lines in
input.txt
.STDERR
(Standard Error): Represents error messages (file descriptor2
). To redirectSTDERR
, use2>
.
Example:
This redirects error messages to
error.txt
.
Summary:
>
: RedirectsSTDOUT
.<
: RedirectsSTDIN
.2>
: RedirectsSTDERR
.
-
Which of the following commands will display the last five lines of a file called file1.txt?
(choose two)
head -n 5 file1.txt
tail -5 file1.txt
tail file1.txt
tail -n 5 file1.txt
-
Explanation & Hints: The correct answers are:
tail -5 file1.txt
tail -n 5 file1.txt
tail
: Displays the last lines of a file by default. The-n
or-5
option specifies the number of lines to display.-
tail -5 file1.txt
: Shows the last 5 lines offile1.txt
.tail -n 5 file1.txt
: Also shows the last 5 lines offile1.txt
. The-n
is an explicit option for specifying the number of lines.
Why the others are incorrect:
head -n 5 file1.txt
: Displays the first 5 lines of the file, not the last.tail file1.txt
: Displays the last 10 lines by default (not specifically the last 5).
Summary:
Use
tail -5 file1.txt
ortail -n 5 file1.txt
to display the last 5 lines offile1.txt
.
-
The ping command uses IP addresses to identify a computer on a network.
True or False?
- True
- False
-
Explanation & Hints: True
The
ping
command uses IP addresses to identify and communicate with a computer or device on a network. When you use theping
command, it sends Internet Control Message Protocol (ICMP) echo requests to the specified IP address or hostname.If you use a hostname (e.g.,
ping www.example.com
), the system first resolves the hostname to an IP address using DNS, and then uses that IP address to send the ICMP packets.Example:
- Using an IP address:
This directly sends ICMP packets to the device at
192.168.1.1
. - Using a hostname:
The hostname
google.com
is resolved to its corresponding IP address (e.g.,142.250.190.46
), and thenping
uses the IP address to send packets.
Thus, the
ping
command fundamentally relies on IP addresses to identify devices. - Using an IP address: