File Permission denied, Debian 9


New Member
Aug 30, 2018
Reaction score
I recently installed core package of Debian 9 via USB (I had to use smaller ISO image due to data limit being reached on Internet). It installed fine and works just like I was expecting, identified my hardware and all that and no problems in that regard.

However, I'm having trouble with file permissions and can't do anything on here, as in, can't install, update or unpack files. The few lines of code that I've tried keep giving me the following errors about permission denied. The main one (I think) is the apt update, not sure what to do as I'm totally new to Linux. I've retyped the errors I get below (I've got line numbering here but they're not in command prompt).

wirra@Beasta:~$ apt update
Reading package lists... Done
line1) W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
Line 2) E: Could not open lock file/var/lib/apt/lists/lock - open (13: permission denied)
L3) E: Unable to lock directory /var/lib/apt/lists/
L4) W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
L5) W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

Any help will be greatly appreciated, thanks for reading.

For tasks that will make changes to the system, you will need root privileges.
Rather than switching to the root users account, you should do this from your own account using sudo - which will prompt you for your password and will temporarily give you root permissions.
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
sudo apt autoclean

The first time you run a sudo command, it will ask for your password. As long as you type your password correctly (and assuming your user is a member of the sudo group) the command will execute and make changes to your system.

After your first sudo command has completed, you can use further sudo commands without retyping your password. But there is a time limit, typically 5 or 10 minutes after your most recent sudo command.
If the time limit expires, sudo will ask you for your password again.

Also, when you have finished using sudo, you can manually make the permission expire using the command:
sudo -k

That will force sudo to drop your credentials, so the next time you use sudo, you will have to re-enter your password.

And why is this useful?

Well, consider you ran a sudo command and then left the room. If somebody else comes along before your sudo/superuser privileges time out, they can run any command they like using sudo, without having to enter your password.

So if you are going to run one or more sudo commands and leave the room: its a good idea to use a sudo -k command at the end.
To safely do an unattended update and upgrade while you pop to the toilet, you'd use:
sudo apt update && sudo apt upgrade -y && sudo -k

When you enter that command, you will be prompted for your password.
Once you have entered your password, the package lists will start updating, then apt will upgrade and install any updated packages (the -y option will just automatically answer yes to any questions thrown by apt), then sudo -k is invoked to clear your credentials.

So whilst these commands are running you can safely take as long as you like on the toilet. And if the commands finish before you get back - your kids/room-mate/colleagues will not be able to run any unauthorized commands. (Unless they already know your password!)

And for additional protection, if your chosen desktop has a screen lock feature, it might be worth activating that whilst your away, if you don't want people to see what cat videos you've been watching in your internet history! XD ha ha!

Anyway, sudo is what you need to perform commands that will modify your system!
Last edited:
Now that's an Australian-sounding name :)

(wizard appears in a puff of smoke)

Hi Wirra, and welcome to :p

This may be very simple...

breaking off - Jas to the rescue!

Chris Turner
Just to thoroughly derail the topic....I thought the same as Chris....the name was it is Wirragulla.....tiny little place in in the north coatc area of nsw, australia. It has a railway platform(wooden) 3 metres long(10'), and a polulation of around 30

Good work up there Jas....that will set him on the right track.
Thanks JasKinasis, but I can't even do that? All I get is:

-bash: sudo: command not found

So my next question is, how do I check if I'm a root user? I should be as there was only one user account created. Or, how do I switch to root user account? And thank you for responding so quickly mate, cheers

But on a completely different note, Wirra Gunya is my Tribal name and my People are the Wiradjuri Nation in central N.S.W, Australia. Cheers guys and thanks for helping me.
Condobolin area ?
Yep, Euabalong to be precise mate. Lived there when I was a kid and went to Lake Cargelligo Primary. When I saw your username I immediately thought "I wonder if he's from around Condo, or does he live in a Condo?" (lol).
But you're a Mexican ie south of the border (Vic) now? Like the avatar :)

Wirra I've got to scoot to cook tea and then gone for the night, and you folks have just gone on to silly time over the weekend, yeah?

I'll check in tomorrow morning. I've got the full Debian 9 on one of my other puters, but Jas is The Man where Debian and a bunch of other things are concerned.

So you're not on dialup, are you, is it ADSL? And you have a download allowance, is that by the calendar month?


Euabalong ....Eubalong west ....royal hotel.......spent a few hours there, holding the bar up for fear it might fall over. Condo.....11 years.
Nah, crappy desktop PC with no wifi card so I've tethered my Samsung to it via usb. So obviously I'm using mobile data at the moment which is why I'm limited in downloading larger files, basically I only get about 1.24gb per day on mobile plan which is plenty for the mobile.

Yeah, another mexican atm (lol) just while I deal with family stuff.

Yeah, know the royal pretty good, we lived around the corner from it. But then again everything in Euabalong is around the corner from the pub really, lol. Haven't been up there for years though, well, almost 2 decades really but been traveling around new south.
No sudo?

Sorry - I assumed you had a full Debian install - installed via the minimal net installer with a net connection and that you had managed to select a desktop and other software from the installer.

But it sounds like you literally did the bare-bones Debian minimal install with no network connection, which yields an ultra-minimal Debian CLI based system, with no sudo and a lot of other things missing. It also means that your user account is literally just a normal user.

Which means that you would have to either log in directly as root at the login screen (using the username "root" and whatever root password you set up in the installer), or from your normal account you could switch to root using:
su root
And you will be prompted for the root password.
Whichever option you use - once you have correctly entered the root password, you will be able to use ANY commands and can modify/administer the system.

So once you have logged in as root, you might want to consider doing a quick system update/upgrade and then install sudo:
apt update
apt upgrade
apt install sudo

Once sudo has downloaded and configured itself, you should add your username to the sudo group:
usermod -a -G sudo username
Where "username" is the username for your normal user-account.

Then type "exit" a couple of times to get back to the text-based login screen.

Once you are back to the login screen, you should be able to log back in with your ordinary user account and you will be able to perform administrative tasks using sudo.

Then I guess the next task will be to install some kind of GUI/Desktop on there? Or is this going to be some kind of server, with no GUI?

Hey mate, did some reading last night and discovered I had to use su to become root and things started working. About to do the 'apt upgrade' now that I have more credit & data. But I do thank you for your help. Without you mentioning the stuff you told me, I wouldn't have known what to look for and wouldn't have been able to find out what I needed and I really do appreciate what you've done for me mate.

I won't be setting up a server until I'm familiar and use to using Linux, so I may ask for your help again to do that down the track. For now though, I just want to familiarise myself with Linux and then take it from there. The PC in question I bought cheap from a shop and it had Win10 on it which kept chewing up my data and is what prompted me to go Linux. About to do the things you've suggested and I'm guessing eveything will start working for me once I've sudo happening.

Thanks for your help, wirra
Last edited:

Hey mate, I followed your advice and it worked no problem, thank you.

But then, I decided that since I have data (for now), to go and install a desktop environment and well well well, I now have a functioning and working computer system that I'm very happy with. :D

I'm so glad I followed your advice and you are a legend mate, thank you so much mate. And now I guess it's time for me to get to know my new PC and get use to using Linux, thanks again mate and cheers guys.

Onya Wirra !!...well done mate.

Yeah I got there with JasKinasis's help, now I'm just getting it setup the way I like things. So far I'm glad I made the switch, it works nice and fast on this crappy PC (which was slow under win10). Can't wait to get some programs installed (Linux compatible obviously) and then I can get back to doing my usual thing. :D

cheers mate
Hey guys, just an update

Since @JasKinasis helped me solve my original problem, and I went and got a desktop environment and I started loving Stretch (Debian 9). I decided that I should go whole hog and get the full setup, which I've done and I also did myself a favour and downloaded a manual so I can do some reading and learn more about my new favourite OS, I just wished I had made the switch sooner because I'm finding it super easy to use now and love the new found speed of my PC.

Cheers guys and thanks for all your help and the chats :D
All good mate
Legend, Wirra :)

I was nearly in my mid-50s before I started dabbling in Linux (61 now), and then another 5 years to make up my mind and get serious.

Mid-2014 blew away Win 7 (which I quite liked, apart from the usual beefs) and went totally Linux household, never looked back.

Enjoy your Linux


Members online

Latest posts