Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 1.69 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # List all users
  2. cat /etc/passwd | cut -d: -f1
  3. # List all non-system users
  4. awk -F: '{if ($3>=500 && $3<=1000) print $1}' /etc/passwd
  5.  
  6. # List all groups
  7. cat /etc/group | cut -d: -f1
  8.  
  9. # Add an existing user to a group - http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
  10. # usermod -a -G ftp tony
  11.  
  12.  
  13.  
  14. # Chmod usage - http://en.wikipedia.org/wiki/Chmod
  15. chmod [options] mode[,mode] file1 [file2 ...]
  16.  
  17. # Modes
  18. u       user    the owner of the file
  19. g       group   users who are members of the file's group
  20. o       others  users who are not the owner of the file or members of the group
  21. a       all     all three of the above, is the same as ugo
  22.  
  23. Operator        Description
  24. +       adds the specified modes to the specified classes
  25. -       removes the specified modes from the specified classes
  26. =       the modes specified are to be made the exact modes for the specified classes
  27.  
  28. Mode    Name    Description
  29. r       read    read a file or list a directory's contents
  30. w       write   write to a file or directory
  31. x       execute execute a file or recurse a directory tree
  32. X       special execute which is not a permission in itself but rather can be used instead of x. It applies execute permissions to directories regardless of their current permissions and applies execute permissions to a file which already has at least 1 execute permission bit already set (either user, group or other). It is only really useful when used with '+' and usually in combination with the -R option for giving group or other access to a big directory tree without setting execute permission on normal files (such as text files), which would normally happen if you just used "chmod -R a+rx .", whereas with 'X' you can do "chmod -R a+rX ." instead
  33. s       setuid/gid      details in Special modes section
  34. t       sticky  details in Special modes section