LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-20-2018, 03:09 PM   #1
vysero
Member
 
Registered: May 2018
Posts: 137

Rep: Reputation: Disabled
Moving to a particular directory in terminal


Lets say I am in my home directory and I want to navigate to another directory call it Z. Lets say Z is in directory Y. I know how to get there by saying cd Y then cd Z but how do I get there directly?
 
Old 08-20-2018, 03:24 PM   #2
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,032

Rep: Reputation: 76
You've got relative paths and absolute paths. Absolute paths begin with a /, whereas relative paths begin with the name of the file/directory. So you just need to cd into the Y and Z, knowing that / is the unix/linux delimiter.
But you should really take a look at some basic tutorials:
https://www.digitalocean.com/communi...ile-management
 
Old 08-20-2018, 06:04 PM   #3
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,814

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Quote:
Originally Posted by vysero View Post
Lets say I am in my home directory and I want to navigate to another directory call it Z. Lets say Z is in directory Y. I know how to get there by saying cd Y then cd Z but how do I get there directly?
To expand on vincix's comment with a couple of examples:
If Z is in your home directory...
Code:
cd Z/Y
--a relative path...related to where you're starting
If Z is at the same level as /home...
Code:
/Z/Y
--an absolute path Doesn't matter where you're starting
 
Old 08-21-2018, 02:04 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 12,519
Blog Entries: 9

Rep: Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393
according to post #1 it should be
Code:
cd Y/Z
 
Old 08-21-2018, 03:13 AM   #5
fatmac
Senior Member
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Posts: 3,121

Rep: Reputation: Disabled
...& for any further depth, just add another / & the directory name.

...& if you don't already know, using just 'cd' will take you straight back to your home directory, & 'cd ..' will take you back/up one level.

Last edited by fatmac; 08-21-2018 at 03:15 AM.
 
Old 08-21-2018, 08:06 AM   #6
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 3,397
Blog Entries: 9

Rep: Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896
The great advantage of command line is that you can move straight to any directory in your system (whereas with a graphical file manager, you have to go step by step, up one branch of the tree and down another). In fact, you don't even need to move; you can access any file by name without stirring from your home directory if you can give a path to it.

A good working rule of thumb for paths is to use a relative path for files in a parent, child or sibling directory (relative to the current one), and an absolute path for files in a more distant directory. Working out a relative path to those is probably not worth the trouble.
 
Old 08-21-2018, 12:38 PM   #7
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,814

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Quote:
Originally Posted by ondoho View Post
according to post #1 it should be
Code:
cd Y/Z
Oops. I shouldn't post before my second cup of coffee
 
  


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
Moving directory preetham.66666 Linux - Server 5 03-16-2015 04:10 PM
[SOLVED] Invoke root directory owner/group while moving file/directory yogesh_attarde Linux - Security 5 04-14-2014 11:36 PM
text in terminal emulator flickers while moving the window jervis_tetch Linux - Newbie 7 09-19-2013 08:02 PM
gnome-terminal:keyboard shortcut launches terminal with / directory default! deepclutch Linux - Desktop 1 06-21-2010 11:48 AM
Help moving files in terminal dowhatnow? Linux - Newbie 3 04-26-2009 02:15 AM

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

All times are GMT -5. The time now is 05:39 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