Tag: fedora

  • RHEL6 – Using ACLs to Grant and Restrict FIle Access.

    RangerRick

    Access Control Lists or ACLs provide more controll over file permissions than standard linux file permissions (UGO — user, group, other). For example lets say that you want all members of the group "students" to have the ability to read a file, however you want to allow one user in that group the ability to write to the file, well ACLs can help you do this.

    First thing that you need to know is that you cannot just start using ACLs right away, first you have to make sure that your filesystem is mounted so that ACLs are availible. This means adding ACL to the mount options in /etc/fstab.

    UUID=3fa4603e-9874-4f47-ae1c-3f7715a54238 /                       ext4    defaults,user_xattr

    So in my fstab, I change the line above to the line below. I know, exciting right?

    UUID=3fa4603e-9874-4f47-ae1c-3f7715a54238 /                       ext4    defaults,user_xattr.acl

    Now to view the permissions and ACLs on a file use the getfacl command, below i am checking the file RangerRick.jpg in /root/Pictures.  In the example below there are no ACLs assigned, btw.

    [root@fedora15 Pictures]# getfacl RangerRick.jpg
    # file: RangerRick.jpg
    # owner: root
    # group: root
    user::rw-
    group::r–
    other::r–

    So lets allow the user "chris" to write to the file, just just read it.

    [root@fedora15 Pictures] setfacl -m u:chris:w RangerRick.jpg

    Now run getfacl again and check out the difference

    [root@fedora15 Pictures]# getfacl RangerRick.jpg
    # file: RangerRick.jpg
    # owner: root
    # group: root
    user::rw-
    user:chris:-w-
    group::r–
    mask::rw-
    other::r–

    Additonal Examples:

    Lets give all users in the group "students" the ability to write to the file, since they may want to modify it and add a photochop their faces over the dear old racoon's face.

    [root@fedora15 Pictures] setfactl -m g:students:w RangerRick.jpg

    But oh no, user "bert" in the group "students", has decided to modify the file RangerRick.jpg in an in appropriate way, so lets remove his permissions altogether.

    [root@fedora15 Pictures] setfacl -x u:bert

    Lets say that we want to allow the user "chris" to be able to modify all existing and newly created files in the Pictures directory where the Ranger Rick picture lives.

    [root@fedora15 Pictures] setfacl -m d:u:chris:rw /root/Pictures

    Note that when a file has ACLs assigned to it, a plus "+" sign will appear in the output of an 'ls-l'

    -rw-rw-r–+ 1 root root 148011 Oct 12 15:06 RangerRick.jpg

    Honestly you will probably never need to use ACLs, but they are handy to have availible if you run into some sort of situation where you need to grant very particular permissions to files and directories.

  • RHEL- Find UUID of Hard Disks

    CinderblockAnyone who has added and removed multiple disks from a RedHat server knows very well that your disks may not always enumerate exactly the same way after a reboot. You then have to resort to mounting up your filesystems to a temporary mount point to see exactly whats in them, and were they really need to be mounted.

    Want to know if UUIDS are being used on your linux box, well just cat /etc/fstab, and if you see somthing similar to what’s below, then you are using UUIDS, instead of traditional disk device names.

    UUID=3fa4603e-9874-4f47-ae1c-3f7715a54238 /                       ext4    defaults,user_xattr        1 1
    UUID=483c34a4-b3ec-4860-854f-b9e5b6a6efac /boot                   ext4    defaults        1 2
    UUID=7cab6648-b3f3-4aaa-bb2b-d32b78156aab /var                    ext4    defaults        1 2
    UUID=7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7 swap                    swap    defaults        0 0

    One way of mapping device UUIDS back to device names is the blkid command — usage and output below.

    [root@fedora15 ~]# blkid
    /dev/sda1: UUID=”483c34a4-b3ec-4860-854f-b9e5b6a6efac” TYPE=”ext4″
    /dev/sda2: LABEL=”_Fedora-15-x86_6″ UUID=”3fa4603e-9874-4f47-ae1c-3f7715a54238″ TYPE=”ext4″
    /dev/sda3: UUID=”7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7″ TYPE=”swap”
    /dev/sdb1: UUID=”7cab6648-b3f3-4aaa-bb2b-d32b78156aab” TYPE=”ext4″
    /dev/sdb2: UUID=”rJfNaK-e3Xp-n3qm-4aXM-BfKF-g7sg-Kwm33a” TYPE=”LVM2_member”
    /dev/sdc1: LABEL=”raid1″ UUID=”34ed4ffd-cc4a-4b40-892f-6d7714fe7f4e” TYPE=”ext3″
    /dev/mapper/vm_vg-v1: UUID=”2d96aa43-b5b8-4185-8014-323ad8a07a0d” TYPE=”ext4″

    You can also do an ls on the following directory and get the same information.

    [root@fedora15 ~]# ls -l /dev/disk/by-uuid
    total 0
    lrwxrwxrwx 1 root root 10 Sep 25 21:41 2d96aa43-b5b8-4185-8014-323ad8a07a0d -> ../../dm-0
    lrwxrwxrwx 1 root root 10 Sep 25 20:51 34ed4ffd-cc4a-4b40-892f-6d7714fe7f4e -> ../../sdc1
    lrwxrwxrwx 1 root root 10 Sep 25 20:51 3fa4603e-9874-4f47-ae1c-3f7715a54238 -> ../../sda2
    lrwxrwxrwx 1 root root 10 Sep 25 20:51 483c34a4-b3ec-4860-854f-b9e5b6a6efac -> ../../sda1
    lrwxrwxrwx 1 root root 10 Sep 25 20:51 7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7 -> ../../sda3
    lrwxrwxrwx 1 root root 10 Sep 25 20:51 7cab6648-b3f3-4aaa-bb2b-d32b78156aab -> ../../sdb1

    If you are so inclined, you can also get the UUID and filesystem label (if there is one) with the tune2fs command

    tune2fs -l /dev/sda1

    Filesystem volume name:   <none>
    Last mounted on:          /boot
    Filesystem UUID:          483c34a4-b3ec-4860-854f-b9e5b6a6efac
    Filesystem magic number:  0xEF53
    Filesystem revision #:    1 (dynamic)

    ….truncated…

    Oh and if you are running Fedora 15 and are wondering what the heck rootfs is (as I was), here is an explanation. More junk that I hope never gets into RHEL.

    Oh and if you are really bored, and would like to know more about what a UUID is go here

  • Systemd/Systemctl in Fedora 15 — WTF is this?

    Nausea_smiley Fresh install of Fedora 15 on my home machine… feeling great, running great. Got myself a fast new SSD, and upgraded to a new quad core and 8gb of ram. Then i run into this.

    [root@fedora15 ~]# service nscd start
    Starting nscd (via systemctl):                             [  OK  ]

     

    Oh man whats this — systemctl. If this is anything like upstart I am going to be ill.  Well guess what, it is. Even worse, its also kinda like svcadm in Solaris10.

    "systemd is a replacement for the System V init daemon for Linux. It is intended to provide a better framework for expressing services' dependencies, allow more work to be done in parallel at system startup, and to reduce shell overhead"

    Seriously, was there something wrong with systemV init scripts that i was not aware of.  Looks like systemd is enabled by default in Fedora15,

    Anway, the link directly below will take you to a nice cheatsheet for systemd commands. Looks like they are also mucking around with the sysivinit Runlevels. Scroll down for that little gem.

    http://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet

    Below is also a FAQ on systemd

    http://www.freedesktop.org/wiki/Software/systemd/FrequentlyAskedQuestions

    And a bit more insight into what it is and where it comes from

    http://www.h-online.com/open/news/item/Systemd-presented-as-SysV-Init-and-Upstart-alternative-991875.html

    Finally the blog post from the developer announcing systemd. Apparently from last year.

    http://0pointer.de/blog/projects/systemd.html

    Wondering now when we are going to see this in RHEL and if and when systemVinit will be completely deprecated.

  • Installing Spotify on Fedora

    Spotify-logo So Spotify is finally available in the US, which is good news for those who are getting tired of Pandora. Hell, Pandora played Celine Dion on my Hardcore Punk Radio Station the other day…wtf.

    So anyway, I decided to sign up and was disappointed to find that they did not have an official linux client, However they do publicize an Ubuntu client here, however, since I run Fedora this is not much interest to me.

    Thankfully the Europeans have already figured out how to get Spotify running on other linuxes natively, and google found this link on installing the Debian packages on Fedora 13. I am glad to report that these instructions also work on Fedora 12. So far so good on Fedora 12.

    However i decided to explore their repo a bit and found that in fact they do have rpm packages. Check out the link below. Sneaky.

    http://repository.spotify.com/fedora/

    I bit more googling found me this link which contains instructions on installing via the apparently secret rpms.

    Btw, if you are a jackass and want to run Spotify under Wine for some reason, click here for instructions.

  • RHEL – How to Encrypt a Partition using Cryptsetup and LUKS

    EUTScglkIUlpZsV Cryptsetup uses dm-crypt to encrypt a disk at the partition level.  In RHEL, cryptsetup is used with Linux Unified Key Setup (LUKS), a disk encryption specification. Mounting a LUKS encrypted partiton requires a passphrase, which can either be passed in a file or via the command line. Read more about dm-crypt here.

    Anyway to use crypsetup, you first must have a free partiton on a disk. In this instance I am using /dev/sdc1, which is a freeagent external usb drive.

    First initialize the LUKS partition. My target is /dev/sdc1

    #cryptsetup luksFormat /dev/sdc1

    Then open the LUKS partition setup the dev mapper device. The command below creates /dev/mapper/freeagent

    #cryptsetup luksOpen /dev/sdc1 freeagent

    Create a passkey file if you want the device to be able to automount at boot. 

    #touch /root/freeagent_passkey && chmod 600 /root/freeagent_passkey

    Make cryptsetup aware of the key

    #cryptsetup luksAddKey /dev/sdc1 /root/freeagent_passkey

    #echo "mypasskey" > /root/freeagent_passkey

    Dont forget to make a filesystem

    #mkfs -t ext4 /dev/mapper/freeagent

    Then add the following to /etc/fstab…

    /dev/mapper/freeagent   /freeagent              ext4    _netdev         1 1

    And add the following to /etc/crypttab. Note that the first entry is the name of the /dev/mapper device

    freeagent       /dev/sdc1       /freeagent

    To get a status on a device and to see the mappings between /dev/mapper and /dev/sdc1

    #cryptsetup status

    /dev/mapper/freeagent
    /dev/mapper//dev/mapper/freeagent is active:
      cipher:  aes-cbc-essiv:sha256
      keysize: 128 bits
      device:  /dev/sdc1
      offset:  1032 sectors
      size:    2930270970 sectors
      mode:    read/write

    Make sure you keep track of when to use /dev/mapper/freeagent vs /dev/sdc1 in the commands above.