Linux Commands: umask, su, sudo, chown
16 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which permission group applies only to the owner of a file or directory?

  • Owner (correct)
  • Group
  • Read
  • All Users
  • What permission type allows a user to modify a file or directory?

  • id
  • Read
  • Write (correct)
  • Execute
  • Which command allows you to change a file's group ownership?

  • chgrp (correct)
  • chown
  • su
  • chmod
  • What does the 'id' command display?

    <p>User identity</p> Signup and view all the answers

    Which file type refers to a device handling data in blocks, like a hard-drive?

    <p>Block special file</p> Signup and view all the answers

    What does the 'umask' command set?

    <p>Default file permissions</p> Signup and view all the answers

    What is the binary equivalent of the file mode 'rw- rw- r--'?

    <p>000 110 100</p> Signup and view all the answers

    When using the 'chown' command with the argument 'nika:users', what ownership changes occur?

    <p>Change to user 'nika' and group 'users'</p> Signup and view all the answers

    Which command is used to change the group ownership of a file in Linux?

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

    In octal notation, what is the permission mode for a file with 'rw- r-- r--' permissions?

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

    Which permission type allows a user to read and execute a file but not modify it?

    <p>'r-x'</p> Signup and view all the answers

    What is the binary equivalent of the file mode 'rw- r-- r--'?

    <p>000 110 010</p> Signup and view all the answers

    Which file type handles data in blocks, like a hard drive?

    <p>'b'</p> Signup and view all the answers

    What does the 'su' command allow you to do in Linux?

    <p>Switch to another user's identity</p> Signup and view all the answers

    What does the 'passwd' command enable users to change in Linux?

    <p>'password'</p> Signup and view all the answers

    What is the binary equivalent of the file mode '*Property of STI: rw- rw- rw-'?

    <p>000 000 011</p> Signup and view all the answers

    Study Notes

    umask Command

    • The umask command sets default permissions for newly created files and directories.
    • A common binary umask is 0002, which results in file permissions of rw-rw-r--.

    Permissions and Modes

    • Original file modes can be expressed in octal notation:
      • 777: Full permissions for everyone (not recommended).
      • 755: Owner can read, write, execute; others can read and execute.
      • 700: Owner has all permissions; others have none (private use).
      • 666: All users can read/write.
      • 644: Owner can read/write; others can only read.
      • 600: Owner can read/write; others have no permissions.

    chown Command

    • The chown command changes file ownership.
    • Sample usage:
      • nika: Changes ownership to user "nika".
      • nika:users: Changes ownership to user “nika” and group “users”.
      • :admins: Changes group ownership to “admins”.

    File Permission Values

    • Octal to binary notations:
      • 0 - 000 (no permissions)
      • 1 - 001 (execute)
      • 2 - 010 (write)
      • 3 - 011 (write + execute)
      • 4 - 100 (read)
      • 5 - 101 (read + execute)
      • 6 - 110 (read + write)
      • 7 - 111 (read + write + execute)

    Directory Permission Values

    • Directory permissions are critical for managing access:
      • 777: Full permissions (not recommended).
      • 755: Owner has full access; others can list.
      • 700: Directory is private to the owner.

    Symbolic Notation for Permissions

    • Represents permissions using combinations of symbols:
      • u: User (owner)
      • g: Group owner
      • o: Others
      • a: All (user, group, others)
    • Symbolic commands examples:
      • u+x: Grants execute permission to the owner.
      • u-x: Revokes execute permission from the owner.
      • go=rw: Sets group and others to read/write permissions, removes execute.
      • u+x, go=rx: Grants execute to owner; group and others get read/execute permissions.

    Overall Best Practices

    • Avoid using 777 permissions to maintain security.
    • Use umask carefully to default to safer permissions.
    • Regularly review file and directory permissions to ensure they meet security needs.

    Studying That Suits You

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

    Quiz Team

    Description

    Test your knowledge on Linux commands such as umask, su, sudo, and chown. Understand how to set permissions and change ownership of files in a Linux environment.

    More Like This

    Use Quizgecko on...
    Browser
    Browser