Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

File creation

Hey guys,
Linux newbie here...but how can you create a file in a different directory than the one you are currently in. I'm not so much interested in the method used (cat, vim, etc...) I just cant get the syntax, to, for instance, create a file in the root directory from the /etc directory. Any help is appreciated.

Comments

  • nugentnugent Member Posts: 87
    if you are in /etc and want to create a file in / put ../ before the filename, for example, you are in /etc and want to create a file called FILE in the / type "touch ../FILE" (without quote marks). (.. means up on directory, and . means current directory)

    Or you could just use the full path when referring to the file, for example, again if you are in /etc and want to create a file in / refer to the file with a sash in front of the name "/FILE"


    if you are writing a program that creates the file attempting to open the file is usually sufficent to create the file.

    or course you need to have the right file access permissions set in order to create a file in /, usually only a priveliged user such as root can do this.




    ------
    nugent



Sign In or Register to comment.