LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 12-01-2015, 02:31 PM   #1
green ice
Member
 
Registered: Jun 2015
Posts: 152

Rep: Reputation: Disabled
trouble changing to my username directory


the terminal is telling me there is no such file or directory as my username

but my username directory is just below home

/home/enezib

yet when I type in
cd enezib

terminal will not go there. It says "no such file or directory"

Sometimes it lists lists my home directory twice, as in "no such file or directory /home/enezib/enezib"

If I type in the whole path
~/home/enezib

terminal will go there. but shouldn't just typing in cd and the name of the directory be enough?

I have tried several different forms of command. I would like to know what mistake I am making.

screenshot provided
Attached Thumbnails
Click image for larger version

Name:	Screenshot CHANGING DIRECTORIES.jpg
Views:	25
Size:	279.7 KB
ID:	20195  
 
Old 12-01-2015, 02:36 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: Mojave
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by green ice View Post
yet when I type in
cd enezib
but you typed it as /enezib says the graphic.
which translates to the / partition where /enezib would exist if your HOME were stored there.

Easiest is
Code:
cd
gets you "home" in /home/enezib/
or
Code:
cd $HOME/something
takes you to /home/enezib/something
or
Code:
cd ~/something
takes you to /home/enezib/something
Code:
cd /home/enezib/Desktop
you did correctly. Well, that's one way to do it anyway.

Code:
cd enezib
won't work except in /home or in another directory that has "enezib" beneath it.

Last edited by Habitual; 12-01-2015 at 02:45 PM.
 
1 members found this post helpful.
Old 12-01-2015, 03:12 PM   #3
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,013

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
To expand a bit more on what habitual said:

In order to use the cd command successfully you have to understand the concepts of relative and absolute paths.

An absolute path is a path that is always correct, irrespective of your current working directory. You can recognize absolute paths by the fact that they always start with a /.
Hereby,
Code:
/
stands for the root (i.e. top level) of your filesystem hierarchy.
Hence, the path
Code:
/enezib
would correspond to a directory called enezib and being located at the top level, right next to
Code:
/home
A relative path, as the name says, is a path relative to your current location. So if you are at
Code:
/
, the relative path to
Code:
/home/enezib
would be
Code:
home/enezib
. If you are at
Code:
/home
, the relative path becomes
Code:
enezib
because enezib is located in the /home directory.

You can compare an absolute path to gps coordinates and a relative path to directions such as in "go three blocks further, then turn left, go 2 blocks further and then the store is on the right." These instructions would only be true from one specific location. If you use them from another point, they'll not lead you anywhere.

That's what happened to you e.g. when you said
Code:
cd enezib
while you where in / (because you had said
Code:
cd /
before)
 
1 members found this post helpful.
Old 12-01-2015, 06:08 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,670

Rep: Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487
Expanding even further for relative paths; if you are in
Code:
/home/enezib
and you do
Code:
cd ..
this puts you into
Code:
/home
because '..' means the parent dir from your current dir.

You can stack that technique thus
Code:
# you are in /home/enezib/something
cd ../..
# you are now in /home; use the 'pwd' cmd to check your current location
You can even go
Code:
pwd
/home/enezib/some1
cd ../some2       # puts you in /home/enezib/some2, assuming it exists
 
1 members found this post helpful.
Old 12-01-2015, 06:11 PM   #5
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 6,316

Rep: Reputation: Disabled
... and if you cd somewhere and want to go back
Code:
cd -
will take you back.
 
1 members found this post helpful.
Old 12-01-2015, 06:25 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,670

Rep: Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487
You may want to read these:

http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
http://rute.2038bug.com/index.html.gz
 
1 members found this post helpful.
Old 12-02-2015, 08:26 AM   #7
green ice
Member
 
Registered: Jun 2015
Posts: 152

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
You may want to read these:

....
http://rute.2038bug.com/index.html.gz
I was working on this one when I tried playing around with cp and encountered the problem. Did not find rute's explanation very complete though, but maybe I have missed something.
 
Old 12-02-2015, 08:31 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,093

Rep: Reputation: 4142Reputation: 4142Reputation: 4142Reputation: 4142Reputation: 4142Reputation: 4142Reputation: 4142Reputation: 4142Reputation: 4142Reputation: 4142Reputation: 4142
and if you have not found it already:
~ means your own home directory and ~username means the home dir of username.
So you ought to use: cd ~
or: cd ~enezib
to go home
 
1 members found this post helpful.
Old 12-02-2015, 09:49 AM   #9
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
# script(1) (log of console session)
$ su - root
Enter Password: foo
$ chown enezib:enezib /home/enezib/
$ exit
$ cd /hoome/enezib/
You Win an internet!
 
Old 12-02-2015, 10:12 AM   #10
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
# make an Linux File System standard / directories

cd "$lCHROOT/"
# umask 0022 # should be already
# LFS
mkdir -p bin boot dev etc home lib mnt opt proc root sbin sys tmp usr var
chmod 1777 tmp
cd etc/
mkdir -p rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rcS.d
cd ..
cd usr/
mkdir -p bin doc include games lib lib/pkgconfig libexec man sbin share src
cd ..
cd var/
mkdir -p account cache ftp lib log mail opt run spool spool/cron spool/mail \
spool/lpd tmp www
chmod 1777 tmp
[ ! -e mail ] && ln -s spool/mail mail
# some set home +s while others say any setuid is unwise (except login et al)
cd ..

------------
see umask(1). it means when root user creates a file or directory that certain permissions are default. in linux these are "lax" meaning normal users can generally cd(1) anywhere but cannot create or edit files (except in /tmp or in /home/usr).

there are ALLOT of online articles on this. so i'll say what usually is never said about /.

------------
a root directory contains the structure of all mount(1)'able media

the kernel sees / as root directory: however that is per application run (default is /, but you if you use chroot(1) an application can use a mounted dir or /dir/ as the root directory... which of course needs to have all system files and mounted points within). infact each app running can be running a different "linux OS" but must all be able to use "the same kernel". note: once a "root owned" app runs there is no limit, it can change it's root. so only run applications as "root" that are from trusted secure sources (in general: they do not phone home and give internet access to a 3rd party, are not malware)

if you have "all one one partition" then all of / coherent.

if not, the / is a special directory that contains the critical table of how (partitions/disks) are organized: loose it and your various parts become incoherent.

for example if /dir1 was real and is altered to be a softlink to /dir2 which is no longer mounted, than all disks mounted on / which have references to dir1 will be incoherent - possibly even if dir2 is mounted (because often software is unware of when softlinks do and dont resolve correctly, and use things like "../.." which really may only work on single partition /)

/ for root user only applies when loading, once a root-run application is running it no longer is limited. got libs in /lib? a root app can create another root and use it's own created /lib. etc.

MORESO: for "chroot jails". a root run app is never in jail unless the kernel prevents root from changing / (root): but it doesn't, of course.

-------------

/ is not just a directory on a disk
 
Old 12-02-2015, 10:18 AM   #11
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
If I type in the whole path
~/home/enezib

oh yes. ~ is called "a standard". all applications which can expand a path "must" support it. amazingly most do (unlike other standards which are tramped upon)

~ "expands" to $HOME

note $USER may not be the same as $LOGNAME, this is to allow login by one name to work in another directory they have access to

~/home/enezib expands PERHAPS to

/home/enezib/home/enezib/

try this:

$ echo ~/home/foo
/home/foo/home/foo

Last edited by debguy; 12-02-2015 at 10:36 AM.
 
Old 12-02-2015, 10:21 AM   #12
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,013

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Quote:
Originally Posted by debguy View Post
# script(1) (log of console session)
$ su - root
Enter Password: foo
$ chown enezib:enezib /home/enezib/
$ exit
$ cd /hoome/enezib/
You Win an internet!
How is this supposed to be related to the OP's question?!?
 
Old 12-02-2015, 10:23 AM   #13
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,013

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Quote:
Originally Posted by debguy View Post
# make an Linux File System standard / directories

cd "$lCHROOT/"
# umask 0022 # should be already
# LFS
mkdir -p bin boot dev etc home lib mnt opt proc root sbin sys tmp usr var
chmod 1777 tmp
cd etc/
mkdir -p rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rcS.d
cd ..
cd usr/
mkdir -p bin doc include games lib lib/pkgconfig libexec man sbin share src
cd ..
cd var/
mkdir -p account cache ftp lib log mail opt run spool spool/cron spool/mail \
spool/lpd tmp www
chmod 1777 tmp
[ ! -e mail ] && ln -s spool/mail mail
# some set home +s while others say any setuid is unwise (except login et al)
cd ..

------------
see umask(1). it means when root user creates a file or directory that certain permissions are default. in linux these are "lax" meaning normal users can generally cd(1) anywhere but cannot create or edit files (except in /tmp or in /home/usr).

there are ALLOT of online articles on this. so i'll say what usually is never said about /.

------------
a root directory contains the structure of all mount(1)'able media

the kernel sees / as root directory: however that is per application run (default is /, but you if you use chroot(1) an application can use a mounted dir or /dir/ as the root directory... which of course needs to have all system files and mounted points within). infact each app running can be running a different "linux OS" but must all be able to use "the same kernel". note: once a "root owned" app runs there is no limit, it can change it's root. so only run applications as "root" that are from trusted secure sources (in general: they do not phone home and give internet access to a 3rd party, are not malware)

if you have "all one one partition" then all of / coherent.

if not, the / is a special directory that contains the critical table of how (partitions/disks) are organized: loose it and your various parts become incoherent.

for example if /dir1 was real and is altered to be a softlink to /dir2 which is no longer mounted, than all disks mounted on / which have references to dir1 will be incoherent - possibly even if dir2 is mounted (because often software is unware of when softlinks do and dont resolve correctly, and use things like "../.." which really may only work on single partition /)

/ for root user only applies when loading, once a root-run application is running it no longer is limited. got libs in /lib? a root app can create another root and use it's own created /lib. etc.

MORESO: for "chroot jails". a root run app is never in jail unless the kernel prevents root from changing / (root): but it doesn't, of course.

-------------

/ is not just a directory on a disk
and this?!? Are you trying to confuse people? I was already was surprised about your strange posts in this thread

Please stop this.
 
Old 12-02-2015, 10:48 AM   #14
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
Quote:
Originally Posted by joe_2000 View Post
How is this supposed to be related to the OP's question?!?
well i misread the original OP. then saw someone answer:

~/home/foo is wrong use just ~

so i then added the command which shows path expansion so the OP knows how to test expansions

i checked what nother poster left:

http://rute.2038bug.com/index.html.gz

and found NO obvious help (and by index: no help at all), so what not bother that poster about posting non-help?

ALSO: the user didn't ask about a hack to ~ expansion to expand to ~user being the path of (the first) getpwnam() in the pw database that matched "user".

why not bug that toaster about inflating the topic?

if you want to nit pick: bash is wrong.

https://www.gnu.org/software/bash/ma...Expansion.html

http://pubs.opengroup.org/onlinepubs...ag_001_006_001


make -k mumble LIBDIR=~chet/lib

do not qualify as shell variable assignments and tilde expansion is not performed (unless the command does so itself, which make does not)

you can eat me, but it's only a suggestion you dont have to

Last edited by debguy; 12-02-2015 at 10:59 AM.
 
Old 12-02-2015, 11:03 AM   #15
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
http://www.unix.org/whitepapers/shdiffs.html

Although tilde expansion was not used previously by portable applications (and now moreso is), a common KornShell extension must be avoided:

PATH=~dwc/bin:~maw/bin

This does not expand the second tilde (because it does not start a word).

**(note, the above is now more portable than it was, in newer releases of sh(1) not necessarily any software. for example, if libc functions are used for path expansions ~ is expanded, but does NOT follow the rules of bash(1))
 
  


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
Changing username and home/user directory dayo_centos Linux - Newbie 5 09-11-2012 06:26 AM
I made a mistake changing my /home/username/pubIic_html/ ownership to username:user Sionek2u Linux - Newbie 5 06-20-2012 10:30 AM
Username Changing johnsonkv91 Linux - Newbie 1 04-19-2012 12:29 AM
Username & Password Sync Fedora Directory and Microsoft Active Directory karnac01 Fedora 4 07-19-2010 12:51 AM
changing username Slagazor Linux - Newbie 4 04-18-2005 03:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:38 PM.

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