LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Permissions command needs clarifying (https://www.linuxquestions.org/questions/linux-newbie-8/permissions-command-needs-clarifying-875284/)

nnjond 04-16-2011 01:43 AM

Permissions command needs clarifying
 
Hi,

I've installed my os on a new HD, and it declines me permission to acces my Data dd. I seem to remember I should navigate to the drive and:

sudo -R 777 *

Could you fill me please?

An additional quiry is the failure to recognise my certain password in this specific instance:

nnjond@Den-GeForce6100PM-M2:~$ su
Password:
su: Authentication failure
nnjond@Den-GeForce6100PM-M2:~$

?

acid_kewpie 04-16-2011 01:59 AM

I think you mean "chmod" not "sudo" the commands are very different. run "man chmod" for it's usage and function. You've said nothing about what data this is, what kind of partition, but doing a 777 is usually the very worst way to fix permissions issues, as what you're doing is to just make everything writable by everyone, which is horrible. There's probably a better way if you can give more details.

As for su, that's acking for the root password, not your password. an equivalent which uses *your* password is "sudo -i" assuming your sudoers file is configured to allow this.

nnjond 04-16-2011 02:47 AM

Thanks for your help.

All my files (not sw) are on a second physical hdd, so it doesn't mater if I mess up my os.
I'm the only user of my pc so, I imagine 777 is no threat to my peace of mind.

If you can advise me on a more standard way of accessing my data drive on /media//,

I would be grateful. I hope that answers your questions.

unSpawn 04-16-2011 03:28 AM

Quote:

Originally Posted by nnjond (Post 4326123)
All my files (not sw) are on a second physical hdd, so it doesn't mater if I mess up my os.
I'm the only user of my pc so, I imagine 777 is no threat to my peace of mind.

That may be your opinion but I'm afraid it's simply wrong: that what affects your setup may adversely affect the 'net community. Linux may be free to use but using it is not free of responsibilities.


Quote:

Originally Posted by nnjond (Post 4326123)
If you can advise me on a more standard way of accessing my data drive on /media//,

First restore your file permissions then move on to other tasks. Since Debian-based distributions don't facilitate easy restoration of permissions here's a script from Ubuntuforums:
Code:

#!/bin/bash
# Restores file permissions for all files on a debian system for which .deb
# packages exist.
#
# Author: Larry Kagan <me at larrykagan dot com>
# Since 2007-02-20

ARCHIVE_DIR=/var/cache/apt/archives/
PACKAGES=`ls $ARCHIVE_DIR`
cd /

function changePerms()
{
    CHOWN="/bin/chown"
    CHMOD="/bin/chmod"
    PERMS=$1
    OWN=`echo $2 | /usr/bin/tr '/' ':'`
    PATHNAME=$3

    echo -e "$CHOWN $OWN $PATHNAME"
    #`$CHOWN $OWN $PATHNAME`
    #`$CHMOD $MODE $PATHNAME`
       
}

for PACKAGE in $PACKAGES;
do
    echo -e "Getting information for $PACKAGE\n"
    FILES=`/usr/bin/dpkg -c "${ARCHIVE_DIR}${PACKAGE}"`

    for FILE in "$FILES";
    do
        FILE_DETAILS=`echo "$FILE" | awk '{print $1"\t"$2"\t"$6}'`
        changePerms $FILE_DETAILS
    done
done

This may or may not work for you. If it does not then re-installing your distribution would be best. The fact that that's tedious, boring and a waste of time you will chalk up as a "lessons learnt" so you remember next time to read before you act.

T3RM1NVT0R 04-16-2011 07:20 AM

@ Reply
 
Hi nnjond,

unSpawn and acid_kewpie are right that you shouldn't be using 777 (Its not about the threat its about how you should set up your system in general) and as said by acid_kewpie I think it is not sudo it should be chmod

Also for your other query i.e. when you do su you get authentication failure. Which Linux flavor it is? If it is Ubuntu and you are logging in for the first time then you have reset the root password because Ubuntu does not ask you for root password during installation.

Have you ever logged in as root on this machine? Do you remember the root password? If not then reset the root password first :-)

nnjond 04-16-2011 04:04 PM

Thanks for your advice. I'm not sure how to follow it. My Ubuntu os is freshly installed and I haven't tried to alter the permisions. -But I am not permited to alter my files on a second physical hdd as this was established in another setup.

Should I just paste a sequence of the lines into the Bash terminal? I'm not sure where I should begin?

yancek 04-16-2011 04:35 PM

You're using Ubuntu and according to your post #3, your data drive is in the /media directory but you cannot access the drive of directories on it, correct.

You could post the info you see there so someone could help with whatever changes are needed. Click on the Applications tab at the top left of the Desktop and in the drop-down menu, look for Terminal and click it. Then run this: ls -l /media
This should show your directories which should include your second drive as well as whatever their permissions are.

stress_junkie 04-16-2011 04:43 PM

One of the good things about Ubuntu is that it makes using an external disk easier than other Linux distributions.

You should plug in the drive then on your desktop near the top of the screen you should click on Places. Then you will see a list of directories AND you should see your external disk drive. Just click on the icon for your disk drive. Ubuntu will automatically mount it and it will set the permissions for you. It will also open a file explorer window at the same time.

BTW the file explorer in Ubuntu is called Nautilus.

T3RM1NVT0R 04-16-2011 05:10 PM

@ nnjond
 
Alright for your query regarding authentication failure here is the solution:

http://www.myokyawhtun.com/ubuntu-li...or-ubuntu.html

Also read the following:

http://www.ubuntux.org/how-to-change...word-in-ubuntu

The first link says that by default there is no password set for root user in uBuntu which is not correct. It has been explained in the second link.

For your query related to permissions, we will get back on that once you are done with this.

spazticclown 04-16-2011 05:30 PM

Is the data drive formatted for NTFS or FAT32? If it is then you can just change the ownership of the mount point or even edit the fstab to grant ownership to your user.
Code:

$ su -c 'fdisk -l'
password:

This will print a list of your drives and partition types.

If the drive is EXT[234] or another non-windows partition then maybe changing the ownership rather than permissions would be a better bet?

This will change the entire drive ownership
Code:

$ su -c 'chown -R <username>:<groupname> <mount point of drive in question>'
password:

"su -c" gets you root permissions on the command in the single quotes. "chown -R" will change the ownership of all files, directories and subdirectories. "<username>" is just your user name. "<groupname>" is not necessary, if you don't use it take out the ":" also. "<mount point of drive in question>" can be something like "/media/sdb1" or "/media/C Drive" depending on where it is mounted.

Hope this helps.

nnjond 04-16-2011 10:46 PM

The procedure below seems to succeed except when I open an .odt doc on the drive in question it is read only and -'is locked for editing by yourself on a different system'


Code:

nnjond@Den-GeForce6100PM-M2:~$ sudo fdisk -l

Disk /dev/sdb: 2023 MB, 2023751680 bytes
255 heads, 63 sectors/track, 246 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000078f1

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1        246    1975963+  b  W95 FAT32

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cedbd

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1        7725    62048092+  83  Linux
/dev/sda2            7725      30402  182149121    5  Extended
/dev/sda5          30020      30402    3068928  82  Linux swap / Solaris
/dev/sda6          15234      29669  115948544  83  Linux
/dev/sda7          29669      30019    2812928  82  Linux swap / Solaris
/dev/sda8            7725      14922    57807872  83  Linux
/dev/sda9          14922      15233    2500608  82  Linux swap / Solaris

Partition table entries are not in disk order

Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ea57a

  Device Boot      Start        End      Blocks  Id  System
/dev/sdd1              1      121602  976760832  83  Linux
nnjond@Den-GeForce6100PM-M2:~$ sudo chown -R nnjond /media/sdb1
chown: cannot access `/media/sdb1': No such file or directory
nnjond@Den-GeForce6100PM-M2:~$ sudo chown -R nnjond /dev/sdb1
nnjond@Den-GeForce6100PM-M2:~$


acid_kewpie 04-17-2011 08:08 AM

fat32! Pfft. so assuming you wish to share this drive with windows machines and the likes, then you can keep it as fat32. However, fat32 is NOT a posix (unix) compliant filesystem. As such, it has no concept of file ownership and access rights in the filesystem itself. Consequently chmod will do nothing. You traditionally need to mount it with "fake" rights - "mount /dev/sdb1 /mnt/my_drive -o umask=000" etc, which wold make all the files world accessible. Under Gnome I'm not really sure what the easy user enhancements are in the GUI world, but just plugging it in should make then fully accessible through Gnome.

malekmustaq 04-18-2011 12:49 AM

nnjondk,

acid_kewpie is right. FAT16,32 cannot help you control ownership. If it doesn't cost you any data you may reformat that /dev/sdb1 into a linux format.

As a matter of experience MS file systems are a security risk. My advice is always to format every volume into a linux or unix filesystem before using them. Just imagine you issuing an option of umask=0000 ! in the fstab, nothing can be more promiscuous than that: I certainly cannot allow my disk nor my files behave like prostitutes in another hands. Lol (joke).

Hope it helps.


All times are GMT -5. The time now is 04:46 AM.