1

I'm new to Linux of any flavor and am having a little trouble. I am attempting to install Cloudera CDH 5 onto an Ubuntu computer I have setup to be part of the Hadoop cluster. Per Cloudera's install guide Trusty (14.04) users need to prioritize the Cloudera repository to prevent an issue with some Zookeeper packages.

To do so they instruct you to create a file at /etc/apt/preferences.d/cloudera.pref with some specific text contained inside.

However, when I navigate to /etc/apt/preferences.d/, New Document on the right-click menu is greyed out.

Thus my questions:

  1. How would I go about creating the needed file in that directory?
  2. Given that I'm the admin, how would I go about changing the right setting such that I can create/edit any file in any directory (like the admin permissions in Windows)?
aastefanov
  • 1,391
  • 12
  • 16
JMichael
  • 113
  • 2
  • 7

1 Answers1

1

Most directories under /etc will require root privileges to create files in. Unfortunately, the default file browser doesn't provide a quick-n-easy method to escalate privileges for a single operation. The command line is your answer.

sudo nautilus will launch a copy of nautilus w/ root privileges, allowing you to do whatever you want. I'm not sure that's a good idea (easy to leave it open and forget that it has super powers), but it's convenient in some cases.

sudo touch /etc/apt/preferences.d/cloudera.pref will create an empty file. Once you've done that, you could do something like sudo chown some_user /etc/apt/preferences.d/cloudera.pref to change ownership or sudo chmod a+rw /etc/apt/preferences.d/cloudera.pref to open read/write privs to everyone (generally a bad idea) You can also set user & group on a file at the same time:

sudo chown some_user:some_group /etc/apt/preferences.d/cloudera.pref

or just set the group ownership:

sudo chgrp some_group /etc/apt/preferences.d/cloudera.pref

an ls -l (or using your graphical browser w/ the right settings) will display the ownership/permission details for verification.

You could create the file and set it to be owned by your user for temporary convenience, edit it using your convenient GUI editor if you want, then set ownership back to root or whatever you want it to be for proper security.

Typically, /etc contains static configuration files, so you make them readable by certain groups of users (even all users, if not sensitive) but reserve write privs for root. I don't know anything about Cloudera, but it's common to have software running under a particular user (and a user can be a member of multiple groups) so you can set the group of the file to be the group that you want to have privs on it.

muru
  • 197,895
  • 55
  • 485
  • 740
Charles Boling
  • 548
  • 4
  • 8
  • Considering I'm the only person with access to the computer in question, 'sudo chmod a+rw /etc/apt/preferences.d/cloudera.pref' seems a decent answer. If I wanted to revert to "default" permissions on the file, is there an easy way to do so? – JMichael Jul 14 '15 at 20:11
  • If you say sudo chmod go-w /etc/apt/preferences.d/cloudera.pref it will remove the write perms from "group" & "other". Since you still don't own the file, you can't change permissions on it without being root; otherwise you could also tweak privs from the properties window of your file manager [without running it as root]. More details on how chmod works can be found with man chmod and then there's how "ls" displays those privileges. (to be continued) – Charles Boling Jul 15 '15 at 05:33
  • (cont.) The nickel tutorial there is when you see the "-rwxrwxrwx" on the left for the file, the 1st char is special (e.g. "d" for directory) and the next 9 are 3 groups of 3: read/write/execute flags for the owner, anyone in the same group, and other users. – Charles Boling Jul 15 '15 at 05:34