Need some Linux Terminal Commands Help

Lino

I am back
Joined
Jan 26, 2008
Messages
13,785
Reaction score
56
So as a lot of you know I am becoming more and more involved with Linux with each passing day.

I am currently doing my Linux + and have its exams next week.

There are a few things I am unsure of.

1) Lets say I am currently in directory etc.

Right, now lets say I want to backup the file "motd" using tar and I want the file to be backed up onto the desktop.

All I can do so far is

tar -cvf nameofthefile.tar /etc/motd

what do I have to add to that?


2) Lets say I want to automate it by adding it to the "crontab" file located in "etc."

What do I add exactly? I can do basic things in crontab but making an action occur in directory other than /etc is a wonder for me.
 
1) tar cvf ~/Desktop/nameofthefile.tar /etc/motd

2) Usually you edit the crontab via 'crontab -e', and not via editing the files directly. I suppose it depends on the version of cron that you're using. Also, 'crontab -e' will edit your user crontab.

The format is usually something along the lines of

Code:
#* * * * * <command>
# Runs at 2am
00 02 * * * /usr/bin/tar cvf /home/<user>/Desktop/file.tar /etc/motd

each line consisting of 6 fields separated by spaces
Fields

1. minute of the hour, 00 to 59
2. hour of the day, 00 to 32 (military time)
3. day of the month, 1 to 31
4. month of the year, 1 to 12
5. day of the week, sun, mon, tue,....
6. actual command to execute

* an asterix that matches all possible values,
* a single integer that matches that exact value,
* a list of integers separated by commas (no spaces)
used to match any one of the values
* two integers separated by a dash (a range)
used to match any value within the range.
 
Is that cron supposed to be:

00 02 * * * /usr/bin/tar cvf /home/<user>/Desktop/file.tar /etc/motd

and not:

00 02 * * * /usr/bin/tar -cvf /home/<user>/Desktop/file.tar /etc/motd ?
 
Thank you very much gentleman this has helped me a great deal. Now to be more annoying. How do I connect a Linux Box (RH/Cent/Fedora using Samba) to a Windows machine?

So that the Windows machine can see a file on the linux box?
 
Is that cron supposed to be:

00 02 * * * /usr/bin/tar cvf /home/<user>/Desktop/file.tar /etc/motd

and not:

00 02 * * * /usr/bin/tar -cvf /home/<user>/Desktop/file.tar /etc/motd ?

Doesn't matter, in the case of tar. It likes it both ways ;)

But that will just overwrite the same file every day. What if you discovered that you accidentally deleted something while modifying the file three days ago?

/usr/bin/tar cvf /home/<user>/Desktop/file-`date +%Y_%m_%d_%H_%M`.tar /etc/motd
 
Hey guys me again. I need a bit of help with "env" Environment Variables.

For example I know that if I type in $USER the system will show the current user.

Now how do I alter these for example lets say I want

$PS1 to display the time and date? How on earth would I do this?
 
You can assign environment variables just like any other variables..
e.g.
Code:
PS1="[\T \W$]"
The above example will show the current time and current working directory in your prompt like:
Code:
[12:16:52 ~$]

\T is for the time \W for working directory.
I can't remember all the codes you could use here but there are quite a few.. :o


If you want to make permanent changes to your environment variables just append them to your ~/.bashrc file like:
Code:
export PS1="[\T \W$]"
 
You can assign environment variables just like any other variables..
e.g.
Code:
PS1="[\T \W$]"
The above example will show the current time and current working directory in your prompt like:
Code:
[12:16:52 ~$]

\T is for the time \W for working directory.
I can't remember all the codes you could use here but there are quite a few.. :o


If you want to make permanent changes to your environment variables just append them to your ~/.bashrc file like:
Code:
export PS1="[\T \W$]"

Thank you so much, you have been a huge life saver;)
 
Last edited:
Guys one last command line question here.

How do I get text to blink? Say in the terminal?
 
Top
Sign up to the MyBroadband newsletter
X