Category: System Admin stuff


I found it really hard to change the home directory of an FTP user, later discovered that useradd is embedded with the feature of changing the default home directory to something else. Anwyays I learnt it the hard way. It’s pretty easy and so dumb of me that I didn’t find it at the first attempt.

Here you go,

useradd [username] -p [password] -d [directory]

example:

useradd testuser -p test123 -d /opt

Here /opt is the home directory of the user testuser. By default the home directory is set to /home/testuser.

Yum

Yum is a package management utility that is used to install packages. The greatest benefit of using yum is that it automatically configures the dependency packages required for the installation and installs them as well. YUM is expanded as YellowDog Updater Modified. It is used in rpm compatible operating systems like Red Hat and Fedora/CentOS. It makes use of XML for storing repository information.

Configuring yum

YUM is stored under /etc under yum.repos.d.

The basic syntax for yum repo is

[name of repository]

baseurl=ftp://mywebsite.com

enabled=0 (or) 1

gpgcheck = 0 (or) 1

Baseurl defines the url from which the packages are to be retrieved. Enabled is whether the current repo is in on or off state. GPGcheck can be 0 or 1, depending on whether a GPG signature check needs to be performed or not.

The baseurl may be defined for HTTP/FTP websites and a few more I assume. The baseurl can be configured to use a local file system as well just use file:///(path)

For eg: baseurl = file:///root

HTH

A few tips on configuring your yum repository.

1. First update your yum repository.

yum update

2. Make sure you clean your repository so that there isn’t much of a mess.

yum clean

3. Once the yum repository is cleaned check for the packages.

yum list

The above command shows the various packages in the repository.

Every time one installs packages make sure to do the above steps

HTH

Installing Broadcom drivers on Fedora 16 is quite easy but sometimes configuring the repositories proves to be a hindrance. First to install broadcom drivers make sure you add rpmfusion repositories to your yum repositories.

1. Go to rpmfusion.org/configuration, select the desired rpm from the list. In my case i chose rpm fusion Non Free for Fedora 14,15,16.

2. Run the rpm file.

3. Make sure your broadcom drivers are present.

yum install b43*

4. Now install kmod-wl

yum install kmod-wl

5. Restart your machine

6. Make sure your kernel header files are up to date.

yum install kernel-PAE-devel kernel-headers

HTH

Adding Another Logical Volume

Adding another LV is a straightforward process.

  1. Add the new hard drive.
  2. Configure the new hard drive with partitions using a command tool such as fdisk. It’s code is 8e within fdisk.
  3. If you’ve created separate partitions, you can dedicate the space of a specific partition to a PV. If you don’t already have an empty logical volume, you’ll need to create more than one. For example, for the first partition /dev/sda1, you can do this with the following command:
    # pvcreate /dev/sda1
  4. Next, you’ll want to create a Volume Group (VG) from two or more empty, properly configured partitions (or drives). One way to do this, assuming you have an empty /dev/sda3 partition, is with the following command:
    # vgcreate Volume01 /dev/sda1
  5. Before proceeding, you should inspect the VG with the vgdisplay command.
  6. You should now be able to add another LV with the lvcreate command.
    # lvcreate -l 20 Volume01 -n LogVol01
  7. You’ve added a new logical volume. Naturally, you’ll need to format and mount a directory on this LV before you can use it. For the example shown, you would use the following commands:
    # mkfs -j /dev/Volume01/LogVol01
    # mount -t ext3 /dev/Volume01/LogVol01 /tmp

Removing Logical Volumes

Removing an existing LV requires a straightforward command. The basic command is lvremove. If you’ve created an LV in the previous section and want to remove it, the basic steps are simple:

  1. Save any data in directories that are mounted on the LV.
  2. Unmount any directories associated with the LV. Based on the example in the previous section, you would use the following command:
    # umount /dev/Volume01/LogVol01
  3. Apply the lvremove command to the LV with a command such as:
    # lvremove /dev/Volume01/LogVol01

Resizing Logical Volumes

If you have an existing LV, you can add a newly created PV to extend the space available on your system. All it takes is appropriate use of the vgextend and lvextend commands. For example, if you want to add PEs to the VG associated with the aforementioned /home directory, you could take the following basic steps:

Just be careful while re-sizing home directories as the computer may crash do take sufficient precaution while handling re-sizing requests as they are prone to system crashes.

  1. Back up any data existing on the /home directory.
  2. Unmount the /home directory from the current logical volume.
  3. Extend the VG to include the new hard drive or partitions that you’ve created. For example, if you wanted to add /dev/sdd1 to the /home VG, you would run the following command:
    # vgextend Volume00 /dev/sda1
  4. Make sure the new partitions are included in the VG with the following vgdisplay command:
    # vgdisplay Volume00
  5. Extend the current LV to include the space you need. For example, if you wanted to extend the LV to 2000MB, you’d run the following command:
    # lvextend -L2000M /dev/Volume00/LogVol00

    The lvextend command can help you configure LVs in KB, MB, GB, or even TB. For example, you could get the same result with the following command:

    # lvextend -L2G /dev/Volume00/LogVol00
  6. Reformat and remount the LV, using commands described earlier:

    use resize2fs when prompted

    # mkfs -j /dev/Volume00/LogVol00
    # mount -t ext3 /dev/Volume00/LogVol00 /home

The following example explains the sticky bit – a special feature in linux operating systems

  1. Add users called test1, test2, and test3.
    # useradd test1; passwd test1
    # useradd test2; passwd test2
    # useradd test3; passwd test3
  2. Edit the /etc/group file and add a group called group1. Make the test1 and test2 accounts a member of this group. You could add the following line to /etc/group directly or use the Red Hat User Manager:
    group1::9999:test1,test2

    Before you proceed, make sure the group ID you assign to group group1 is not already in use.

  3. Create a shared director for the group1 group:
    # mkdir  /home/testshared
  4. Change the user and group ownership of the shared directory:
    # chown  nobody.group1  /home/testshared
  5. Log in as test1 and test2 separately. Change the directory to the testshared directory and try to create a file. Two ways to do so are with the following commands.
    $ date >> test.txt
    $ touch abcd
  6. Now as the root user, set group write permissions on the testshared directory.
    # chmod 770 /home/testshared
  7. Log in again as user test1, and then try to create a file in the new directory. So far, so good.
    $ cd /home/testshared
    $ date >> test.txt
    $ ls -l test.txt
  8. Now check the ownership on the new file. Do you think other users in the group11 group can access this file?
    $ ls -l
  9. From the root account, set the SGID bit on the directory:
    # chmod g+s  /home/testshared
  10. Switch back to the test1 account and create another file. Check the ownership on this file. Do you think that user test2 can now access this file?
    $ date >> testb.txt
    $ ls  -l
  11. Now log in as the test2 account. Go into the /home/testshared directory, create a different file, and use ls -l to check permissions and ownership again.
  12. Switch to the test3 account and check whether you can or cannot create files in this directory, and whether you can or cannot view the files in this directory.

Red Hat

If you people ever wanted to change your terminal name as well as the user that appears on the terminal for example the default would be set as “root@localhost” , you can always change that to your needs, to change the terminal label go to terminal menu and select “Set title”, changes would be effected as soon as its set.

1. Now to change the user go to /etc/hosts and change the hostname after the ip like

127.0.0.1 localhost.localdomain localhost

to (say)

127.0.0.1 linuxserver linuxserver

2. Now go to terminal and give the following command

sysctl kernel.hostname = linuxserver

3. Now make changes to /etc/sysconfig/networks file as well set “HOSTNAME=   ” to your requirement in my case its linuxserver

Logout and check for the changes

HTH