Skip to main content

Command Palette

Search for a command to run...

[Day 1] Linux Basics - File Permissions, Vim, Shell Script

Updated
3 min read

1. Basic Commands

Command Description
pwd Print current working directory
ls -la List all files including hidden ones with permissions
cd Change directory
mkdir Create directories (multiple at once: mkdir a b c)
touch Create an empty file
cat Display file contents

2. File Permissions (chmod)

-rwxr-xr-- → file type / owner / group / others
  • r(read) = 4, w(write) = 2, x(execute) = 1 → binary bit values

  • Numeric mode: chmod 755 file → owner(rwx) group(r-x) others(r-x)

  • Symbolic mode: chmod u+x file → add execute permission to owner

Common Permission Patterns

Number Meaning Use Case
755 rwxr-xr-x Executable files, scripts
644 rw-r--r-- Regular files
600 rw------- Private files (SSH keys, etc.)
700 rwx------ Private executables

3. Owner / Group / Others

  • Owner (user): The person who created the file

  • Group: Users belonging to the same group (e.g., docker group)

  • Others: Everyone else — not the owner, not in the group

How the OS checks permissions: Is this the owner? → Same group? → Others

groups frog    # Check which groups frog belongs to

4. Vim Basics

Key Action
i Enter insert mode
Esc Return to normal mode
:wq Save and quit
dd Delete current line
o Open new line below + enter insert mode
u Undo
A Jump to end of line + enter insert mode
$ Move to end of line
0 Move to beginning of line
w / b Move forward / backward by word

5. Shell Script

#!/bin/bash          ← shebang: tells the OS to run this with bash
echo "Hello"         ← print to screen
$(whoami)            ← command substitution (returns command output as string)
$(date +%Y-%m-%d)    ← format date output
echo "text" > file   ← redirection: write output to a file

bash myfirst.sh vs ./myfirst.sh

  • bash myfirst.sh → bash reads the file as text and executes it. Only needs read(r) permission.

  • ./myfirst.sh → OS treats the file itself as an executable. Requires execute(x) permission.

6. Other Useful Commands

  • sudo → Run as administrator (root)

  • apt update → Refresh package list

  • apt install → Install a package

  • && → Run next command only if the previous one succeeds

  • -y → Auto-confirm installation prompts


Tomorrow: find, grep, pipe (|), redirection (>, >>)

11 views