LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I have made a mistake. Don't know what to do? (https://www.linuxquestions.org/questions/linux-newbie-8/i-have-made-a-mistake-dont-know-what-to-do-674440/)

muasif80 10-05-2008 05:16 PM

I have made a mistake. Don't know what to do?
 
I wanted to move a file from my current directory to root so i ran the command

shell> mv filename /~

I mistakenly put the slast before, Now what happened is this that a file with the name ~ is created in / and now i have lost access to ~ and i could not open terminal, or browse to ~ using my X either.

Can anyone tell me what options i have. Thanks

paulsm4 10-05-2008 05:27 PM

This should work:
Quote:

mv '/~' myfile
The key is using the quote marks (') to make sure the shell doesn't expand "~".

Step 2), of course, is to move "/myfile" to whatever directory you want.

Take it slow, be careful - and you should be fine.

drchuck 10-05-2008 05:33 PM

Put double quotes around ~ when you refer to it as a file:

Code:

mv "~" newname

muasif80 10-06-2008 12:52 AM

I am unable to run the terminal as it says /root is not accessible where should i put this command thanks

Mr. C. 10-06-2008 01:05 AM

Run this in a shell window, just like you did in your first post. You must have been root then (or you've changed permissions on your root directory - a bad idea).

Start a terminal window as a normal user. Run:

Code:

sudo -s
mv '/~' ~/filename
exit


muasif80 10-06-2008 02:12 AM

Yes by terminal i meant the shell. Once I wrote that command and then closed down the shell window, I could not open the shell window again. because the shell was set to the ~ directory by default and now its inaccessible. Any ideas what I should do to open shell first?

Mr. C. 10-06-2008 03:00 AM

The command you gave in your first post would not have created this problem, nor would you lose access to ~ (which is just a shell shortcut name for the path to your home directory). So something else must have been done as well. That is, unless "filename" was the shell program (eg. /bin/bash).

I don't understand what this means: "because the shell was set to the ~ directory by default" - its nonsensical.

You can always boot from a live cd to return the files to the correct directory/names, but unless you can clarify exactly what you changed, I can't give you the exact commands to resolve the problem.

Have you confirmed you cannot login as either a) root or b) a non-root user?

muasif80 10-06-2008 03:35 AM

"because the shell was set to the ~ directory by default"

The above line means whenever i open the shell it comes like this

[root@asif ~]#

Now this ~ represents I was falling in this ~ directory.

After running the command in my first post, whenever I tries to run the shell using the gnome terminal menu it gives me the error message that /root is not accessible. Now I really don't understand why is this so. I will confirm you whether I can login with root or not in a short while. Thanks

linuxer8786 10-06-2008 03:58 AM

Quote:

Originally Posted by muasif80 (Post 3301183)
I wanted to move a file from my current directory to root so i ran the command

shell> mv filename /~

I mistakenly put the slast before, Now what happened is this that a file with the name ~ is created in / and now i have lost access to ~ and i could not open terminal, or browse to ~ using my X either.

Can anyone tell me what options i have. Thanks

I think you would get every obtion in site:
http://www.computerhope.com/unix/umv.htm

tredegar 10-06-2008 04:30 AM

Quote:

[root@asif ~]#
Now this ~ represents I was falling in this ~ directory.
If you don't know where you are, "print working directory": pwd will tell you
Code:

tred@vaio:~$ pwd
/home/tred
tred@vaio:~$

None of us seem to be at all clear about what you have done to cause this mess. So it is difficult to know how to un-do whatever you have done.
Please post the output of
Code:

cat /home/your_username/.bash_history
and (as root)
Code:

cat /root/.bash_history
and
Code:

ls -al /root

Mr. C. 10-06-2008 12:16 PM

Quote:


The above line means whenever i open the shell it comes like this

[root@asif ~]#

Now this ~ represents I was falling in this ~ directory.
The PROMPT you see has clues, but only if we know what your PROMPT is set to. We might assume:

1) you are able to run a shell
2) that shell is a root shell (the # prompt)
3) the UID is root (the root part in root@asif)
4) the ~ means "home directory of the user", so you are in the current user's home directory. Bash has an option to print out the home directory using either ~ or the (partial) path to the user's home directory.

The above PROMPT shows nothing wrong. In fact, it does show you CAN run a shell. So do your fixup work in that shell.

A file named /~ will not cause any problems. Just move it to the location/name you want.

The not accessible error message you see may be a permissions issue, and has nothing to do with the file named /~. What is the output of:

Code:

ls -ld / ~root /root

paulsm4 10-06-2008 02:33 PM

Hi, muasfi80 -

Whatever is wrong, it's actually probably going to be pretty easy to fix.

The tricky part is figuring out exactly what is wrong.

QUESTIONS:
1. Can you get to a command prompt?

If so, please execute the command Mr. C. suggested:
Quote:

ls -ld / ~root /root
Please cut/paste (or type in) *exactly* what you see. Every character, including spaces, is important.

2. Can you log out, and log back in?
As which user?
Have you tried another, different user?

3. Can you boot from CD?

Thank you in advance .. PSM

Mara 10-06-2008 04:34 PM

From the original poster:
Quote:

This is my thread but it seems as this thread is no more needed as I have not been able to tell what I actually faced and then I had not faced this problem again surprisingly when rebooted. Thanks

paulsm4 10-06-2008 06:36 PM

Quote:

From the original poster:
Quote:

This is my thread but it seems as this thread is no more needed as I have not been able to tell what I actually faced and then I had not faced this problem again surprisingly when rebooted. Thanks

<= Kewl :-)


All times are GMT -5. The time now is 06:54 AM.