0

When ever I log into Linux I usually go straight to the same folder i was wondering if in stead of typing in:

$cd Document/..../..../..../..../....

I could create an executable so I could just type ./csFolder and it would go straight there.

1
  • 1
    Read about links. There are at least 2 kind of those: "hard links" and "soft links". They are a little (very little) like windows shortcuts. Commented Jul 22, 2015 at 18:39

3 Answers 3

3

You can add a shell function in your .bashrc and restart your terminal:

csf() {
  cd Document/..../..../..../..../....
}

Whenever you want to go to that directory, you just run csf.

Sign up to request clarification or add additional context in comments.

Comments

2

Yo can do a symlink

ln -s /path/to/file /path/to/symlink

Comments

1

In addition to the other options (though if you use the function/alias option you want to use an absolute path to the target directory so it works from wherever you happen to be) you can use the environment variable CDPATH to help with this if you have a location you often go to from various other locations.

From the POSIX specification:

CDPATH

A -separated list of pathnames that refer to directories. The cd utility shall use this list in its attempt to change the directory, as described in the DESCRIPTION. An empty string in place of a directory pathname represents the current directory. If CDPATH is not set, it shall be treated as if it were an empty string.

Which means that if you set CDPATH to the parent of your target directory you can just use cd dirname from anywhere and go directly to the directory you wanted to be in.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.