DCubes
Linux module

Lesson 6

Permission denied

Read ls -l, make a script executable, and learn why chmod 777 is not a fix.

beginner30 minRun on your machine

What you will be able to do

  • Decode a line of ls -l (type, rwx, owner)
  • Create a small script, mark it executable, and run it
  • Explain why Spark, Airflow, and Docker mounts hit permission errors

Why this matters for DE and AI

The fake log in the last lesson failed with Permission denied writing /data. That message is the most common “it works on my laptop” failure in pipelines:

  • Spark cannot write the output path.
  • Airflow cannot read a DAG file owned by root.
  • Docker mounts a folder the container user cannot write.
  • A GPU job cannot save checkpoints.

You do not need to be a sysadmin. You need to read ls -l and know what chmod +x does.

Concepts

Run ls -l on a file and you get a line like:

-rw-r--r-- 1 sam sam  412 Mar  1 09:00 job.log
Piece Meaning
- Type: - file, d directory, l symlink
rw-r--r-- Permissions in three groups of rwx: user, group, others
sam sam Owner user and group
412 Size in bytes
job.log Name

r read, w write, x execute (for a directory, x means “you may enter it”).

So rw-r--r-- means: owner can read/write, everyone else can only read.

Making a script runnable

A file of commands is just text until the system is allowed to execute it.

chmod +x scripts/hello.sh

+x adds execute for the user (typically). Then:

./scripts/hello.sh

The ./ means “run this file in the current directory tree,” not a program from PATH (lesson 10).

The first line of a script is often a shebang:

#!/bin/bash

It tells the OS which program should interpret the file.

Practice on your machine

cd ~/dcubes/linux-lab
ls -l logs/job.log
ls -ld data logs scripts

ls -ld lists the directory itself, not its contents. Note the leading d.

Create a script:

cat > scripts/hello.sh << 'EOF'
#!/bin/bash
echo "hello from linux-lab"
pwd
EOF

Try running it before chmod:

./scripts/hello.sh

What you should see: Permission denied (or a similar “cannot execute” message). That is the lesson.

ls -l scripts/hello.sh
chmod +x scripts/hello.sh
ls -l scripts/hello.sh
./scripts/hello.sh

After chmod the permission string should contain x. The script should print hello from linux-lab and your path.

On some systems you can also run bash scripts/hello.sh without +x. That asks bash to read the file. Production job schedulers often expect the +x and shebang form.

Common mistakes

  • Forgetting ./. Typing hello.sh looks in PATH, not the current folder. Use ./scripts/hello.sh.
  • chmod on the wrong file. ls -l before and after.
  • Treating 777 as normal. If a tutorial says chmod 777 to “just make it work,” skip that tutorial.

Next

Find and searchfind, grep, and hunting ERROR in a log.