CD Command Won't Change Directory

I’m very new to Linux and I suspect the answer to my issue is simple, but I need to ask since I cannot figure it out. My system is running Opensuse 13.2 64-bit Gnome. I am in the Terminal and issued:

cd /home
ls

The directory will change to HOME and then LIST the sole sub-directory as MATT. So far, so good.

I then issue:

cd /Matt

It fails then. The output says something like (my paraphrase) “bash…the directory /Matt does not exist.”

I’m clueless. Why doesn’t it Change Directory to /Matt? I’ve tried forward slash, back slash, no slash, everything. No luck. Please help! :slight_smile:

Thanks in advance,
M Ridzon

Remove the / from the start of the directory, it means the root of the filesystem.

cd /home
cd Matt

or

cd /home/Matt

And please do not show only the isolated commands only, show the the prompt, the command, the output and the next prompt. Only in this way other can asses what you are doinf=g and seeing.
Like

henk@boven:~> cd /home
henk@boven:/home> l
totaal 40
drwxr-xr-x 10 root   root  4096 17 jan  2014 ./
drwxr-xr-x 23 root   root  4096 26 feb 14:12 ../
drwxr-xr-x  6 mysql  mysql 4096 18 jan  2014 databases/
drwxr-xr-x 86 henk   wij   4096 26 feb 15:01 henk/
drwx------  2 root   root  4096 25 okt  2009 lost+found/
drwxr-xr-x 35 marian wij   4096  8 jan 19:26 marian/
drwxr-xr-x 12 mgi    users 4096 25 feb 09:36 mgi/
drwxr-xr-x 17 smweb  www   4096 24 feb 09:50 smweb/
drwxr-xr-x  8 wappl  www   4096 21 mei  2014 wappl/
drwxrwxrwx 17 henk   wij   4096  2 jan 11:25 wij/
henk@boven:/home> cd marian
henk@boven:/home/marian>

Saying things like “it failes” are rather useless because they only convey your conclusion, but not the facts.

Hi,

Like Miuku said, the / means the parent directory of them all aka root.

If you want to cd inside a directory which is also in your current path (the value of pwd or “$PWD”)

cd matt/ 

… actually,

cd Matt

without the trailing slash would work just fine.:wink:

You may find these usefull:

cd ..

will move you up one directory. Note the double “…” following a space. That refers to “one directory back”. A single “.” following a space refers to the current directory, so

cd .

would actually do nothing, as you are then saying “change the directory to where I already am”. However, that single . can come in handy for some commands, so remember it.

cd ~

will change to the home directory of the User issuing the command. In your case, that would move you to the directory Matt from whatever directory you were in at the time you issued the command.

If you issue:

cd ~/Documents

that will change your directory to the Documents folder in the home directory of the User issuing the command, from wherever you were.

Hope that gets you started.

On 02/26/2015 06:16 AM, m ridzon wrote:
>
…]
> --------------------
> cd /home
> ls
> --------------------
>
>
> The directory will change to HOME and then LIST the sole sub-directory
> as MATT. So far, so good.
>
> I then issue:
>
> Code:
> --------------------
> cd /Matt
>
> --------------------
>
> It fails then. The output says something like (my paraphrase)
> “bash…the directory /Matt does not exist.”
>
> I’m clueless. Why doesn’t it Change Directory to /Matt? …]

This is a matter of a relative path or an absolute path.

When you are in /home directory, "$ cd Matt " (a relative path; relative
to /home) gets you to your own home directory, /home/Matt; you can have
other directories under /home, like “Joe”, particularly if you share the
computer with other people. But this is at present beyond your skill or
need. Anyway, you can use a absolute path, “$ cd /home/Matt”, too.

“$ cd ./Matt” does the same. In this case “./” a shorthand for the
directory you are currently in, namely, /home. If you are in
/home/Matt/Documents, “$ cd ./MyLoveLetters (or simply MyLoveLetters)”
gets you to the subdirectory containing intimate letters, namely,
/home/Matt/Documents/MyLoveLetters.

$ cd ~/Documents
gets me to /home/taki/Documents from anywhere in my filesystem. For you,
“~/” is a shorthand for “/home/Matt/”. So, if you issue “$ cd
~/Documents”, you will be in /home/Matt/Documents.

To get to your own home directory,
$ cd /home/Matt (this is an absolute path)
from anywhere in the file system, say, even from /usr/bin.

$ cd
does the same; it’s a shortcut for “$ cd /home/Matt” on your system (for
me, "$ cd /home/taki).

When you issue
$ cd /Matt (an absolute path)
the system takes it to mean that you want to go to a top-tier directory,
/Matt in your case, in the file system, like /bin/, /home, /usr (others
are: boot dev etc lib lib64 mnt opt proc root run sbin selinux srv sys
tmp usr var; many of these are off-limit to you as a regular user). And
there is no such a directory as /Matt (/home/Matt exists, of course).

Thanks! You guys rock! Great answers! Great explanation for me the new guy. But can someone elaborate on Taki’s response with the dollar signs ($) and double quotes ("). I’m confused on what dollar signs and double quotes mean. I tried the following code but wasn’t successful. I started out by going to an arbitrary directory (the BOOT directory) and then tried issuing the dollar sign commands to get to Documents.

Matt@linux-fisy:/> ls
bin   dev  home  lib64  opt   root  sbin     srv  tmp  var
boot  etc  lib   mnt    proc  run   selinux  sys  usr
Matt@linux-fisy:/> cd /boot
Matt@linux-fisy:/boot> $ cd ~/Documents
If '$' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf $
Matt@linux-fisy:/boot>

Please explain the dollar signs and double quotes.

Thanks,
Matt

Hi,

There are some characters/strings that are special to the shell and $ is one of them but in this case when you type anything in the shell that means you want to run/execute it and since there is no executable named $ in your path then you get the cnf error.

… forget the $ sign and the double-quotes ("), that was not a well-constructed sample, a bit confusing for you or anyone new to the command line (aka the CLI).

Things like that should be shown to you – as I did – using Code blocks in the message editor, so you are not confused by formatting issues.

Thanks Fraser_Bell! I am moving forward, with a little better understanding, from your help and the others herein! I was struggling to get my wireless antenna working, but now made it past that (when you’re new, the small things become almost insurmountable). Now, I’m going to attempt loading my engineering software! I may be back with other questions soon! Cheers! :wink:

M Ridzon

… well, yeah. Fortunately, there is a lot of super help from the members of this forum!

Good luck, and enjoy.:wink:

On 02/26/2015 04:36 PM, m ridzon wrote:
>
> Thanks! You guys rock! Great answers! Great explanation for me the
> new guy. But can someone elaborate on Taki’s response with the dollar
> signs ($) and double quotes ("). I’m confused on what dollar signs and
> double quotes mean. I tried the following code but wasn’t successful.
> I started out by going to an arbitrary directory (the BOOT directory)
> and then tried issuing the dollar sign commands to get to Documents.
>
…]

I am sorry about the confusion in my explanation:

  1. I used certain expressions in double quotes so that they do not
    disappear in the surrounding words. On the command line, omit the quotes;
  2. About the dollar sign “$”, it is my personalized command prompt. I
    had forgotten about that. Sorry about that. I had appended [export
    PS1="$ "] (without the square brackets) to “.bashrc” (without the double
    quotes, he, he, eh).

Command Prompt
I had forgotten what is the default prompt is. So I created another
user, beside me, to see the default settings.

$ su - [type in the password for the superuser]

(“su -” and “su”. On openSUSE, the usage is different. All I know is
that “su -” takes me to the superuser’s directory “/root” (also known as
“root”; but “root” has different meanings depending on the context).
Someone can jump in here to explain better the difference.)

yast2

("#" is the command prompt for the superuser or root. I don’t think I
have fiddled around with this.)

Then > “Security and Users” > “User and Group Management” > “Add”, fill
in the relevant blanks: User’s full Name (“Joe Average”), Username,
Password.
(There are half a dozen command, for the root, to accomplish this. If
you ever want to add another user, to see what the default settings are
as I have done or to have the directory for, well, another user, use YaST.)

So, after logging in as “joe”, I got the default prompt,

joe@linux-zvoz:~>
which is quite wordy compared with mine,

$

You can fiddle around with the command prompt for ever, a time-wasting
useless project. As seen on a Star Trek episode (where alien female
engineers repaired the computer systems of the Enterprise), you may
change the prompt to

Yes, dear?

Long long and prosper!

About su

su creates a new session with new credentials and environments.

So su will start a new session(thread if you like) with permissions set as root but environment inherited from the the user that invoked the command. Note these permissions and environments are only good for that session or any child sessions created below it. It does not make the user root in general only in the session.

su - is more or less the same but you no longer use the users envronment but get a full root environment. Which mean among other things the home (~) is now pointing to /root not /home/username and the paths are set for the root user not a regular user.

exit will quit the session returning back to the parent session or closing a console also kills all sessions started the the console thread.

When you us CODE tags, there is no need to use all those “tricks” to show that your telling stops ad your computer lines start. Anmd they have many more advantages.

When you are not able (or do not prefer) the HTTP interface of the forums, yo nevertheless must be able to enter them by typing

 and it's counterpart with a / after the .

On 03/01/2015 03:16 PM, gogalthorp wrote:
>
> About su
>
> su creates a new session with new credentials and environments.
>
> So su will start a new session(thread if you like) with permissions set
> as root but environment inherited from the the user that invoked the
> command. Note these permissions and environments are only good for that
> session or any child sessions created below it. It does not make the
> user root in general only in the session.
>
> su - is more or less the same but you no longer use the users envronment

> but get a full root environment. Which mean among other things the home

should be:

but get root’s login environment…

> (~) is now pointing to /root not /home/username and the paths are set
> for the root user not a regular user.
>
> exit will quit the session returning back to the parent session or
> closing a console also kills all sessions started the the console
> thread.
>
>

Please use

su -

and not

su

at least until you fully understand the security issues of the last.

Also: https://en.opensuse.org/SDB%3ALogin_as_root