No such file or directory when trying to create a file with nano

32,002

Solution 1

It seems like there is a typo in your question because there would normally be a blank space between nano and /etc/apt/apt.conf.d/... To create a new file named 02proxy in the /etc/apt/apt.conf.d directory (which normally already exists) open the terminal and type:

sudo touch /etc/apt/apt.conf.d/02proxy  

To open the 02proxy file for editing in nano text editor:

sudo nano /etc/apt/apt.conf.d/02proxy  

Nano text editor keyboard shortcuts
Use the keyboard combination Ctrl + O and after that press Enter to save the file to its current location.
Use the keyboard combination Ctrl + X to exit nano.

Solution 2

this behavior happen if the target directory doesn't exist. you have therefore to create the parent directory

mkdir my_dir

then use nano.

nano my_file

CTRL x=>y

Share:
32,002
Zanna
Author by

Zanna

Updated on September 18, 2022

Comments

  • Zanna
    Zanna over 1 year

    I am trying to create a new file:

    nano/etc/apt/apt.conf.d/02proxy
    

    When upgrading from 14.04 to 16.04, but I'm getting the error:

    No such file or directory
    
    • Admin
      Admin over 6 years
      Have you tried to run nano/etc/apt/apt.conf.d/02proxy literally? Try it with a space after the command name: nano /etc/apt/apt.conf.d/02proxy. You’ll need root permissions for that.
  • PerlDuck
    PerlDuck almost 6 years
    Creating a directory won't help if you don't put a space between the command (nano) and the file it applies to (/etc/apt/apt.conf.d/02proxy). The OP basically issued nanomy_file instead of nano my_file.