Hbwsl - Linux Basic Commands

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Gauravjoshi
G
Gauravjoshi
Community Contributor
Quizzes Created: 1 | Total Attempts: 632
| Attempts: 634
SettingsSettings
Please wait...
  • 1/65 Questions

    What command is used to copy a file?

Please wait...
About This Quiz

The 'HBWSL - Linux Basic Commands' quiz assesses knowledge of essential Linux command line tools. It covers commands for memory utilization, clearing terminal display, file permissions, ownership changes, file viewing, and locating system log files. Ideal for learners enhancing their Linux skills.

Hbwsl - Linux Basic Commands - Quiz

Quiz Preview

  • 2. 

    What command is used to change directories?

    Explanation
    The command "cd" is used to change directories in a command line interface. It allows the user to navigate through different directories or folders on the computer's file system. By typing "cd" followed by the desired directory name, the user can switch to that directory and access its contents. This command is commonly used in operating systems like Unix, Linux, and Windows Command Prompt.

    Rate this question:

  • 3. 

    What command is used to change the permissions of a file?

    Explanation
    The command "chmod" is used to change the permissions of a file. This command allows the user to modify the permissions for the owner, group, and others on the file. By using different options and parameters with the "chmod" command, the user can grant or revoke read, write, and execute permissions for the file. This command is commonly used in Unix-like operating systems to manage file permissions and ensure the security and accessibility of files.

    Rate this question:

  • 4. 

    ls -al

    • Create or update file

    • Change directory

    • Formatted listing with hidden files

    Correct Answer
    A. Formatted listing with hidden files
    Explanation
    The command "ls -al" is used to display a formatted listing of files and directories in the current directory. The "-a" option includes hidden files in the listing, while the "-l" option provides detailed information about each file or directory, such as permissions, owner, size, and modification date. Therefore, the correct answer is "formatted listing with hidden files".

    Rate this question:

  • 5. 

    What is the command to delete a file?

    Correct Answer
    rm
    rm -f
    Explanation
    The command "rm" is used to delete a file in a Unix/Linux system. It stands for "remove" and is a basic command for deleting files. The command "rm -f" is a more forceful version of the "rm" command, where the "-f" flag is used to forcefully remove the file without prompting for confirmation. Both commands can be used to delete files, but "rm -f" is more commonly used when you want to delete files without any confirmation prompts.

    Rate this question:

  • 6. 

    What command is used to change ownership of a file?

    Correct Answer
    chown
    Explanation
    The command "chown" is used to change the ownership of a file. This command allows the user to transfer the ownership of a file to another user or group. By using "chown", the user can modify the permissions and access rights of a file, granting ownership to a specific user or group. This command is commonly used in Unix-based operating systems to manage file ownership and control access to files.

    Rate this question:

  • 7. 

    How would you show a list of files and directories that are inside the current directory?

    • List

    • Ls

    • Dir

    • Listfiles

    • Listout

    Correct Answer
    A. Ls
    Explanation
    The correct answer for this question is "ls". In Unix-based systems, the "ls" command is used to list the files and directories that are inside the current directory. It provides a simple and concise way to view the contents of the current directory without displaying any additional information. This command is widely used by users to navigate and explore the file system.

    Rate this question:

  • 8. 

    head file

    • Show contents of files

    • Show top 10 lines

    • Show bottom 10 lines

    Correct Answer
    A. Show top 10 lines
    Explanation
    The correct answer is "show top 10 lines" because the command "head" is used to display the beginning or top portion of a file. By typing "head file", it will show the first 10 lines of the file "file".

    Rate this question:

  • 9. 

    mv file1 file2

    • Rename or move file 1 to file 2

    • Delete file 1 and file 2

    • Copy file 1 to file 2

    Correct Answer
    A. Rename or move file 1 to file 2
    Explanation
    The given command "mv file1 file2" is used to rename or move file1 to file2. It does not delete the files or copy file1 to file2.

    Rate this question:

  • 10. 

    ps

    • Display date and time

    • Show months calendar

    • Display currenty active processes

    Correct Answer
    A. Display currenty active processes
    Explanation
    The correct answer is "display current active processes" because out of the given options, it is the only one that pertains to showing the currently running processes on a system. The other options, such as displaying the date and time or showing a monthly calendar, are unrelated to displaying active processes.

    Rate this question:

  • 11. 

    __________ command used to create an empty file.

    • Mtfile

    • Touch

    • File

    • Intouch

    • Create

    Correct Answer
    A. Touch
    Explanation
    The touch command is used to create an empty file.

    Rate this question:

  • 12. 

    cp -r dir1 dir2

    • Copy file 1 to file 2

    • Delete files 1 and 2

    • Copy dir1 to dir 2, create dir 2 if it doesn't exist

    Correct Answer
    A. Copy dir1 to dir 2, create dir 2 if it doesn't exist
    Explanation
    The given command "cp -r dir1 dir2" is used to copy the directory "dir1" and all its contents to the directory "dir2". If "dir2" does not exist, it will be created. This command does not involve copying or deleting individual files, it specifically deals with copying directories.

    Rate this question:

  • 13. 

    What command clears the contents of your terminal display?

    Correct Answer
    clear
    reset
    Explanation
    The correct answer is "clear". This command is used to clear the contents of the terminal display, removing all previous commands and output from the screen. The "reset" command, on the other hand, resets the terminal to its default settings, but does not clear the display.

    Rate this question:

  • 14. 

    tail file

    • Show top 10 lines

    • Show bottom 10 lines

    • Show contents of files

    Correct Answer
    A. Show bottom 10 lines
    Explanation
    The correct answer is "show bottom 10 lines" because the command "tail file" is used to display the last few lines of a file. By default, it displays the last 10 lines of the file. Therefore, the command "tail file" is equivalent to "show bottom 10 lines".

    Rate this question:

  • 15. 

    pwd

    • Create or update file

    • Show current directory

    • Delete file

    • Change password

    Correct Answer
    A. Show current directory
    Explanation
    The command "pwd" is used to show the current directory in a command line interface. It displays the full path of the current working directory, allowing the user to see where they are located within the file system. This can be helpful for navigating and organizing files and directories.

    Rate this question:

  • 16. 

    You want to view a listing of previously entered commands. What command wouldyou use?

    • Hist

    • Histfile

    • Showbuff

    • History

    Correct Answer
    A. History
    Explanation
    history command lists all commands in history. All history commands
    stored in ~/.bash_history file.

    Rate this question:

  • 17. 

    What command allows you to view a file one page at a time?

    Correct Answer
    less
    more
    Explanation
    The correct answer is "less". The "less" command allows you to view a file one page at a time. It is a pager program that displays text files or the output of other commands on the terminal. It allows you to scroll through the file using the arrow keys or specific commands, making it easier to navigate through large files without overwhelming the screen with too much information at once. The "more" command is similar but has fewer features compared to "less".

    Rate this question:

  • 18. 

    What command creates an empty directory?

    • Mkdir

    • Touch

    • Dir

    • Createdir

    Correct Answer
    A. Mkdir
    Explanation
    The correct answer is "mkdir". The mkdir command is used to create a new directory or folder in a file system. By using this command, an empty directory can be created.

    Rate this question:

  • 19. 

    What is the command to switch to the root user account?

    Correct Answer
    su
    sudo su root
    sudo su
    Explanation
    The correct answer is "su". This command is used to switch to the root user account in Unix-like operating systems. "sudo su root" is also a valid command to switch to the root user account using the sudo command. "sudo su" alone can also be used to switch to the root user account, but it is not recommended as it can potentially cause security risks.

    Rate this question:

  • 20. 

    The symbol represents home directory is?

    • ~

    • .

    • ..

    • -

    Correct Answer
    A. ~
    Explanation
    The symbol "~" is commonly used to represent the home directory in various operating systems, including Unix and Unix-like systems. The home directory is the default directory for a user when they log in, and it typically contains their personal files and settings. Using "~" as a shortcut allows users to quickly navigate to their home directory without having to specify the full path.

    Rate this question:

  • 21. 

    What is the command to run a program with elevated permissions?

    Correct Answer
    sudo
    Explanation
    The command "sudo" is used to run a program with elevated permissions. It allows a user to execute a command as a superuser or another user, granting them temporary administrative privileges. This is commonly used in Unix-based operating systems to perform tasks that require higher privileges, such as installing software or making system changes.

    Rate this question:

  • 22. 

    Which command to use for complete details of a command on the shell?

    • Help

    • ?

    • Man

    • Hlp

    • Info

    Correct Answer
    A. Man
    Explanation
    The correct answer is "man". The "man" command is used to display the manual page for a given command on the shell. It provides detailed information about the command, including its syntax, options, and examples. By using the "man" command, users can access comprehensive documentation and get a complete understanding of how a specific command works.

    Rate this question:

  • 23. 

    How do you see hidden files in your home directory?

    • Ls -h

    • Ls -la

    • Ls -hn

    • Ls -R

    Correct Answer
    A. Ls -la
    Explanation
    The correct answer is "ls -la". This command lists all files and directories, including hidden ones, in a detailed format. The "-l" option displays the files in a long format, showing permissions, owner, size, and other details. The "-a" option shows all files, including hidden ones that start with a dot. Therefore, using "ls -la" allows you to see hidden files in your home directory.

    Rate this question:

  • 24. 

    What two commands display the status of processes on a Linux system?

    • Ls and df

    • Ps and top

    • Ps and df

    • Df and top

    • Du and df

    Correct Answer
    A. Ps and top
    Explanation
    b. Both ps and top yield process status. None of the other listed commands are related to processes.

    Rate this question:

  • 25. 

    Which command is used to view the complete file without modifying it ?

    • View

    • Cat

    • More

    • Head

    • Tail

    Correct Answer
    A. Cat
    Explanation
    The cat command is used to view the complete file without modifying it. It displays the contents of a file on the terminal.

    Rate this question:

  • 26. 

    What command is used to search files for a pattern?

    • Find

    • Ls

    • Grep

    • Help

    Correct Answer
    A. Grep
    Explanation
    The command "grep" is used to search files for a pattern. It is a powerful tool that allows users to search for specific text or patterns within files. By using various options and regular expressions, grep can efficiently search through multiple files and directories to find the desired pattern. It is commonly used in command-line environments for tasks such as log analysis, text processing, and data extraction.

    Rate this question:

  • 27. 

    What is the command to search all files in your current directory for the word plasmodium?

    • Grep plasmodium *

    • Find plasmodium -all

    • Lookup plasmodium *

    Correct Answer
    A. Grep plasmodium *
    Explanation
    The correct answer is "grep plasmodium *". The grep command is used to search for patterns in files. In this case, it is searching for the word "plasmodium" in all files in the current directory. The asterisk (*) is a wildcard that represents all files in the directory. Therefore, this command will search all files in the current directory for the word "plasmodium".

    Rate this question:

  • 28. 

    Chmod 644 finance.doc644 equals to

    • Rwx r-x r-x

    • Rw- r-x r-x

    • R-- r-- ---

    • Rw- r-- r--

    • Rw- rw- rw-

    Correct Answer
    A. Rw- r-- r--
    Explanation
    The given answer, "rw- r-- r--", represents the permission settings for the file "finance.doc" when using the chmod command with the argument "644". In this case, "rw-" indicates that the owner of the file has read and write permissions, while "r--" indicates that the group and other users only have read permissions. This means that the owner can read and modify the file, while the group and other users can only read the file.

    Rate this question:

  • 29. 

    How do you copy an entire directory structure? E.g. from Project to Project.backup

    • Cp Project Project.backup

    • Mv -r Project Project.backup

    • Cp -r Project Project.backup

    • Mv Project Project.backup

    Correct Answer
    A. Cp -r Project Project.backup
    Explanation
    To copy an entire directory structure from "Project" to "Project.backup", the correct command is "cp -r Project Project.backup". The "-r" flag is used to recursively copy all files and directories within the "Project" directory to the "Project.backup" directory. This ensures that the entire directory structure is copied over. The other options, "cp Project Project.backup" and "mv Project Project.backup", do not include the "-r" flag and would only copy or move the top-level directory, without its contents. The option "mv -r Project Project.backup" is incorrect as the "-r" flag is not valid for the "mv" command.

    Rate this question:

  • 30. 

    You're now in directory X3 (see below). Moving to directory X1 using command:X1  |__     X2      |__          X3 <--- You're here

    • Cd .

    • Cd ..

    • Cd ../..

    • Cd ../../..

    Correct Answer
    A. Cd ../..
    Explanation
    The command "cd ../.." is used to move up two levels in the directory structure. The ".." represents the parent directory, so using it twice moves up two levels. In this case, it will take you from directory X3 to the root directory.

    Rate this question:

  • 31. 

    If you want to restrict users from directory content listing, you have to

    • Change the file write permission

    • Change the file read permission

    • Change the directory write permission

    • Change the directory read permission

    Correct Answer
    A. Change the directory read permission
    Explanation
    To restrict users from directory content listing, you need to change the directory read permission. By changing the directory read permission, you can prevent users from viewing the contents of the directory, including any files or subdirectories within it. This ensures that the directory's content remains private and inaccessible to unauthorized users.

    Rate this question:

  • 32. 

    You want to change the permissions on the file named “fifteen” so that owner has all permissions while all other users don't have any permissions. Which command should you use?

    • Chmod fifteen 700

    • Chmod 100 fifteen

    • Chmod 700 fifteen

    • Chmod fifteen 100

    • Chmod 770 fifteen

    Correct Answer
    A. Chmod 700 fifteen
    Explanation
    The correct answer is "chmod 700 fifteen". This command will change the permissions of the file named "fifteen" so that the owner has all permissions (read, write, and execute), while all other users (group and others) don't have any permissions. The number "700" represents the permission settings, where the first digit (7) represents the owner's permissions, the second digit (0) represents the group's permissions, and the third digit (0) represents the permissions for others.

    Rate this question:

  • 33. 

    What is the default directory path for system log files?

    Correct Answer
    /var/log
    /var/log/
    Explanation
    The default directory path for system log files is typically "/var/log" or "/var/log/". This is where various log files are stored on a Unix-like operating system. The logs contain important information about system events, errors, and activities, which can be useful for troubleshooting and monitoring the system's performance. The "/var/log" directory is commonly used by many Linux distributions and Unix-based systems to organize and store log files.

    Rate this question:

  • 34. 

    In order to append the output of ls to a file called bazz, which of the following command lines would you use?

    • Ls > bazz

    • Ls >& bazz

    • Ls &> bazz

    • Ls >> bazz

    Correct Answer
    A. Ls >> bazz
    Explanation
    The correct answer is "ls >> bazz". This command line appends the output of the "ls" command to a file called "bazz". The ">>" symbol is used for appending output to a file, while ">" symbol is used for overwriting the file with the new output. The other options are incorrect because they either redirect the output to a file without appending it (">" and ">&") or use the incorrect syntax ("&>").

    Rate this question:

  • 35. 

    One single command to completely remove directory X1 and all it's contents (see below)X1 |__     X2      |__          X3

    • Rm X1

    • Rmdir X1

    • Rm -f X1

    • Rm -rf X1

    Correct Answer
    A. Rm -rf X1
    Explanation
    The correct answer is "rm -rf X1" because the "rm" command is used to remove files and directories, and the "-rf" options are used to forcefully remove directories and their contents recursively. This means that the command will remove directory X1 and all its contents, including directory X2 and file X3.

    Rate this question:

  • 36. 

    What command shows you memory utilization?

    Correct Answer
    free
    top
    Explanation
    The command "free" shows the memory utilization by displaying the total amount of free and used memory in the system. On the other hand, the command "top" provides a dynamic real-time view of the system, including information about memory usage, CPU usage, and other system statistics. Both commands can be used to monitor memory utilization, but "free" specifically focuses on memory while "top" provides a broader overview of system performance.

    Rate this question:

  • 37. 

    Which command will display the last lines of the text file file1?

    • Head -b file1

    • Head --bottom file1

    • Head -v file1

    • Tail file1

    • Tail -n 1 file1

    Correct Answer
    A. Tail file1
    Explanation
    d. The tail command is used for checking the last lines of a text file. By default, it displays 10 lines.

    Rate this question:

  • 38. 

    The symbol represents current directory is?

    • ~

    • .

    • ..

    • -

    Correct Answer
    A. .
    Explanation
    The symbol "." represents the current directory in a file system. It is commonly used in command line interfaces to refer to the current working directory. This symbol allows users to navigate and access files and directories within the current directory without having to specify the full path.

    Rate this question:

  • 39. 

    Which command will list the contents of a directory, listed by file modification time, in reverse order (last modified file shows up at the bottom of a listing)?

    • Ls

    • Ls -al

    • Ll

    • Ls -lart

    Correct Answer
    A. Ls -lart
    Explanation
    The command "ls -lart" will list the contents of a directory, listed by file modification time, in reverse order. The "-l" option displays the files in a long format, including the modification time. The "-a" option includes hidden files in the listing. The "-r" option reverses the order of the listing, so that the last modified file shows up at the bottom. Finally, the "-t" option sorts the files by modification time.

    Rate this question:

  • 40. 

    How would you remove a directory that is not empty?

    • Rm -r

    • Rm -f

    • Rmdir -f

    • Rmdir -le

    Correct Answer
    A. Rm -r
    Explanation
    The correct answer is "rm -r". The "rm" command is used to remove files and directories in Unix-like operating systems. The "-r" option stands for "recursive", which means it will remove the specified directory and its contents, including any subdirectories and files within it. By using "rm -r", you can remove a directory that is not empty.

    Rate this question:

  • 41. 

    What is the command to view data in real time as it is being added to a file?

    • Tail -f

    • Less

    • Refresh

    • Head -r

    Correct Answer
    A. Tail -f
    Explanation
    The correct answer is "tail -f". The "tail" command is used to display the last part of a file, and the "-f" option allows the command to continuously display the file as it is being updated in real time. This is useful for monitoring log files or any other files that are constantly being appended with new data.

    Rate this question:

  • 42. 

    If you want to protect files from content modifications, you have to

    • Change the file write permission

    • Change the file read permission

    • Change the file's directory write permission

    • Change the file's directory read permission

    Correct Answer
    A. Change the file write permission
    Explanation
    To protect files from content modifications, you need to change the file write permission. By changing the write permission, you can restrict users from making any changes to the file, ensuring its integrity and preventing unauthorized modifications. This allows you to maintain the original content and prevent any accidental or intentional alterations to the file. Changing the file read permission or the directory permissions would not directly address the issue of content modifications.

    Rate this question:

  • 43. 

    You're now in directory X1 (see below). Moving to directory X3 using command:X1 <--- You're here |__     X2      |__          X3

    • Cd X3/

    • Cd /X3

    • Cd /X2/X3

    • Cd X2/X3/

    Correct Answer
    A. Cd X2/X3/
    Explanation
    The correct answer is "cd X2/X3/" because it correctly navigates to directory X3, which is located inside directory X2. The command "cd X2/X3/" specifies the path to directory X3 relative to the current directory X1.

    Rate this question:

  • 44. 

    Which one of the following statements correctly describes the > and >> symbols in the context of the bash shell?

    • > appends standard output to an existing file, and >> writes standard output to a new file.

    • > writes standard output to a new file, and >> appends standard output to an existing file.

    • > writes standard error to a new file, and >> appends standard error to an existing file.

    • > pipes standard output to a new file, and >> pipes standard output to an existing file.

    • > pipes standard output to an existing file and >> pipes standard error to a new file.

    Correct Answer
    A. > writes standard output to a new file, and >> appends standard output to an existing file.
    Explanation
    b. The > character opens and writes to a new file, while >> appends to an existing file, unless that file doesn't exist, in which case it is opened first.

    Rate this question:

  • 45. 

    You want to search the file myfile for all occurrences of a string containing at leastfive characters, where character number 2 and 5 are "a" and character number 3 isNOT "b". Which command would you use?

    • Grep a*^b*a myfile

    • Grep .a[^b].a myfile

    • Grep .[a].*.[a] myfile

    • Grep .a*^b..a myfile

    Correct Answer
    A. Grep .a[^b].a myfile
    Explanation
    String Processing Tools like grep, sed, awk uses wildcard characters.
    . à Any Single character from the range
    [abc] à Any Single Character from the set
    [a-c] à Any Single Character from the Range
    [^abc] à Any Single Character except from the set.
    [^a-c] àAny Single Character except from the range.
    According to QUESTION, in 2nd and 5th position must be a and in 3rd position not b.
    B. . means any single character in first postion., a means a must be in second postions,
    [^b] means b must not be in third postion, . means any single character in fourth position
    and a in fifth position.

    Rate this question:

  • 46. 

    How would you avoid accidentally removing files?

    • Rm -i

    • Rm -chk

    • Rm -a

    • Rm -r

    Correct Answer
    A. Rm -i
    Explanation
    The option "rm -i" is the correct answer because it prompts the user for confirmation before deleting each file. This allows the user to double-check and avoid accidentally removing files. The other options, "rm -chk," "rm -a," and "rm -r," do not provide any confirmation and can lead to unintentional file removal.

    Rate this question:

  • 47. 

    How do you find files in your current directory modified more than 48 hours ago?

    • Find . -mtime 2

    • Grep -R -mtime 2 .

    • Find -mtime 2 *

    • Grep * -R -mtime 2

    Correct Answer
    A. Find . -mtime 2
    Explanation
    The correct answer is "find . -mtime 2". This command uses the "find" utility to search for files in the current directory (and its subdirectories) that were modified exactly 2 days ago. The dot (.) represents the current directory, and the option "-mtime" specifies the time period for the search. The number 2 indicates that the files modified within the last 48 hours will be returned.

    Rate this question:

  • 48. 

    The command to restrict user not to delete finance.doc within directory /home/budi

    • Chmod +w finance.doc

    • Chmod -w finance.doc

    • Chmod +w /home/budi

    • Chmod -w /home/budi

    Correct Answer
    A. Chmod -w /home/budi
    Explanation
    The correct answer is "chmod -w /home/budi". This command removes the write permission for the directory "/home/budi", which means that users will not be able to delete the file "finance.doc" within that directory. The other options either only modify the permissions of the file "finance.doc" or change the permissions of the entire directory without specifically targeting the file.

    Rate this question:

  • 49. 

    Which one of the following commands is equivalent to the following command for user jdoe whose home directory is /home/jdoe?# chmod 754 ~/file1

    • Chmod u=rwx,g=rx,o=r /home/jdoe/file1

    • Chmod ugo=rwx ~/file1

    • Chmod u=7,g=5,o=4 ~/file1

    • Chmod 754 \home\jdoe\file1

    • Chmod 754 /usr/jdoe/file1

    Correct Answer
    A. Chmod u=rwx,g=rx,o=r /home/jdoe/file1
    Explanation
    a. User mode 7 is the same as u=rwx, group mode 5 is the same as g=rx, and other mode 4 is the same as o=r. The ~/ syntax implies the user's home directory.

    Rate this question:

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 03, 2013
    Quiz Created by
    Gauravjoshi
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.