Linux Questions

Rubtub

New member
Joined
Jan 11, 2006
Messages
246
Reaction score
0
Points
0
Well im in school for linux yet, my teacher is the same teacher have for VB which.. my VB teacher sucks. So that being said, He never showed us how to do this so im asking for your help a bit.

Using Slackware
Ok first question is making a user "student" with the password "password" ( Got this one)

Make a script in the /scripts folder to make a backup in the /backup folder for the /home/student directory. With the file name student.tar.gz! Also make it run once every hour on the hour everyday.

This part I have gotten most of just its screwing me up here is what i have gotten. ( ANY help would be helpful)

Well mkdir scripts and backup
my script is something like this

name: script
Code:
#! bin/bash
tar -cvvf /home/student.tar.gz /backup

( for some reason gives me a remove "/" before member) It doesnt click to me i have read so many examples everyone says its like this.

I can not even get the script to run so i can get into the crontab.
my crontab is setup like this

Code:
00**** /scripts/script

Last part: Make everytime the "student" account is logged on start with startx (GUI)
No idea on this.. never ever showed us this..

Basicly both classes were taught by google.com

If you guys would post any comment that would be helpful. I thank you in advance.
 
Using Slackware
Ok first question is making a user "student" with the password "password" ( Got this one)

No clue about slackware in particular, but look for useradd or adduser. Both commands usually exist, sometimes it's the same command by different names. You might need to give a password afterwards with passwd, but sometimes useradd/adduser will do it for you.

Make a script in the /scripts folder to make a backup in the /backup folder for the /home/student directory. With the file name student.tar.gz! Also make it run once every hour on the hour everyday.

This part I have gotten most of just its screwing me up here is what i have gotten. ( ANY help would be helpful)

Well mkdir scripts and backup
my script is something like this

name: script
Code:
#! bin/bash
 *tar -cvvf /home/student.tar.gz /backup
( for some reason gives me a remove "/" before member) It doesnt click to me i have read so many examples everyone says its like this.

Well, first things first. "man" is your friend. do a "man tar" and go from there. For this particular example, your command is actually incorrect at another level. To actually gzip the file, you want
Code:
 tar -czvf /home/student.tar.gz /backup
Another common convention for tar.gz is .tgz instead, just fyi.
Also... the path to bash is most likely /bin/bash, as opposed to bin/bash, which is a relative path. so your first line should be
Code:
#!/bin/bash
I also recommend you getting in the habit of writing scripts for sh, rather than bash, since sh is on every unix box out there, no so with bash.

I can not even get the script to run so i can get into the crontab.
my crontab is setup like this

Code:
00**** /scripts/script

You don't need both zeros, you can just do
Code:
0 * * * *
Note that you need spaces between the fields.

Last part: Make everytime the "student" account is logged on start with startx (GUI)
No idea on this.. never ever showed us this..

Basicly both classes were taught by google.com

If you guys would post any comment that would be helpful. I thank you in advance.

you can just make student's shell be startx, instead of bash. That's a crap way of doing it though, the "proper" way would be to use kdm/xdm.
 
Last edited:
I just setup an Ubuntu LAMP server, lemmy tell you that was fun. Sadly I can't answer any of your questions, cause I only know how to do it in the deb stuff. But as for the gui part, I guess I can atleast tell you what I did.
Code:
apt-get install desktop-ubunutu
That installs the GUI packages. Not sure how slackware handles it.

Code:
gdm
That loads the GUI and sets it to default.

I dunno how useful this will be. New linux user myself.

r2h
 
Wow..

To just want to say i spent 4 hours yesterday doing this i manned and google almost all of this

Would you elaborate on the last part. Where would i go to mess with the shell script for student.

Also in the crontab:

If i set it up just like you have it and put

/scripts/script afterwards to make it call the script to back up student directory to backups. Will that work? I dont have a linux box with me as i speak.
 
Ok, First
the compression of the directory would be a script like

#!/bin/bash
tar -czvf /backup/student.tar.gz /home/student

Next, the restore script would be
If you are running this as root then you would also need the chown line
#!/bin/bash
tar -xzvf /backup/student.tar.gz /home/student
chown -R student /home/student

second the crontab
use the command crontab -e
then inside the file it loads put (or whatever the path and script is)
Also, make sure the script is executable

0 0 * * * * /scripts/studentscript.sh

You dont need both 0's as was previously said, but imo its good practice.

For starting X when the user logs in there really has to be checks put in place. Because there are multiple ways of logging in.
Under the assumption the 'student' accnt always logs in via the host tty then placing startx in the .profile (or whichever is being used for the startup script) would work fine. If not, then you also would have to make sure that it is available to do by exporting the X display to the computer he is loggin in from.

Now, since most of that probalby didnt mean much, when asked for a test, with the limited knowledge you have atm, just put in there to add a line of 'startx' at the bottom of the users profile script.
 
Nice. Last question

Ok great i understand where i went wrong on the 2nd problem

The last one, I wish it was written if you would point me in the direction to change the profile so when i log in ( its a hands on test) so i has to "work".

What directory are the profiles located in. Do i just add startx at the bottom or have to put the absoulte path?

To make the script execuable would be
chmod 777 (scriptname)?
 
mind Bogged!!

OK i have tried everything in my power to make a script for the user "student" to run everytime the student user logs in. I set it up under crontabs.. it just refuses!!

If Anyone has any idea. Please let me know i have search the whole day. I dont care if its a link please just link it. Thanks a ton.

Or

Am i not doing it right, Falcor said something about profile but i cant seem to find that either.

Thanks in advance.
 
if you want the script to run when the student logs in, just add it to your .bashrc like you would execute it from the command line (with full path to the script).

Crontab would be for scheduling it for a date/time, not running it when logging in.