0

I'm trying to access the etc/fstab by the following command and getting the error.

Bash command:

sudo echo "swapfile none swap sw 0 0" >> etc/fstab

Error:

-bash: etc/fstab: No such file or directory

Then when I trying to check the existence of etc/fstab by ls -l and getting it there. But why I got an error in the first entry point?

Btw, I'm using Ubuntu server on my Virtual machine.

AdminBee
  • 22,803

1 Answers1

5

Two issues here

  1. The file path needs the leading / here, so it should be /etc/fstab
  2. You'll then find that despite your sudo command you get a "permission denied" error. This is answered at Redirecting stdout to a file you don't have write permission on
Chris Davies
  • 116,213
  • 16
  • 160
  • 287