CS131 - Week 3 (Hard)
19 Questions
3 Views

CS131 - Week 3 (Hard)

Created by
@RefinedBowenite

Questions and Answers

Which command is used to change the owner of a file or directory?

  • chown (correct)
  • chgrp
  • chroot
  • chmod
  • Which command is used to change the group that owns a file or directory?

  • chgrp (correct)
  • chown
  • chroot
  • chmod
  • Which command is used to create a new user account?

  • passwd
  • usermod
  • userdel
  • useradd (correct)
  • Why does Linux use groups?

    <p>All of the above</p> Signup and view all the answers

    Which file contains the user account information for your system?

    <p>/etc/passwd</p> Signup and view all the answers

    What does the 'alias' command do in the previous example?

    <p>Replaces a simpler word for the command given</p> Signup and view all the answers

    What is the purpose of the 'sudo' command?

    <p>Allows you to issue a single command as root user or another user</p> Signup and view all the answers

    Can a user 'ronaldo' run a command as 'messi' using the 'sudo' command?

    <p>False</p> Signup and view all the answers

    Which of the following is true about variables in Shell Scripts?

    <p>Variables in Shell Scripts are not typed.</p> Signup and view all the answers

    Which of the following is true about global variables in Shell Scripts?

    <p>Global variables pollute the global namespace.</p> Signup and view all the answers

    What is the difference between 'echo pwd' and 'echo "pwd"'?

    <p>'echo <code>pwd</code>' prints the current working directory, while 'echo &quot;pwd&quot;' prints the string 'pwd'.</p> Signup and view all the answers

    What does the 'export' command do in Shell Scripts?

    <p>The 'export' command sets variables.</p> Signup and view all the answers

    Which graphical editor is the default text editor for Gnome?

    <p>gedit</p> Signup and view all the answers

    What is the purpose of the command 'egrep "^(0|1)+ [a-zA-Z]+$" searchfile.txt'?

    <p>Searches for lines in searchfile.txt that start with one or more 0s or 1s followed by alphabetic characters</p> Signup and view all the answers

    What is the difference between 'echo "me"', 'pwd', 'echo pwd', and 'echo $HOME'?

    <p>'echo &quot;me&quot;' prints out the word 'me', 'pwd' prints the current working directory, 'echo <code>pwd</code>' prints the result of the 'pwd' command, and 'echo $HOME' prints the value of the HOME environment variable</p> Signup and view all the answers

    Which command is used to create a new group and specify a GID for the group?

    <p>groupadd -g GID groupname</p> Signup and view all the answers

    Which command is used to delete a group?

    <p>groupdel group_name</p> Signup and view all the answers

    Which command is used to add a user to a particular group on Debian or Ubuntu?

    <p>usermod -a -G sudo exampleusername</p> Signup and view all the answers

    Which command is used to add a user to a particular group on CentOS or RedHat?

    <p>usermod -a -G wheel exampleusername</p> Signup and view all the answers

    Study Notes

    File and Directory Management

    • The chown command is used to change the owner of a file or directory.
    • The chgrp command is used to change the group that owns a file or directory.

    User Account Management

    • The useradd command is used to create a new user account.
    • Linux uses groups to categorize users and manage access to system resources.
    • The /etc/passwd file contains user account information for the system.

    Command Functions

    • The alias command creates a shortcut or alternative name for a command or sequence of commands.
    • The sudo command allows authorized users to run commands with superuser privileges.

    Variable Usage in Shell Scripts

    • In Shell Scripts, variables are local by default and can be made global using the export command.
    • Global variables in Shell Scripts can be accessed and modified from any part of the script.

    Command Differences

    • echo pwd`` outputs the current working directory, while echo "pwd" outputs the string "pwd".
    • echo "me" outputs the string "me", pwd outputs the current working directory, echo pwd`` outputs the current working directory, and echo $HOME outputs the user's home directory.

    Graphical Editor

    • The default text editor for Gnome is gedit.

    Regular Expressions

    • The command egrep "^(0|1)+ [a-zA-Z]+$" searchfile.txt searches the file searchfile.txt for lines containing one or more occurrences of either "0" or "1" followed by a space and one or more alphabetical characters.

    Group Management

    • The groupadd command is used to create a new group and specify a GID (Group ID) for the group.
    • The groupdel command is used to delete a group.
    • On Debian or Ubuntu, the adduser command is used to add a user to a particular group.
    • On CentOS or RedHat, the usermod command is used to add a user to a particular group.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge of bash_profile and bashrc files with this quiz. Learn when and how these files are read, how to edit them, and how to set up aliases. Perfect for beginners looking to improve their command line skills.

    More Quizzes Like This

    Linux File Management Quiz
    9 questions
    Linux File Management in Bash Shell
    12 questions
    Linux File System and Commands
    10 questions
    Use Quizgecko on...
    Browser
    Browser