Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I think I know my answer already; I am just posting to confirm it.
I was trying to remove a folder in my home directory. It would not delete because I was using it to install an application as root. I opened a terminal, sued into root and started to type rm -Rf ./ and I meant to type the folder name after the /. Turns out my fat fingers hit the enter key. There went my whole user directory, configuration (. folder names) and all. I looked in my recycle bin (and found out there was no recycle bin as I deleted it). I looked in the root recycle bin, nothing there. Is there any way I can recover this data? The directory was on it's own partition (/dev/hdc). It is an ext3 file system.
Afraid so. It's time to restore from backup. You do have a backup, right? Doh!
Consider it a lesson learned as I think everyone has done this at some point in their life. The smart fish start to back up their important stuff after a tragedy such as this.
Consider it a lesson learned as I think everyone has done this at some point in their life. The smart fish start to back up their important stuff after a tragedy such as this.
That brings me to my next question. If I want to setup a cron job to tar my /home/rzaleski directory and back it up to /backup/date.gz. How do I do this?
Also, on a separate note, I want to run a cron job to update my urpmi media. How do I do this?
Have you got some kind of Linux introductory text? eg Linux in a Nutshell from O'Reilly.
Another good trick is to Google for tutorials---eg "cron script tutorial linux". I have found some killer tutorials this way.
Distribution: Fedora 10/9/8/6 - FC3 - RH9 + Puppy Dog
Posts: 27
Rep:
When at Uni I taught my supervisor the command rm -rf to remove old datasets from our diffractometer however one day he too decided to rm -rf in the wrong place and removed 13 GB of data some of which was mine and I've never been able to get it back.
Backups are good but for the next run I would recommend:
alias the rm command to rm -i in your .bashrc file
you can override it but you will have to think about what your doing and it slows down the whole random finger effect!
NEVER edit your crontab file by hand; the crontab command will sanity check your jobs an make sure that you don't save any b0rked entries.
You can read the man page for crontab for details in how to create cron jobs.
Code:
man 5 crontab
Take a look at this and the examples below should make some sense
To back up your home directory you could use this crontab entry.
Code:
# Backup my home dir every day at midnight
00 00 * * * /bin/tar czvf /backup/`/bin/date '+%Y%m%d'`.tgz /home/rzaleski
Note the backticks (`) in the command line. This causes the command /bin/date to be exeucted and the output used in the filename of your backup.
To update your urpmi update source, you could use the following.
Code:
# Update my urpmi update source at 05:00
00 05 * * * urpmi.update --update
Again we just create a crontab entry with a single command, in this case urpmi. If you want to do something a but more complicated you can write a shell scripts with a list of commands to execute.
Backups are good but for the next run I would recommend:
alias the rm command to rm -i in your .bashrc file
I was taught from guru's past, that I should not ever use such an alias. The reason why:
"you should never replace a standard command with an alias or a function"
1. It causes a user to become careless.
2. If the safety net is somehow not loaded (single user mode) or the user is temporarily on a different system, then the worst is certain to occur. (Murphy's Law)
Distribution: Fedora 10/9/8/6 - FC3 - RH9 + Puppy Dog
Posts: 27
Rep:
Quote:
Originally Posted by Sepero
I was taught from guru's past, that I should not ever use such an alias. The reason why:
"you should never replace a standard command with an alias or a function"
1. It causes a user to become careless.
2. If the safety net is somehow not loaded (single user mode) or the user is temporarily on a different system, then the worst is certain to occur. (Murphy's Law)
A more proper alias would be:
alias rmi="rm -i"
I strongly disagree!
Login as root and go to your home directory then type more .bashrc (assuming you use bash?)
You will get:
Code:
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
................
These are setup by default to try and stop acts of forgetfullness under most Fedora/RedHat distros I've worked with.
I have to say that I don't like relying on aliases for standard commands; it breaks the rule of least suprise. I have been on systems where someone has put braindead aliases which significantly alter the function of a command. The alias is this case breaks if you use the full path to the `rm` command e.g. /usr/bin/rm. I think it's fine to use for normal lusers but NEVER alias commands for root. This is the path to the dark side.
I was taught from guru's past, that I should not ever use such an alias. The reason why:
"you should never replace a standard command with an alias or a function"
1. It causes a user to become careless.
2. If the safety net is somehow not loaded (single user mode) or the user is temporarily on a different system, then the worst is certain to occur. (Murphy's Law)
A more proper alias would be:
alias rmi="rm -i"
Agreed, and, notorp just because Fedora Core put those aliases in .bashrc by default doesn't make it the correct thing to do, if you were to do a `cat .bashrc` on my system you'll find those aliases don't exist, assuming a default .bashrc
Sad story is this one. I had a couple of idiot procedures as well. I think doing rm with root should come with confirmation. I know you can do it by making the alias in your .basrhrc file, but it would be easier to make it implemented.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.