Working with Linux

If, like me, you get tired of trawling the the internets digging into old message boards looking for linux help, then this page is for you, here is some stuff that I use a lot.

Here is a short summary on monkeying with linux via the command line! Woo!

Crontab

Starting Crontab:

crontab -e: Edit current users crontab file, create one if it doesn’t exists.
crontab -l: Show the contents of current uses crontab file.
crontab -r: Delete crontab file.

Crontab contents and syntax

Enter this to get problems and other stuff emailed to you:
MAILTO=”name@domain.com”

A crontab file has five stars specifying day, date and time, with the command to be run at the end.

* * * * * command to be run

The stars are:

  • Min (0 - 59)
  • Hour (0 - 23)
  • Day of the month (1 - 31)
  • Month (1 - 12)
  • Day of the week (0 - 6) ( Starts on Sunday, so Sunday = 0)
  • The field can have a * which means “all”, a list of elements seperated by commas or you can also have two numbers seperated by a hyphen which indicates a range.

Note: The specification of days can be made in two fields: month day and weekday. If both are specified in an entry, they are cumulative meaning both of the entries will get executed .

Crontab example

This example will run the php script at 2:15 am, every day.

15 2 * * * /usr/bin/php -f /home/someuser/foo.php

User stuff

Adding a group

group add [groupname]

Adding a user

useradd -g [groupname] -d /path/to/home -s /dev/null [username]


Update: the ‘-s’ switch, specifies what shell the user should use. Setting it to ‘/dev/null’ may cause you some problems, so, you need to set it to some shell that is actually in /etc/shells. It doesn’t have to be a real shell though, simply add ‘/bin/false’ to /etc/shells and then set the users shell: -s /bin/false. This highlighted itself when I tried to setup a user with proftp, because his shell didn’t exists, he couldn’t connect.


Modifying a user

usermod -g [groupname] / usermod -s /path/to/shell / usermod -etc ….

Deleting a user

userdel [username]

Other Stuff

ProFTP

Proftp, is, I guess, the programme that my server uses to allow people ftp access.

To stop people from visiting anywhere else on the server other than their home directory (and sub-directories of that) you need to edit /etc/proftp.conf and change the DefaultRoot to:

DefaultRoot ~

You can also do things like:

DefaultRoot ~ !some-group-who-can-do-what-they-like or DefaultRoot ~ group1, group2, group3 and DefaultRoot /path/to/rome romegrp1, romegrp2