Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 'cd home/cataldo/Programs': No such file or directory

Without qoutes after exec it does not work either. Double quotes make no difference. Using bash -c "cd .." does not work.

It might be some permission problem or screen executes commands as a special user at startup?

Thank you very much for your help!

screen --version
Screen version 4.00.03jw4 (FAU) 2-May-06

cat /etc/debian_version 
share|improve this question

It doesn't work because cd is a shell built-in command (try which cd). Screen has a chdir command which you can use to achieve your goal: Put the following inside your .screenrc:

chdir /home/cataldo/Programs

Now start screen and you should be in the specified directory.

share|improve this answer

screen doesn't know about cd as it is a shell builtin, so screen can't execute it. However, screen has a builtin command of chdir. If you execute chdir by itself from the screen command line, all new windows in the screen session will start in your $HOME. If you execute chdir /home/cataldo/Programs from the screen command line, all new windows in the screen session will start in /home/cataldo/Programs.

If you want to open 3 windows in different directories when you start a new screen session, in your ~/.screenrc define the directory with chdir and then immediately start a new window.

# Start these windows when screen starts up
chdir /home/cataldo/Programs
screen 0
chdir /usr/local/bin
screen 1
chdir /tmp
screen 2

From man 1 screen (pay attention to the last line)

chdir [directory]
Change the current directory of screen to the specified directory or,
if  called  without  an argument,  to your home directory (the value of
the environment variable $HOME).  All windows that are created by means
of the "screen" command from within ".screenrc" or by means of "C-a : 
screen ..." or "C-a c" use this as their default directory.  Without a 
chdir command, this would be the directory from which screen was invoked.  
Hardcopy  and  log  files  are  always written  to  the window's default 
directory, not the current directory of the process running in the window.  
You can use this command multiple times in your .screenrc  to  start  
various windows  in  different default directories, but the last chdir value 
will affect all the windows you create interactively.
share|improve this answer

What you say doesn't make much sense. Even if cd were a real command, screen would just change directory and then immediately exit, which would do nobody any good whatsoever.

If you only want to start a specific screen session in a particular directory:

(cd home/cataldo/Programs && screen)

That will change directory, start screen with a shell, and return to your existing directory when screen exits.

share|improve this answer
Thanks for the reply, but I am afraid that it does not make much sense. When I open screen I want to open 3 different subscreens in 3 different subdirectories, as it is shown in the page linked in the question. I think all this should be initialized in .screenrc, not from command line. – Gismo Ranas Mar 30 '12 at 14:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.