Top 50 Common Linux Commands (Essential for Operations) Part 2

This article compiles the top 50 questions frequently encountered in Linux system operation and maintenance interviews. Whether you are a beginner entering the IT industry or an experienced operations personnel aiming for promotion, these questions will provide you with comprehensive knowledge review and practical simulation, helping you stand out in interviews, successfully secure your desired offer, and advance to new heights in your career, furthering your journey in Linux operations. (Part 2)

1. Multiple Choice Questions

1. Environment Variables and Output

  • Output Environment Variable
    • <span>echo $PATH</span>: Used to output the value of the environment variable <span>PATH</span>.

2. System Information

  • Display Current Time
    • <span>date</span>: Used to display the current system time.
  • Display Current Path
    • <span>pwd</span>: Used to display the path of the current working directory.

3. File and Directory Operations

  • Home Directory Symbol
    • <span>~</span>: Represents the current user’s home directory.
  • Redirect Output (Append)
    • <span>>></span>: Used to redirect output and append to the end of a file.
  • Delete Files or Directories
    • <span>rm</span>: Used to delete files or directories (to delete non-empty directories, add the <span>-r</span> or <span>-R</span> option).
  • Directory Deletion Command
    • <span>rm</span> and <span>rmdir</span>: <span>rm -r</span> can delete non-empty directories, while <span>rmdir</span> can only delete empty directories.

4. File Permissions

  • Modify File or Directory Permissions
    • <span>chmod</span>: Used to modify the permissions of files or directories.
  • Change File Group Ownership
    • <span>chgrp</span>: Used to change the user group ownership of a file.
  • File Permission Types
    • Read (r), Write (w), Execute (x).

5. File Viewing

  • View the Last Few Lines of a File
    • <span>tail</span>: Used to view the last few lines of a file.
  • View Detailed Information of a File
    • <span>ls</span>: Lists files and directories; combined with options like <span>-l</span> can display detailed information.

6. User Management

  • Delete User
    • <span>userdel</span>: Used to delete a user.
  • View Current Logged-in User
    • <span>whoami</span>: Used to view the currently logged-in username.
  • User Management Related Commands
    • <span>userdel</span> and <span>groupdel</span>: Used to delete users and groups.
  • Create New User and Set Password
    • Use the <span>useradd</span> command to create a new user, for example:<span>useradd username</span>.
    • Use the <span>passwd</span> command to set a password, for example:<span>passwd username</span>.

7. Shell Scripts

  • Get Number of Script Parameters
    • <span>$#</span>: Used to get the number of parameters in a Shell script.
  • Receive User Input
    • <span>read</span>: Used in Shell scripts to receive user input.
  • Common Loop Structures
    • <span>for</span>: One of the commonly used loop structures.

8. Others

  • Create Hard Link
    • <span>ln</span>: Used to create a hard link.
  • Numeric Comparison Operators
    • <span>-ge</span>: Represents the “greater than or equal to” comparison for numbers.

2. True or False Questions

  1. Command Combination Execution

  • <span>&&</span>: Used to indicate that the next command is executed only if the previous command is successful.
  • Permission Settings

    • <span>chmod 700 file</span>: Indicates that other users have no permissions.
  • Display Hidden Files

    • <span>ls -a</span>: Can display hidden files.
  • <span>mv</span> command can be used to copy directories?

    • <span>mv</span> command is used to move directories×
  • <span>cp</span> command function is to rename files?

    • <span>cp</span> command is used to copy files.×
  • Permission Settings

    • <span>chmod 755 file</span>: Indicates that other users have read and write permissions.×
  • File Search find command can be used to search file contents?

    • <span>find</span> command is used to search for files in the file system, not directly used to search file contents (<span>grep</span> is used to search file contents).×
  • User Switching

    • <span>su</span> command can be used to switch users.
  • Shell Script Comments

    • <span>#</span> symbol is used for comments.
  • rmdir can delete non-empty directories?

    • <span>rmdir</span> command cannot delete non-empty directories, must use <span>rm -r</span>.×

    3. Fill-in-the-Blanks

    • Under superuser privileges, to display all currently running processes in the system, the command to use is ps -ef.

    • Using the standard output of the previous command as the standard input of the next command is called pipe, represented by the symbol “<span>|</span>”.

    • In Linux, the file for configuring the DNS server is /etc/resolv.conf.

    • In Linux, the command used to view the current network interface information is ifconfig or ip addr.

    4. Short Answer Questions

    1. Briefly describe several common commands for managing users and groups in Linux

    • User Management:
      • <span>useradd</span>: Add user.
      • <span>userdel</span>: Delete user.
      • <span>passwd</span>: Set password.
    • Group Management:
      • <span>groupadd</span>: Add group.
      • <span>groupdel</span>: Delete group.
      • <span>usermod</span>: Modify user group.

    2. How to create a new user and set a password in Linux?

    • Use the <span>useradd</span> command to create a new user, for example:<span>useradd username</span>.
    • Use the <span>passwd</span> command to set a password, for example:<span>passwd username</span>.

    3. How to restart network services via command line?

    • <span>systemctl restart network</span> or
    • <span>service network restart</span>

    4. Explain the meaning of <span>chown user:group file</span> command

    • <span>chown</span> command is used to change the owner and group of a file.
    • <span>user:group</span> indicates setting the owner of the file to <span>user</span> and the group to <span>group</span>.
    • <span>file</span> is the name of the file whose permissions need to be changed.

    5. Briefly describe numeric comparison operators in Linux

    • <span>-eq</span>: Equal to
    • <span>-ne</span>: Not equal to
    • <span>-gt</span>: Greater than
    • <span>-lt</span>: Less than
    • <span>-ge</span>: Greater than or equal to
    • <span>-le</span>: Less than or equal to

    I hope everyone can take this article as a starting point, continuously learn and practice, and apply these commands and techniques in daily work. Remember, the road of technology is endless; only through continuous exploration and learning can you go further in your career. Wishing your endeavors to flourish. If you find this useful:

    Top 50 Common Linux Commands (Essential for Operations) Part 2

    Leave a Comment