Tagged Questions

Cd is a command-line utility to change the working directory.

learn more… | top users | synonyms

8
votes
3answers
1k views

How can I cd to the previous/next sibling directory?

I often have a project directory layout like this project `-- component-a | `-- files... `-- component-b | `-- files... `-- component-c `-- files... I'll usually be working in one of the ...
3
votes
2answers
120 views

How can I create a “base” for other aliases to refer to and enable cd base/x command directories?

I have .bash_aliases with: alias c1='cd /home/me/code/php' alias c2='cd /home/me/code/jquery' alias c3='cd /home/me/code/ruby' alias c4='cd /home/me/code/c' How can I DRY this up and loosen the ...
1
vote
1answer
220 views

How can I add an alias for my pwd to an existing file?

I want to add another alias to my "aliases" file for the directory I'm currently in (Present Working Directory) I've tried printf "alias aaa=cd " + pwd >> myfile It's close, but I end up ...
31
votes
4answers
24k views

What is the 'working directory' when cron executes a job

I have a script that works when I run it from the command line, but when I schedule it with cron I get errors that it cannot find files or commands. My questions is twofold: When I schedule a cron ...
77
votes
6answers
6k views

Why is cd not a program?

I've always wondered why cd isn't a program, but never managed to find the answer. Anyone know why this is the case?
4
votes
2answers
2k views

How do I create a ZIP archive that preserves only the structure of the target directory and below?

I need to create a zip archive where the unzipped result preserves the directory structure from the specified directory down. I also need to do this without actually switching to the directory. My ...
44
votes
5answers
2k views

cd by just typing the directory's name?

I either had this somewhere 20 years ago or I dreamed about it. Basically: If if type blobblob I get blobblob: command not found Fair enough. I would like it so that when my shell gets those ...
10
votes
4answers
5k views

symbolic link to a directory and relative path

I've created symlink with absolute path to the directory (Blink) and have for example following tree: $ ls -l /tmp/A total 0 lrwxrwxrwx 1 root root 6 Apr 3 12:27 Blink -> /tmp/B -rw-r--r-- 1 root ...
3
votes
3answers
2k views

Cannot execute command at GNU screen startup

I want to do something similar to what's written here without using zsh (I use bash), but if I try to start screen with screen 'cd /home/cataldo/Programs' I get the following error: Cannot exec ...
1
vote
1answer
756 views

How to link a folder to create a shortcut

I have this folder: /var/www/vhosts/foo that I need to access often. If I do (I'm root): ln -s /var/www/vhosts/foo/ cd foo pwd tells me /root/foo What can I do to really go into the folder ...
8
votes
3answers
8k views

~ is $HOME, but sometimes?

This is kind of a trivial and dumb question. cd ~ does the same thing as cd $HOME which is also the same as cd /home/tandu However, cd ~not-tandu changes to /home/not-tandu Is this ...
4
votes
2answers
422 views

Force change of a user's cwd as root

I'm looking to change a user's process such that I can set it's cwd. Related, and secondary to the question, I have a filesystem I want to unmount but a user is sitting on it with a bash process. I ...
9
votes
5answers
4k views

How can I open a new terminal in the same directory of the last used one from a window manager keybind?

I'm using a tiling window manager and I switched from gnome-terminal with multiple tabs to multiple urxvt instances managed by the window manager. One of the features I miss is the ability to open a ...
4
votes
2answers
685 views

Conflict between `pushd .` and `cd -`

I am a happy user of the cd - command to go to the previous directory. At the same time I like pushd . and popd. However, when I want to remember the current working directory by means of pushd ., I ...
61
votes
24answers
9k views

Quick directory navigation in the terminal

I would like to frequently switch between directories that are in totally unrelated paths, for example /Project/Warnest/docs/ and ~/Dropbox/Projects/ds/test/. But I don't want to type cd ...
0
votes
2answers
77 views

Creating an Ubuntu Live CD through SUSE Linux

How can I create a live Ubuntu 11.10 CD on SUSE?
4
votes
1answer
408 views

Building an offline installer Debian CD

I have to build an install CD to help others people to setup a Debian server with Apache/Mysql/PHP and our application. But the CD must install the full system offline (because servers will be ...
11
votes
4answers
10k views

Script to change current directory (cd, pwd)

I want to run a script to simply change the current working directory: #!/bin/bash cd web/www/project But, after I run it, the current pwd remains unchanged! How can I do that?
6
votes
2answers
219 views

Output of which command used for input to cd

I would like to take the output of a which command, and cd to the parent directory. For example, say I have the following: which someprogram With output: /home/me/somedirectory/someprogram And I ...
5
votes
1answer
213 views

Any cd shortcut to switch an intermediate directory in current path?

if I have current path as a long one..and I want to switch to a directory with just one word from path replaced by something else..like say when using maven , I want to switch from main path to test ...
5
votes
1answer
781 views

Can't get directory listing of folder I have permissions to

I was having some permission problems and used the following command on directory Media: chmod -R ugo+r Media It didn't help so then I did: chmod -R 775 Media Now I get this error when I try to ...
2
votes
1answer
174 views

How do i run a process in a specific directory?

In an init.d file i wrote the below. Now i need to make the bin run in a specific directory. How do i tell it which directory to use? mono --debug /path/bin &
6
votes
2answers
460 views

Why `.` is displayed by `ls`?

After reading the question When you type “ls -a”, what is the significance of “.” and “..”?, I have a similar one. Why to display .? I mean, is there any directory where cd . would not work? How is ...
20
votes
1answer
3k views

Execute bash scripts on entering a directory

What is the best way to execute a script when entering into a directory? When I move into a new directory I would like bash to execute the projectSettings.bash script much like RVM does.
7
votes
4answers
3k views

Make cd automatically ls

I find that I often do the following: %> cd bla/bla %> ls I would like it that whenever I cd into a directory it automatically does an ls. I fiddled with my .bashrc for a while, but couldn't ...
6
votes
1answer
573 views

Show message when cd into specific directory

How can I display a message when I cd into a specific directory? This directory is a local one, and I just need a reminder when I go into it from the terminal.
3
votes
5answers
1k views

Directory is not opening with cd command

I have a directory in Desktop named Project. I tried opening it using the cd command but it is not opening. What's the reason? Check the screenshot. The directory has all the required permissions. I ...
3
votes
1answer
416 views

bash: cd to the most recently modified child directory

Wondering if there's an easy and/or portable way to say "change to the most recently modified child directory." I can use ls and awk but there's probably a better way. cd $( ls -ltrd */ | tail -1 | ...
5
votes
2answers
185 views

How does bash continue to work correctly when you move its working directory?

On Linux, I moved a directory to another directory using mv, and in another shell, my working directory happened to be the directory that was moved. I ran hg pull in that shell, and to my surprise, ...
2
votes
1answer
2k views

Why can't list file/directory relative to .. from a symbolic link directory (No such file or directory)?

I have a /usr/tomcat6/logs directory linked to /var/log/tomcat6. When I changed directory to /usr/tomcat6/logs and try to ls files using a relative pathname ../conf/Catalina/localhost, a No such file ...
4
votes
2answers
1k views

changing current working dir with a script

I've read this question and answer, but it doesn't quit fit my problem, even tho it's similar. I'm writing a script (called cpj) that will launch one of my current projects. I have about 5 of them. ...
14
votes
6answers
10k views

Execute a specific command in a given directory without cd'ing to it?

Is there a way to execute a command in a different directory without having to cd to it? I know that I could simply cd in and cd out, but I'm just interested in the possibilities of forgoing the extra ...
14
votes
3answers
2k views

Changing parent directory (../) with symlinks

I have a symlink ~/link -> ~/a/really/long/path When I do cd ~/link cd .. it takes me to ~ but I want to go to ~/a/really/long Is there a way to do this? I am using bash.
3
votes
1answer
1k views

What is the best touch screen kiosk solution?

I'm a web developer and I'm looking for the best stripped-down linux experience that provides a full-screen experience for touch screens. I'll be looking for: a robust experience that stops people ...
9
votes
2answers
798 views

Change directory without typing cd?

Is it possible to make bash change directory in command line simply by typing that directory without any commands like cd? For example is it possible instead of writing this: $ cd /tmp I just want ...
9
votes
1answer
646 views

How do I redirect output to cd?

Is it possible to redirect a command's output to cd? For example, I searched for a directory using locate and got the path to it. Now, instead of writing a cd path, can I redirect the locate output to ...
19
votes
2answers
3k views

What is the bash shortcut to change to the previous directory?

Sadly, I only learned about this last year by stumbling upon it randomly on the internet. I use it so infrequently that I always forget what it is by the time I need it again. How do you change to ...