Pages

Subscribe:

Sunday, February 01, 2009

add a new user in Redhat 9.0

To add a user and set up the directories you want that user to have, use the useradd command. By default, this will add a user and create a home dircetory for that user, which will be located in /home.

EXAMPLE: /usr/sbin/useradd yourname will create the user yourname, and make the directory /home/yourname

Set the password for the new user by running passwd. This will give the user a password and activate the account.

EXAMPLE: /usr/bin/passwd yourname. You will be prompted twice for a password.

NOTE: If you want useradd to create more default directories than just /home/newuser, you can add them to /etc/skel. Anything you add to this directory will be created when you add a new user.

EXAMPLE: mkdir /etc/skel/www will add a directory called www to the skel dir. Now whenever you run useradd to create a new user, it will also create a www directory in the new users home directory.

There are also some options for useradd you can add if you wish, such as changing where the users home directory will be, or which skeleton directory to use. For more information on useradd options go to www.linuxdocs.org

browse using ~user in Redhat 9.0

In order to be able to browse a user's www folder (or public_html) by using ~user you must do two things:

  1. Configure apache to allow userdir to do this
  2. Reset permissions of the users home dir and public_html dir

1) To configure apache to allow ~userdir

First you have find the following part in the Apache config file, /etc/httpd/conf/httpd.conf. (It will be around line 350 to 380)
TIP: If you are editing with vi, hold down and press g to see what line you are on

# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory # permissions).
#
UserDir disable
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#
#UserDir public_html

You need to edit two of the lines.

  1. Comment out the line UserDir disable (put a # at the beginning). This enables userdir.
  2. Uncomment the line UserDir public_html (remove the #). This sets the users dir to /home/~user/public_html

2) Reset permissions of home and public_html directories

It is recommended that you chmod /home/~user to 755 (although I have found 701 is all you need)
You must also chmod /home/~user/public_html to 755.

You will need to restart apache now.
Type /etc/init.d/httpd restart.

Apache Web Server in Redhat 9.0

Redhat 9 comes with Apache webserver. This is installed by default, but does not run at boot up.

To run Apache type the following at the command prompt:

/etc/init.d/httpd start

To test it type:

/etc/init.d/httpd status

If apache is running you should see something like the following:

httpd (pid 1844 1843 1842 1841 1840 1839 1838 1837 1828) is running...

There are several ways to run Apache at bootup, and here is one of the simple ones.
To run Apache at bootup type:

vi /etc/rc.local

This will open rc.local in the text editor "vi". Arrow down to the bottom of the text (there may not be any yet, in which case it will be the first line) and add:

/etc/init.d/httpd start

Then type :w and enter it (writes the file, i.e. saves it)
Followed by :q and enter it (quits the vi text editor)

start FTP in Redhat 9.0

Redhat 9 comes with the ftp server vsftpd. This is installed by default, but does not run at boot up.

To run vsftpd type: /etc/init.d/vsftpd start

Login to test it by typing ftp localhost at the prompt, and if you get the following, vsftpd is running.


Connected to localhost (127.0.0.1)
220 (vsFTP 1.1.3)
Name:


If you get "connection refused", and the prompt ftp>, then +z will get you back to the normal prompt.

Note: you cannot log into ftp as root, you must have a user set up.

There are several ways to run vsftpd at bootup, and here is one of the simple ones.
To run vsftpd at bootup type:
vi /etc/rc.local (this will open rc.local in the text editor "vi")
Arrow down to the bottom of the text (there may not be any yet, in which case it will be the first line)
type i to enter 'insert' mode, and add....
/etc/init.d/vsftpd start
Press the 'escape' key to exit 'insert' mode.
Then type :w and enter it (writes the file, i.e. saves it)
Followed by :q and enter it (quits the vi text editor)

configuration ip ( redhat 9 )

At the command prompt type /sbin/ifconfig to see what the IP address is, and other information on your network card.

ifconfig

There are two sections - eth0 and lo.

  • Eth0 is information about your network card. The 2nd line in the eth0 section shows you the IP address assigned to that network card (in this case it's 192.168.1.2).
  • lo is information about the loopback device (we won't go into this here).

Use /usr/sbin/netconfig to configure your network card.

You should get a GUI like this....

netconfig

If you wish to continue, press ENTER.

You will get a window where you can enter the address you want....

IP Configuration

Check Use dynamic if you want your IP address assigned automatically. I recommend leaving it unchecked at this stage.
Type in an IP address
The netmask of 255.255.255.0 should work
Enter the IP address of the gateway you use, if you use one.
Enter the IP address of the DNS nameserver you wish to use.