How to fix "chown: invalid group:" if the user does not exist on the running system?

145

Use the numerical UID/GID instead of the user/group name.

You can find the UID/GID on the system the disk belongs to by using

  id some_username

or

ls -ln some_file

where some_file is a file that belongs to user you are looking for

Share:
145

Related videos on Youtube

ssd
Author by

ssd

Updated on September 18, 2022

Comments

  • ssd
    ssd almost 2 years

    Following code is supposed to return the upper case string of the source. It works but does not convert the string. Could not figure out what was wrong.

    char *StrUpper (char *s) {
        int i = 0;
        char *t = &s [i];
        while (*t) {
            if ((*t > 0x5a) && (*t < 0x7b)) t = (t - 32);
            t = &s [i++];
        }
        return (s);
    }
    
    int main () {
        printf ("%s\n", StrUpper ("lower case string"));
        return (0);
    }
    
    • davmac
      davmac almost 10 years
      'it works but does not convert the string' - surely this means it doesn't work?
    • Rahul Tripathi
      Rahul Tripathi almost 10 years
      Also to add that the reason why you say that it works is because you are getting an undefined behavior.
    • Unn
      Unn almost 10 years
      It might be good to mention that you're looking at the 0th element twice: t = &s [i++] might want to be replaced with t = &s [++i]
    • José Manuel Blasco
      José Manuel Blasco over 2 years
      In my case, I was using chown with $USER:(id -n $USER) that fills the group. But the group had whitespaces so I had to surround the group part. $USER:"(id -n $USER)" worked for me
  • ssd
    ssd almost 10 years
    I've already tried that (*t = *t - 32) thing; in that case however, codeblock crashes like: Problem signature: Problem Event Name: APPCRASH ... Exception Code: c0000005
  • ssd
    ssd almost 10 years
    Just tried your code above, codeblocks crashes like: Problem Event Name: APPCRASH Exception Code: c0000005
  • Vlad from Moscow
    Vlad from Moscow almost 10 years
    @merkez3110 The problem is not with the function I showed. The problem with how you call it. For example you may not use string literals as arguments of the function.
  • ssd
    ssd almost 10 years
    I've already tried the code below, no change: ` int main () { char *s = "lower case string"; printf ("%s\n", StrUpper (s)); return (0); }`
  • Some programmer dude
    Some programmer dude almost 10 years
    @merkez3110 That's because s still points to the constant string literal. Instead do char s[] = "...";
  • Vlad from Moscow
    Vlad from Moscow almost 10 years
    @@merkez3110 See my updated post where there is an example of using the function.
  • ssd
    ssd almost 10 years
    OK! StrUpper ("blah blah"); and char *s = "blah blah"; StrUpper (s); does not work; but char s [] = "blah blah"; StrUpper (s); works. Thanks for everyone. As @JoachimPileborg noted, I was trying to crunch a string literal which is a const by def.
  • This isn't my real name
    This isn't my real name almost 10 years
    Oddly enough, string literals are not const by definition, they are non-modifiable by definition. String literals are exceptional: they don't become arrays of const char type, they become arrays of char type that you are nevertheless forbidden to modify.