Skip to content

Missing Semester 01 - The Shell

(Bourne Again SHell) is a common shell that comes preinstalled on many OS.

Written by Eva Dee on (about a 3 minute read).

Bash permalink

  • bash

(Bourne Again SHell) is a common shell that comes preinstalled on many OS.

  • date - current date

  • cal - calendar

  • echo $PATH

Shows all the paths on your machine that the shell will search for programs (it's a colon-separated list).

  • which echo

Tells you where a specific program is run from.

Paths permalink

PATHS are a way to "name a location of a file on your computer".

Absolute paths are paths that fully determine the location of a file.

Relative paths are relative to where you currently are (pwd).

If you want to create a directory/file with spaces:

  • escape the space with \
  • put the name in quotes, e.g.: echo Hello\ World

Directories permalink

  • . (the current directory)
  • .. (the parent directory)
  • ~ (the home directory)
  • cd - (previous directory)

Man(ual) permalink

Anything that doesn't take value is a flag, and everything that does is an option. -a and --all (flags) -c and --color (options)

in man documentation: ... (means 1 or more) [] (means options)

Permissions permalink

In terms of users: owner, group, everyone else.

Directory permissions (rwx))

-read: think of it as a list (can you see files inside a folder)

-write: are you allowed to rename, create or remove files within that directory So if you have write permissions on a file, but not the directory in which the file is, you cannot delete that file (you can empty it, but you cannot delete it!)

-execute: think of it as search. Are you allowed to enter this directory (CD into it). You need to have execute permission on all the parent directories as well!

  • - indicates that the given principal does not have the given permission

Streams permalink

"When a program tries to read input, it reads from the input stream, and when it prints something, it prints to its output stream. "

  • > (append)

  • >> (overwrite)

  • | (takes the output of the program to the left and make it input of the program to the right)

Misc permalink

  • sudo su

Run root shell - you'll see the # prompt (instead of $) at the end of your prompt. Run the following command and shell as superuser

  • tee

Read from standard input and write to standard output and files (or commands). Tee takes it's input and writes it out to a file + it writes to the stdout.

From Exercises permalink

-chmod u+x file

Give the [u]ser who owns a file the right to e[x]ecute it: