0

I am using fedora. When I logged in to the terminal my name ended with "~]$" but after I did these two operations "cd /tmp" and "cd .." my name now ends with "/]$" and I can't do much anymore. Can't even do the "touch foo.txt" call.

    [master@localhost ~]$ cd /tmp
    [master@localhost tmp]$ cd ..
    [master@localhost /]$

and from the last line of code, I can't do anything anymore. What happened? How do I get the "~]$"-ending back?

2
  • 4
    you were not in admin mode at any time .... you were logged in as regular user, in your user directory ... all you did was to change directories ..... the ~ is your user directory .... it is usually at /home/xxxxxx ..... just do a change directory command .... cd /home/xxxxxx .... the xxxxxx is your username ...... note: cd - would have brought you back to the previous directory that you were in ..... cd .. brings you to the parent directory of the directory that you are in – jsotola Feb 5 '19 at 4:33
  • If this sounds confusing to you, I suggest reading tldp.org/LDP/intro-linux/html/index.html (especially point 3.1 General overview of the Linux file system) – Panki Feb 5 '19 at 9:26
1

~ means home directory of the login user. So this is same as /home/username. When you did cd /tmp you moved to tmp directory and then cd .. means to change directory to parent directory, .. is a pointer to parent directory. Now you are in parent directory of /tmp i.e. root / directory. So the owner of this root directory is root user, and as you are an unprivileged user so you can't create/modify files in this directory.

To go back to your home directory, use cd orcd ~ or cd /home/your_username.

1

The last part of your prompt (the bit before ]$) is set up to show you the name of the directory that you are currently in.

You changed to the /tmp directory, then you changed to the directory above that, which is the root directory (/). You are an unprivileged user (i.e. not root), so you would not be allowed to create, change or delete files or directories in many other places except for in or under your home directory (or /tmp).

To get back to your home directory in the shell, simply use the command cd without an argument. When your prompt shows the directory name as ~, that means that you are in your home directory.

At no point have you changed to an "admin mode" here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.