Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

A few questions about Linux commands?

What is the difference between these commands? Don't they all just take you to the home directory?

cd ~

cd $HOME

cd ../../root

cd

Also how do you append output from a script file to a .log file?

Update:

So to append you would write something like:

file.sh file.log

where .sh is a script file and .log is a txt file

3 Answers

Relevance
  • Anonymous
    9 years ago
    Favorite Answer

    No. The fist 2 do. The third one takes you to the root home folder but you would need to be root to do this.

    Appending anything to a file requires a pipe command :

    cat "abcdefg" file.log <<

  • ?
    Lv 7
    9 years ago

    every one of those but cd ../../root (1,2,and 4) are the same thing

    I should note if you change $HOME then they all don't work (besides number 3)

    cd ../../root goes two directories up and into a root folder if one exists. It depends what your current working directory is ... this is called a relative path (because its relative you your current working directory)

    if my home directory is /home/jeff and my current directory is ~/bin/coolness/ then doing cd ../../root will put me at /home/jeff/root/ which is not the same as the other commands obviously

    ./script.sh >> poop.log

    edit: you must have >>

    file.sh >> file.log

  • 9 years ago

    cd ~ This is valid in C Shell only. However, today bash is mixture of C and bourn shells. Thus, it will work.

    cd ../../root This takes you root directory which grand parent to your current directory.

    If you are currently in /home/root then it takes to /root directory is it is existing

    cd this command takes to our home directory. Rather users home directory.

    Main difference is who is executing the command. If the super user root is working then all the above may be same. Else not

Still have questions? Get your answers by asking now.