Skip to main content

Basics - Bash & File Systems

Open a terminal (with a Bash shell) by Ctrl+ALt+T.

Bash Syntax#

Watch the following video:

Keypoints of the video:

  • ~ and $
  • Bash syntax (command base): program-name arguments
  • the search paths when executing:
    • the PATH variable,
    • the absolute path, denoted with leading /, or
    • the relative path, the PWD (current working directory)

Excercise: What is the different between executing foo and ./foo?

Excercise: How to pass multiple arguments when executing a program?

Bash Pipeline, Redirection and Built-in Commands#

Watch the video until 11:30

Watch the video above from 11:30 First few built-in commands:

  • cd change directory
  • echo print arguments to stdout (try echo $PATH)
  • export set environment variable (inheritable variables)

Bash Basic Navigation and File Manipulations#

Access and Navigation

Keypoints of the video:

  • Understand command cd,cd ..,ls, ls -a, mkdir, pwd
  • Understand command touch, mv, rm

Creating & Editing Text Files

Keypoints of the video: - Understand command `cat`,`less`,`tail`, - Use `nano` to edit files

Privileges and Permissions

Keypoints of the video: - Using `sudo` to raise to root access - Set permissions and group using `chmod` and `chown`

Finding Documentation and Files#

Keypoints of the video:

  • Locate executable in PATH by which
  • Locate files using find or locate or whereis
  • using grep to find text in files (Reference)

Navigating through Directories and Locating Files#

Questions for Thought#

  • What is the difference between ls and ls -a?
  • How to differentiate between an absolute path and a relative path?
  • What does environment variable PATH do? How to view, set, append environment variables?
  • What can which whereis and locate do? What are their differences?

Know More about a File#

  • stat to show the modification date etc
  • file to know the binary type (architecture)
  • ldd to know the dynamic linkage (.so file links)

Uncompress Zip File#

Reference

Tar file: tar -czvf archive.tar.gz /usr/local/something

Unzip file with permission preserved: tar -xpf file

Last updated on