Skip to content

Shell / Bash

Resources

Shells:

POSIX:

Documentation

Cheatsheets

Tutorials

Introductions

  • TBD

Games

Introduction

Shell

Different shells

Using Bash

If you're using zsh, run:

vim ~/.zshrc
or
open ~/.zshrc

Command line interface

Customization

Language

Syntax

Variables

TBD

Quoting

In most cases, you should quote variables to prevent word-splitting and globbing issues.

"${VARIABLE}"

Comments

TBD

Pipelines

TBD

Compound commands

Looping constructs

Conditional constructs

Utilities

TBD

Working with files and directories

ls

ls lists the contents of a directory. ls -l produces outputs like the one below:

-rw-r--r--   1 user  staff   1234 Aug 27 21:10 notes.txt
drwxr-xr-x   5 user  staff    160 Aug 27 20:59 my_folder
  • File type and permissions (-rw-r--r--, drwxr-xr-x)
    • First character: file type
      • - = regular file
      • d = directory
      • l = symbolic link
    • Next 9 characters: permissions in 3 groups (owner, group, others).
      • r = read, w = write, x = execute (or directory access).
      • Example: rw- means read/write allowed, no execute.
  • Link count (1, 5)
    • Number of hard links to the file (for directories, this counts subdirectories, including . and ..).
  • Owner (user)
    • The username of the file owner.
  • Group (staff)
    • The group that owns the file.
  • File size (1234, 160)
    • Size in bytes (though for directories this is metadata size, not the total contents).
  • Last modified date/time (Aug 27 21:10)
    • When the file was last changed (content or metadata).
  • File/directory name (notes.txt, my_folder)
    • The actual name of the file or directory.

Managing jobs

Working with parameters and variables