CS131 - Week 3 (Hard)

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

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 (D)</p> Signup and view all the answers

Which file contains the user account information for your system?

<p>/etc/passwd (B)</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 (B)</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 (C)</p> Signup and view all the answers

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

<p>False (A)</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. (A)</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. (D)</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'. (B)</p> Signup and view all the answers

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

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

Which graphical editor is the default text editor for Gnome?

<p>gedit (C)</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 (C)</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 (A)</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 (D)</p> Signup and view all the answers

Which command is used to delete a group?

<p>groupdel group_name (C)</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 (A)</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 (B)</p> Signup and view all the answers

Flashcards are hidden until you start studying

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

Related Documents

combinepdf.pdf

More Like This

Use Quizgecko on...
Browser
Browser