You can't cd or ls in a folder if you have no +x permissions on it. That is all. I wasted 3 hours of my life.
You can't cd or ls in a folder if you have no +x permissions on it. That is all. I wasted 3 hours of my life.
You can't cd or ls in a folder if you have no +x permissions on it. That is all. I wasted 3 hours of my life.
If it makes you feel any better, I decided earlier today to experiment with "castnow", a command-line program for casting to a Chromecast device.
I grabbed the url of a video off of Archive.org, used wget on a box I was ssh'd into to download the video, and then ran my "castnow" command to cast it to the Chromecast.
I got a progress bar and current/total time on the TV, but aside from that only a black screen and no audio.
I tried getting the latest version of "castnow" from the Git repo. I tried transcoding 7 different ways with FFMPEG. A bunch of things.
Finally, copied the video to my local machine and ran it in mpv.
The video itself was solid black with no audio and the Archive.org page had comments on it saying "why is there no video or audio?"
I tried a different video and it worked fine.
Beautiful story. Feel that we've all been there. Every now and then, when the assumption is that the stupid piece of tech isn't working, and there it is, just functioning as intended :)
Thanks for sharing
This is hilarious
My desktop background used to be solid black with faint grey text reading "Yes, the monitor works."
Back in the dark, old days of Linux I spent 5-6 hours digging through dbus events and X11 configs to get my mouse working. It was unplugged.
In my defense, in those days, Linux was such an insane asylum that diving into dbus and X11 as a first step was usually the logical approach.
Been there with those old printer cables that had the two thumb screws. I spent way too long troubleshooting print problems turned out with some cables if you dont screw the thumb screws all the way in you don't get a good cable connection.
Back in the dark, old days of Linux I spent 5-6 hours digging through dbus events
That's not possible. In the dark, old days of Linux, dbus didn't exist yet.
There's always a darker, older day
Or forgetting to enable the third button/wheel in the kernel
Once helped a nice old lady troubleshooter her computer. Everything was yellow. Checked monitor settings three times. Checked Windows for f.lux. Checked Windows video settings. Reverted drivers. Updated drivers.
Jiggled the cable.
Ah, good old VGA brings the memories back
I am still removed when I have to touch anything dbus, x11 or xdg.
Also, finding where an environment variable comes from is fun too.
Let's just hope X11 will soon be gone for good.
Remember - if an environment variable's not your fault, it's your parent's fault.
On the bright side you must be tough as bricks now.
You can always cd's nuts
mkdir -p eez/nuts
cd eez/nuts
This is serious, ls not make it a pun thread.
lol this comment made me subscribe
Underrated comment
No, you just had a 3 hour learning experience.
Educator here. This is called "discovery learning". (The alternative to discovery learning, "direct instruction", would be if someone had told OP about these permissions before OP got themselves into a pickle)
When discovery learning is successful, it leads to better learning outcomes. Compared to direct instruction, you learn the material more deeply and will have better recall of the material, often for the rest of your life. The downsides to discovery learning are that it's very time-consuming, very frustrating, and many students will just fail (give up) before learning is completed.
Consider yourself one of the lucky ones, OP.
If discovery learning is frustrating in class, you must adjust it. It can't be too easy or too frustrating.
And yes, usually the mental model a student forms from a lesson after doing some discovery learning has strong foundations.
It happened to me countless times that I was suffering with a task for hours and hours and hours, then finally found what the problem was. Then a few weeks later, facing the same issue again somewhere else, I only remembered the fact that I had that same issue weeks ago, but I completely forgot what the solution was.
Weirdly enough, sometimes it's indeed a lifelong experience and I can remember the solution forever. I don't really know what it depends on.
Reminds me of the adage "you didn't pay me $5,000 for turning that bolt. You paid me $5,000 because I knew which bolt to turn." Experience and knowledge is valuable.
SELinux enters the chat
Sure you own it, your groups owns it, its permissions are 777, SELinux says GEEEEEEET FUUUUUUCKED.
But then you get the pleasure of making it submit. My Minecraft server is now running in GNU screen just like I wanted it to, and SELinux can only look on and whimper softly.
A friend of mine told me a long time ago: "if a windows system is behaving funny, it has to do with virus. If a Linux system is behaving funny, it has to do with permissions"
if a windows system is behaving funny, it has to do with virus.
Not always true. Sometimes, it's a driver issue. (Usually, a reinstall can fix the issue.) Or it could, very rarely, even be a BIOS/ UEFI issue. (Don't touch it unless you know what you're doing, and only download updates from your manufacturer's website.)
And if a network is having problems, it has to do with DNS.
it has to do with virus. If a Linux system is behaving funny, it has to do with permissions"
Windows permissions are way more complex than Linux though, unless you're using Linux ACLs. Standard Linux permissions just have read, write, and execute permissions for the user, group, and world. Windows (and Linux ACLs) allow any number of different users or groups to have different permissions.
You wasted 3 hours of your life so far lol
But yeah. I find the most mysterious and time-consuming of problems are usually caused by a very minor detail that is so obvious it gets overlooked immediately.
And even if you know that's probably the case, sometimes your brain will just discard information that isn't consistent with its assumed reality, and it tells you the piece of code you just read is fine when it's obviously not.
Troubleshooting/debugging is fun.
Oh god that reminds me of those cases where it IS a language bug. It's like just not part of reality somehow so you don't see it.
I remember myself asking why directories had x flags in their permissions. Like, you don't execute them. What do they use the x flag for?
There needs to be a Linux kernel fork that when you try to execute a directory executes all programs in the directory. In parallel. Juuuuuuuust to fuck with people who might accidentally execute the /usr/bin
directory.
And if there's a circular symlink, we fork bomb
Those of us who use the autocd feature of shells "execute" directories all the time. For example I'd type just /usr/bin RET
if I wanted to cd to /usr/bin.
For directories, it’s permission to cd
into it. Read is whether you can list files, and write is remove, rename, or create new files. Don’t ask questions about the secret sticky bit
cd as owner lol
The x permission on directories is exactly for this purpose. You can use the directory. You cannot read (requires rx), you cannot write (w), but you can 'cd' and operate on files in the directory.
This is important, you can lock someone out from a directory tree buy not giving them 'x' on the root. So, if your home is rwx------, no one but the owner can do anything in your home. This is effective even if some files and subdirectories have less restrictive permissions.
Executing a list read of the inode?
It's necessary if you want to give somebody rw access to a subdirectory but not the parent.
The parent gets "x" and the child gets "rwx".
This way you can have multiple users with their own directories under, say, /var/www/html but restrict access to /var/www/html itself.
If the user doesn't have "x" then they can't see anything in that directory at all.
I love posts like these because they help me avoid mistakes I would've definitely made too. Thanks OP!
ls
reaction to this is unexpected:
$ mkdir foo $ echo Foo > foo/file $ chmod a-x foo $ ls -l foo ls: cannot access 'foo/file': Permission denied total 0 -????????? ? ? ? ? ? file
I expected to just get a "Permission denied", but listing the content it can still do. So x
is for following the name to the inode and r
for listing directory content (i.e. just names)?
You can still read the contents of the directory because you have -r
on it. If you just run ls foo
you'll see your file on there, no problem.
However, without -x
you cannot read metadata in that directory. That's why all information about the file shows as question marks.
sudo chmod -R 777 /
Edit: don't do this, it will allow everyone and everything to read and modify all files of all mounted filesystems, this includes your personal files, system wide passwords, config files, everything and might break the whole system as not all files are meant to have these permissions, e.g. mapped hardware settings or your ssh key store.
sudo
comes with immense power, do not, under any circumstances, enter commands you found on the internet without an intense look about what they do and what their implications could be. Never sudo
or doas
, etc., without a strong and valid reason.
the 777
stands for 'lucky jackpot number', as in 'youre lucky if you dont break your entire system'
well, 666
would '-_-'
This is so useful! Now I can just run:
rm -rf /
Without the sudo!
--no-preserve-root
That's all true, except when I send you a command. You can totally trust me and just run it.
remove the French language pack, frees up space
I set 777 to my whole file system on a install of Ubuntu back in the day and it does indeed fuck the install in lovely ways. I didn't bother attempting recovery. Nice learning experience.
@drdiddlybadger @neonred I've had results with chmod -r +x /
Better than 666, which I did once 20 years ago
Timeshift: hold my beertfs
Challenge time.
Ouch. I'm sorry you had to find out that way. But in the plus side, you'll never forget.
I worked in a job with build scripts. Developers would list what they wanted in a drop-down menu on a website, with very few "fill in the blanks." This would create a template, which was sanity-checked.
One of the "fill in the blanks" was "home directory of user, if not default /home/username." Some people filled it in, some didn't. A lot of "users" might be apps with /home being "/opt/appname" "/var/www/html" or something. We checked to make sure that directory existed, if not, create, and set permissions. Easy peasy, all automated. Ran this lots of times.
Then one day, the script failed. Borked the whole box. Sometimes the VM was corrupt, so delete VM and try again. Usually worked. But this time, the build kept failing. The box went down. Wasn't even bootable. This happened several times with this one build. So we mounted the borked drive under a new VM and checked out the logs. Just like the dessert stage of Willy Wonka chewing gum, it always failed at the last stage: making /home directories.
It would create them, then halt that it could not find bash. We looked for bash on the bad drive, and it was the usual /bin/bash shortcut to /usr/bin/bash and we were truly puzzled. I did a chroot to the drive and NOTHING worked. It just hung. That was the first clue.
The second was looking through the build script (in bash, which we didn't write) and checking the steps. Looked it the logs. Always died at creating some user named sapadm, the user for the HANA database. Eventually, I checked the configure file, and noticed it was the only user with the odd home directory "/usr/sap." Then it hit me: the permissions.
The script, thinking it was a home directory, did a chmod - R 755 for all directories and chmod - R 644 for all files! That meant, while creating home, it made everything under /usr not executable anymore! Holy shit, no wonder nothing worked! So we commented out that user in the config, ran the build again, and we were good! We created the sapadm by hand, and then later fixed the bug in the script.
SANITIZE YOUR DATA. Or you might turn Violet Beauregarde into a blueberry.
Learned that when dealing with Ansible:
To change all the directories to 755 (drwxr-xr-x
):
find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
To change all the files to 644 (-rw-r--r--
):
find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
I have wasted lots of time on this once, long ago.
Here's another one I wasted time on. Mount point didn't have proper permissions (SunOS I think it was). Couldn't access the mounted filesystem.
I once wasted 2 hours on getting an ssl cert working on an irc server by just giving its user access to my nginx certs, which turned out to also need +x. That was when I realized everything I knew about the execute permission was wrong.
Two hard problems.
Yup. Took me weeks to figure out why I explicitly need to use sudo nvim for my nginx config on my Pi, while on my server my little helper script could automatically use sudo for me. Turns out, I chmoded the sites-available and sites-enabled on my pi to 644 but left them untouched on my server.
I still don't know what numbers would be 644 but with execute permissions, but in the end, idc.
You can also do chmod +x
to add the executable bit to whatever the existing perms are.
0: no permissions
+4: read
+2: write
+1: execute
I often go chmod -R go+rX .
if I want to give read-only access to whatever I'm working on to everyone else. The capital X
only sets the executable bit on directories.
644 and 755 are the two most useful octal codes to remember because they make up the majority of files on your system. 644 is user read/write but read-only for everyone else. 755 adds execute to that, useful for scripts and directories.
Other than that, the most common other things are setting access for group and others to zero, so your ~/.ssh directory is 700 (rwx for you, no access for anyone else) and the private keys in it are 600, rw for you, no access for anyone else).
For those that don't know, you can use three numbers, zero through eight, with the chmod command. it takes the binary of each digit to set the permissions.
$ chmod 644 6 | 4 | 4 110 | 100 | 100 rw- | r-- | r--
with the chmid command
Nah, that command just makes the file below average quality. It's a new command added by Gen Z.
Execute just adds 1, so if you want the dir world viewable, it's 755.
Why didn't you just ask?
One person would have responded with "LMGTFY". Another would have said "Why are you trying to do it that way? You should do it this way". Another would have asked what distro they were using, and regardless of the answer, bullied them for their choice. Yet another would have given a very confident and wrong answer. One more would have suggested they use kde instead of genome. And finally, a mod would mark the question as duplicate of another unanswered question and lock it. Thats why.
Why ask for help if I can spend hours in "terminal flow" where I know every three character sequence for CTLR+R to suggest the last 10 commands in the history?
You should check out https://github.com/junegunn/fzf
It has changed part of my life. Unbelievably fast indexing. Not super related to command history, but the hotkey reminded me of it.
The EPERM didn't give you a little hint?
Wouldn't it be EACCES?
ESOMETHING
I still waste time on this occasionally 😹
That's how it works
R is to read it's contents, x to enter
s (g+s) keeps the group for all new files in that directory the same as it's parent
Danngggg.. 3 hours maannn..
and you were the one to remove the +x
Is lemmy just a collection of low grade SWEs? Constantly see memes like this, talking about "coding in HTML", or debating Linux distros lol.
There are a few people that are just getting into Unix style operating systems and we all remember and relate. Even if it was 30 years ago.
Thank you! I only switched to Linux in 2022. I came for the privacy and performance, and stayed for the customisation, the FOSS philosophy and the terminal experience.
We all started small, making mistakes. Most of us still do from time to time
I would argue that this is something that should be taught in every undergraduate Operating Systems course. But if someone posting it here benefits teens, self-taught hobbyists, and old-timers getting back into the field so be it.