Day 11 SAMBA NFS Logs Managing Users. SAMBA Implements the ability for a Linux machine to...

21
Day 11 SAMBA NFS Logs Managing Users

Transcript of Day 11 SAMBA NFS Logs Managing Users. SAMBA Implements the ability for a Linux machine to...

Day 11

SAMBA

NFS

Logs

Managing Users

SAMBA• Implements the ability for a Linux machine to

communicate with and act like a Windows file server.– Implements

• File sharing

• Printer sharing

• On Linux you run smbd. Configure the smb.conf file.

• In windows, your linux machine appears as a new machine in the Neighborhood Network.

SAMBA• For more information about SAMBA, or to find out

how to install/configure it.– http://www.samba.org

nfs• What if you have 2 UNIX machines who would like

to share files with each other.

• One is a server, the other is a client. – We’ll configure both.

Server - /etc/exports• Edit the file /etc/exports. Put the following in it:

/usr (ro)

Server – Start services• As root type:

rpc.mountd

rpc.nfsd

• To have these start automatically put them in startup files.

• If you make any changes to the /etc/exports file, you will need to run

exportfs

Client - /etc/fstab• Find out the IP address of your cousin.

• Make a new directory:mkdir /cousin

• Add the following to /etc/fstab

63.34.78.19:/usr /cousin nfs

• Now save that file and then type:

mount -a

Testing it out• Now on your machine, you should be able to see

your cousins /usr partition.

• As setup, this is a read only mount. To change this, you would use rw instead of ro in the /etc/exports file.

User accounts• One big job of a system administrator is managing

users.– Adding new users when employees are hired.– Deleting old ones are they are fired/quit.– Managing user groups– Resetting passwords

Create a new user.• Usually done with the adduser command.

– This simply does the following:• Adds a new line in /etc/passwd

• Creates a new directory for this person.

• Puts the default files into the new directory.

• Changes ownership and permissions of the files for the user.

Groups• User groups are defined in /etc/group

• prof:x:101:chastine,delgado,booth,coleman,wilson,tomas,preston,enda

• Users can be members of multiple groups

• To see what groups you are a member of use:– id

Changing passwords• Users can change their password at any time.

– passwd• Asks for old password, and then new password twice.

• If a user forgets their password, there is no way to find it out.– Root user can run

• passwd enda

• This will allow him to set a new password for enda, without knowing the old one.

Setting up directory.• /etc/skel

• This is a skeleton directory which has the basic files which a user would need.– .bash_profile etc.

• To manually setup a user:– mkdir /home/enda– cp –R /etc/skel /home/enda– chown –R enda:enda /home/enda– chmod –R 744 /home/enda

Disable a user• Usually done by either:

– Change their shell to /bin/false– Or delete them from /etc/passwd

– You can also user• userdel enda

Logging• A log file is a great resource for finding out what is

going on.– Main logfile is located in /var/log

• /var/log/messages

– Additional logs may exist in there for various applications:

• Web Server logs

• FTP Server logs

• Mail logs

syslogd• Runs all the time in the background as a deamon.• Reads configuration file /etc/syslog.conf

– This determines how various levels of errors or messages are handled.

• Broken up as follows:– kern.* /dev/console– daemon.warning /var/log/messages

• These would mean:– Any message from the kernel should be written to

console– Warning messages from daemons should be written to

/var/log/messages.

Levels of messages• Debug

– You probably never care• Info

– General startup, shutdown of program.• Notice

– User enda logged out etc.• Warnings

– Non critical problems• err

– Errors from the program.• Crit

– Critical errors which may cause the program to crash• alert

– Critical errors, which may effect other things• emerg

– Wow…the system could crash because of this.

Who can log• Messages usually come from:

– daemon– kern– auth– cron– mail– local0-7– Actual program names.

After changes - HUP• Once you make changes to syslog.conf. You must

tell syslogd to reread its configuration file.– kill –HUP [process ID of syslogd]

logger• If you want to log something in the log file, you can

use logger.– Useful in a script which may be run in background as

daemon, or as a cron job.• logger Test

– If you want it to log under a certain priority:• logger –p daemon.info “Started up”

logrotate• The program logrotate can be used to rotate your

logfiles.– By default on a RedHat system, logfiles are rotated every

week, and the previous 4 are kept.• With this weeks logfile, you have approx 5 weeks of logfiles.

– Configured in:• /etc/logrotate.conf• If you have a very busy system, this may be too much.

• Nothing magical, crontab which does:– mv messages messages.old– touch /var/log/messages– kill –HUP syslogd