Is it possible to change owner/group of a file AND permissions with 1 command?
I tried:
chmod user1:groupOfUser1=770 file.txt
but it does not work.
2 Answers
Create a script
Similar to this you can modify as per your need
cat chmodown
#!/bin/bash
chmod $2 $1 $5
chown $3:$4 $1 $5
$1 is file name $2 is permission $3 user name $4 Group name $5 (-R) for recursive.
You can then place the same script to "/usr/bin/" too.
chmodown install.log 777 test root
ls -al install.log
-rwxrwxrwx 1 test root 18262 Jul 27 01:52 install.log
I don't think that's really possible.
I expect that what you are looking for is to input file name just once. You can do something like this
# for a in file.txt; do chown user1:groupOfUser1 $a; chmod 770 $a; done
Over here you need to input the file name just once :)
At the same time, you can use shell script like this:
#!/bin/bash
chown $1:$2 $4
chmod $3 $4
Make this executable and put it in your PATH variable and use it something like this.
# ./x.sh user group permission file_name
chmod
andchown
commands?