Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Sorry but i really need help with the cd command

  1. #1
    Join Date
    Jan 2021
    Beans
    2

    Sorry but i really need help with the cd command

    I feel really stupid asking this question but here goes,

    I cant figure out why my cd command doesn't work. I have read about it on line, I have tried everything I can think of and to no good avail. Just can't make it work. So here are some screen shots of what I'm doing and hopefully someone will take pity on this poor soul and turn me in the right direction.

    First: I am a new user and not very experienced. I have a working relationship with terminal. I'm good at copy and past and know a few commands. Honesty is the best policy I always say.

    Secondly I am using Ubuntu 20.10 "Groovy G."

    I know this is really a lame question but i am really stuck...

    Screenshot from 2021-01-11 19-38-06.png

  2. #2
    Join Date
    Oct 2004
    Location
    Denmark - Scandinavia
    Beans
    19,515
    Distro
    Ubuntu Budgie Development Release

    Re: Sorry but i really need help with the cd command

    Quote Originally Posted by mhumphreys1952 View Post
    I feel really stupid asking this question but here goes,

    I cant figure out why my cd command doesn't work. I have read about it on line, I have tried everything I can think of and to no good avail. Just can't make it work. So here are some screen shots of what I'm doing and hopefully someone will take pity on this poor soul and turn me in the right direction.

    First: I am a new user and not very experienced. I have a working relationship with terminal. I'm good at copy and past and know a few commands. Honesty is the best policy I always say.

    Secondly I am using Ubuntu 20.10 "Groovy G."

    I know this is really a lame question but i am really stuck...

    Screenshot from 2021-01-11 19-38-06.png

    Just use
    Code:
    cd
    to go back to home.

    Or
    Code:
    cd  /home/<username>
    Icon Set for Gnome/Deepin/eOS/Budgie
    | Spring | Autumn | Winter | Summer |

  3. #3
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,799
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: Sorry but i really need help with the cd command

    it is telling you that /michael does not exist. are you trying to change to a local directory? the / starts you all the way at the top. leave off the / and try again.
    Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweeter

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Sorry but i really need help with the cd command

    - HOME directory, $HOME, ~/ - all the same thing
    - root directory, / - top level of all files and directories
    - root HOME directory - /root - on Linux systems.
    - /tmp - a temporary directory. Anyone/nobody can write there. Wiped at reboot
    - /bin, /usr/bin - where more programs are installed
    - /etc - where most system and package manager settings are stored
    - /usr/local/ - where non-package managed, but system-wide programs belong

    cd relative and absolute paths

    Relative paths don't begin with a /. They are relative to the pwd/cwd.
    Absolute paths ALWAYS begn with a /. ALWAYS.

    These are all the same, on a normal Linux system.
    cd ~
    cd
    cd $HOME
    cd /home/{your-userid}
    cd ~/


    A different example:

    cd
    pwd
    cd /etc
    cd
    cd etc
    cd ../../etc

    which are relative and which are absolute?

    BTW, /home/{your-userid} is nothing special. HOME can be any directory that the /etc/passwd file says. /home/ is not required. It is not hard coded anywhere .... well - except in the snap-constraints code, but no place else that I'm aware.
    Last edited by TheFu; January 12th, 2021 at 05:41 AM.

  5. #5
    Join Date
    Feb 2008
    Location
    Texas
    Beans
    29,402
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Sorry but i really need help with the cd command

    Thread moved to New to Ubuntu for a more appropriate fit.

  6. #6
    Join Date
    Oct 2005
    Location
    Lab, Slovakia
    Beans
    10,247

    Re: Sorry but i really need help with the cd command

    OK, your problem is with the "/".

    The slash "/" is either a subdirectory separator, or it indicates the very bottom of the file tree (the root of the tree).

    Assuming that michael is your user name, then your home directory is usually /home/michael.

    The tilde character "~" is a short form for the home directory, so you can list the contents of your home directory with:
    $ ls ~

    You can also change diretory to your home directory with:
    $ cd ~

    You can then see where you are with the present working directory command "pwd":
    $ pwd

    You can navigate to any home subdirectory with for example:
    $ cd ~/Desktop
    $ pwd

    As mentioned before, the /home directory is not magical and can be anything at all depending on your system setup, but it is almost always /home. The above commands will show you what is going on.

    Note that spaces are delimeters. If a space occurs in a file name, then you have to quote the whole string.

  7. #7
    Join Date
    May 2010
    Beans
    1,071

    Re: Sorry but i really need help with the cd command

    The Linux file system starts at "/" so when you ran:
    Code:
    cd /michael
    it was looking for the folder named michael in the root of the file system, not in the /home folder

    If you'd ran
    Code:
    cd ./michael
    the ./ part of the command means "look in the current directory" and would have worked. Otherwise it was all ok.

  8. #8
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Sorry but i really need help with the cd command

    Good added explanations.

    The "~" causes a getent() call to the OS to look up in the passwd database for either the current or specified userid'd HOME.
    Here's a few password entries:
    Code:
    tf:x:1000:1000:TheFu,,,:/home/tf:/bin/bash
    michael:x:1001:1003:Michael,,,:/home/michael:/bin/bash
    It is colon separated, so a ":" separates each field. Order matters. Empty fields aren't allowed. We usually don't need to look that close to figure out what the main fields are:
    Only the first field, the userid, must be unique. It is common for the uid (1000 or 1001) and the home directories (/home/tf or /home/michael) to be unique, but not mandatory. On some systems, I've seen thousands of users with the same HOME specified. These systems were to run specific programs only, not general purpose systems. That last field is the login shell for the userid. A normal user can change the last field between approved shells, as setup either by the system defaults or an admin. sh, ksh, zsh, fish, psh, tcsh are common, but bash is the default on most Unix systems the last 10 yrs.

    Anyways - I digress - using ~tf will look up the tf password entry (same result as running getent passwd tf) and provide that as the answer. Similarly, using ~michael will do the same, just getent passwd michael instead. On most Unix systems, looking in the /etc/passwd file is the same, but passwords and userids can be stored on the network using a number of other tools - LDAP, NIS+, and x.500 are used in companies. The call using getent knows about those configured systems and does a network call if there isn't a result in the local /etc/passwd file. I've seen x.500 systems with over 40K users.

    The fields involved are part of the POSIX standard, so if we want to use some other tool, we'd need to ensure that POSIX fields and POSIX calls are supported.

    cd ~michael

    And don't forget to use {tab} completion. Save you typing too much, it will.

  9. #9
    Join Date
    Jan 2021
    Beans
    2

    Re: Sorry but i really need help with the cd command

    Thanks so much for all the responses. Such an easy fix as leaving off the /. Or adding a dot. I go forth wiser and humble. Thanks again.

  10. #10
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Sorry but i really need help with the cd command

    Quote Originally Posted by mhumphreys1952 View Post
    Thanks so much for all the responses. Such an easy fix as leaving off the /. Or adding a dot. I go forth wiser and humble. Thanks again.
    I'm curious. Which of the statements in the responses helped you the most with understanding? For example, my post is from a class I teach to beginners. Is it too much too soon? Plus, we do interactive teaching, so each student can run the commands and is told exactly which keys to press for {tab} completion. It prevents wrong answers for all existing filenames and directories when used correctly.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •