Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It's just 2 different ways of saying the same thing. Presumably the posters think you know basic UNIX/Linux commands such as chown and are only telling you that you need to chown.
You can type "man chown" to learn about this command.
In both usages you list they are showing standard information:
chown = The command to change owner (and/or group) of a file or directory.
user = The user you want to be the owner of the file or directory.
:group = The group you want put on the file or directory. The colon here is to show the user is on left and group on right.
file = The file on which you are changing the owner and/or group
In Linux a directory is a special type of "file". If you run "-R" with chown it says to do it recursively (i.e. not just the directory but all the other files in the directory including any subdirectories and files.
The first usage is suggesting $USER for both "user" and "group". This implies you've set a variable called USER before that usage. It also assumes you have both a "user" and a "group" with the same name (or number [uid for user and gid for group]). They specify "/path/to/dir" to tell you that you need to figure out the full path of the directory (e.g. /var/www/billybob).
In the second usage you're being told exactly the same thing. It is suggesting "username" for user and "group" for group and "directory" for directory.
If you need help it is OK to ask for it but you don't have to imply others that have previously posted help somehow did YOU wrong because YOU don't understand.
Last edited by MensaWater; 07-06-2017 at 09:52 AM.
using it this way, what syntax to change from root ownership to user a folder and all subfolders and files?
'sudo chown -R username:group directory', likely does not work that way.
I had to cut and paste from an old user account many files and pictures into my user account, and could only do it graphically by using 'sudo nemo', which then left all the copies owned by root.
then this worked great here, as mentioned in another response on that page 'sudo chown -R $USER:$USER /path/to/dir'
The other answers did not seem to fit the question.
Last edited by sdowney717; 07-06-2017 at 11:57 AM.
using it this way, what syntax to change from root ownership to user a folder and all subfolders and files?
'sudo chown -R username:group directory', likely does not work that way.
You already have the syntax. See above command. Yes it does work that way. It's possible that I'm not understanding what you're trying to say, though..
as an example:
Lets say the root user copied the Monthly_Reports directory into user benjamin's Documents directory and was still owned by root. To change it so that its owned by benjamin and the Users group do the following
The -R switch means recursive, meaning it will make the Monthly_Reports directory, and anything under it, belong to user benjamin and belong to group Users. In my example there is a hash tag before the command meaning I am operating as root, but I'm sure this can be done with sudo as well. Pretty basic. See man pages for more info.
erik@mycomputer:~$ id
uid=2007(erik) gid=502(Users) groups=502(Users),25(floppy),27(sudo),30(dip),116(mlocate)
See where it says "gid=502(Users)"? Thats what you want to use for group in that command, Users. Yours may be different. So run the id command and post the output here in quotes.
Just read MensaWaters' post. He already explained what I said.. Sorry for adding redundant info...
Anyway good luck trying to figure it out on your own, which many times you must.
Yup. That's pretty much *nix in a nutshell. Fortunately there are sites like LQ and askubuntu.com where you can get help.
I came from the mainframe world, originally, Burroughs MCP OS; COBOL; LINC -- creating applications specific to the needs of my employer or customer (I actually wrote a General Ledger system once!).
When I transitioned to Unix, the biggest challenge I faced was that I didn't know what I didn't know. That's generally true anytime we need or want to learn something new, but *nix can be particularly daunting for the newbie.
First I learned about man pages. man chown will tell you everything you need to know about changing ownership on files [once you learn that "chown" is the command you need to learn about -- once you know what you don't know ]
Then I bought a half-dozen O'Reilly books and read them. Learning even more about what I didn't know.
These days, one can get most (or maybe all) of the information that's in those books with a web search.
I faced was that I didn't know what I didn't know. That's generally true anytime we need or want to learn something new, but *nix can be particularly daunting for the newbie.
As you say it is true for pretty much everything. Once upon a time I had to learn DOS. I later learned MS Windows then Novell Netware then UNIX (AT&T then SCO, then HP-UX, then SunOS, Then Solaris, then FreeBSD etc...) then Linux (Caldera then RedHat then Debian then Fedora then CoreOS etc...)
Often it is a matter of knowing concepts that are appropriate to various systems then learning methods for the same concepts on other systems. DOS introduced me to command line. Novell introduced me to users and groups. UNIX/Linux introduced me to the world.
Years ago I would connect different tables on Paradox (DB on DOS) easily but later on trying to figure out how to do the same kind of connection in Informix on UNIX I had a dickens of a time mainly because I didn't know this was called doing an "outer join". Solution was to scan through the entire Informix manual page by page until I got to one that seemed to be talking about what I wanted to do.
Life is much easier now. You have man pages built into the systems for many things and for other things there is a plethora of help on the internet. Often you can simply type a keyword followed by "tutorial" to get nice startup guides. (e.g. "bash tutorial", "web tutorial", "awk tutorial"). In fact "chown tutorial" immediately pulls up among other things: https://www.howtoforge.com/linux-chown-command/
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.