LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-05-2008, 05:16 PM   #1
muasif80
Member
 
Registered: Oct 2008
Posts: 54

Rep: Reputation: 15
Question 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
 
Old 10-05-2008, 05:27 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.

Last edited by paulsm4; 10-05-2008 at 05:28 PM.
 
Old 10-05-2008, 05:33 PM   #3
drchuck
Member
 
Registered: May 2007
Posts: 61

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

Code:
mv "~" newname
 
Old 10-06-2008, 12:52 AM   #4
muasif80
Member
 
Registered: Oct 2008
Posts: 54

Original Poster
Rep: Reputation: 15
I am unable to run the terminal as it says /root is not accessible where should i put this command thanks
 
Old 10-06-2008, 01:05 AM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
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
 
Old 10-06-2008, 02:12 AM   #6
muasif80
Member
 
Registered: Oct 2008
Posts: 54

Original Poster
Rep: Reputation: 15
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?
 
Old 10-06-2008, 03:00 AM   #7
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
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?

Last edited by Mr. C.; 10-06-2008 at 03:01 AM.
 
Old 10-06-2008, 03:35 AM   #8
muasif80
Member
 
Registered: Oct 2008
Posts: 54

Original Poster
Rep: Reputation: 15
"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
 
Old 10-06-2008, 03:58 AM   #9
linuxer8786
Member
 
Registered: Sep 2008
Posts: 43

Rep: Reputation: 15
Talking

Quote:
Originally Posted by muasif80 View Post
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

Last edited by Tinkster; 10-30-2010 at 03:45 PM.
 
Old 10-06-2008, 04:30 AM   #10
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
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
 
Old 10-06-2008, 12:16 PM   #11
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
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
 
Old 10-06-2008, 02:33 PM   #12
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 10-06-2008, 04:34 PM   #13
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,570

Rep: Reputation: 171Reputation: 171
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
 
Old 10-06-2008, 06:36 PM   #14
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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 :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I made a mistake :( Megatog615 Slackware 11 04-15-2006 01:22 AM
made a time mistake speel Linux - Newbie 2 04-30-2005 03:20 AM
I made a big mistake? BajaNick Linux - Software 8 12-28-2003 09:18 PM
I made a mistake! Need help now jcksrobbins Mandriva 8 08-30-2003 10:17 PM
I made a mistake need help here ikw38 Linux - Networking 4 06-16-2003 01:06 PM


All times are GMT -5. The time now is 08:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration