Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 months ago.
Improve this question
I am trying to create a temporary directory using mktemp -d but it is not creating a directory. When I try to run cd $(mktemp -d) it takes me to my home folder. This behavior is similar to cd .
When I try to run mktemp -d and check the exit code using echo $? it return 248 as the exit code.
What is going on?
Most likely $(TMPDIR) is set to a non-existent directory or one to which your user lacks write+execute permissions.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
My understanding is that all commands in linux must exist on the $PATH, even for the most basic commands
> which cd
/bin/cd
> which ls
/bin/ls
But when I tried which pushd, to my surprise, it returned:
/usr/bin/which: no pushd in (/bin:/usr/share/maven/bin:/usr/share/java/jdk1.8.0_131/bin:/usr/local/bin:/usr/bin:/usr/local/sbin)
pushd is "installed" and working. This challenges my whole understanding of linux commands.
Can someone explain why this is happening?
Can someone explain why this is happening?
pushd, like many other commands, is a builtin. which is itself an executable and which searches for executables - there is no such executable as pushd.
To affect the current working directory of the shell itself, it has to be a builtin, just like cd.
You can check what it is with type:
$ type pushd
pushd is a shell builtin
what are other examples of such shell builtins?
They are listed in documentation: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Builtin-Commands .
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to Linux commands. I have a requirement where I want to start Tomcat using a shell script. The location of startup.sh file is in /usr/lib/apache-tomcat-7.0.14/bin/. Tomcat is starting using command sh startup.sh. I want to create a shell script so that it will go to that folder and will execute sh startup.sh command. How can I do this using a shell script? Can anyone share the script for doing this?
Are you serious?
#!/bin/bash
cd /usr/lib/apache-tomcat-7.0.14/bin/
sh startup.sh
#!/bin/bash
exec /usr/lib/apache-tomcat-7.0.14/bin/startup.sh
is simpler (as does not have a shell kicking around)
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
like if I'm in a directory called makefile_assignment, what command would give me the higher up directories and display it like
/home/linux/ieng6/cs80w/public/makefile_assignment
I believe you're looking for:
pwd
Just the environment variable of $PWD
echo $PWD
The pwd command is what you are looking for.
The command is pwd (present working directory).
Usually, echo $PWD also works and produces the same answer.
pwd #present working directory
cd / #to your root directory
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
i created a soft link from my home folder to /etc/ by using
"ln -s /etc/ foo"
then i changed directory to foo
"cd foo"
now i executed the following two commands
"pwd" and "/bin/pwd"
Both gave me different outputs.
The output of "pwd" was /home/myhome/foo and of "/bin/pwd" was /etc.
I am not able to understand the difference in the outputs although both commands are the same.
Possibly a bit oversimplified, but the bash builtin pwd tracks cd commands, so when you cd through a symbolic link, it remembers that. On the other hand, /bin/pwd walks the directory tree back to the root, and, as such, has no idea what symbolic links you might have walked through to get where you are.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
How do I copy a symbolic link from one directory to another?
ls -ls
file1.txt
file2.txt
files -> /mnt/iscsi-nfs-share/faulttracker-files
what I'm looking to do is copy files symbolic link into another directory?
cp files /var/copylinktohere/
the above results in
cp: omitting directory `files'
Use the -d option:
cp -d files /var/copylinktohere/
From man cp:
-d same as --no-dereference --preserve=link
--no-dereference
never follow symbolic links