Skip to main content

Command Palette

Search for a command to run...

The Shell

Updated
2 min read

About Shell and bash

What is the shell?

Shell is a textual interface. Terminal is the virtual interface to a shell. In linux and macos, it is called bash (Bourne Again SHell).

Navigating in the shell

  • The prompt we see in a terminal when we open it for the first time looks like below,

    rashid:~$

    Here rashid the machine and the current directory is ~ (short for “home”). The $ tells you that you are not the root user. ~ is called tilde.

    Eg:

    rashid:~$ date
    January 8, 2026 1:15:24 AM

    rashid:~$ echo hello
    hello

  • The command “cd” means change directory. The command “pwd” means present working directory.

What is available in the shell?

  • When the shell is asked to execute a command, it consult an environment variable called $PATH. The command “ls” lists all the files in the directory.

  • cat - content of the file

  • echo is the argument parsing.

  • “man” (manual) is the program that explain how to use a program. or we can use -- help after writing the program name. for eg: date --help.

  • tool: ZOxide tool which remember all the paths we cd into.

  • Double tapping the tab key after enetering the first letter , it will show all the possible options.

  • rashid@LAPTOP-G15TMEFH:~$ which -a sh /usr/bin/sh /bin/sh

  • head -n1 data , for print 1st line.

  • grep is a powerful command-line utility used for searching plain-text data for lines that match a specific pattern, which is typically a regular expression. Its name stands for "global regular expression print".
    grep [OPTION...] PATTERNS [FILE...]

  • sed

  • glob is for path, like */*.md

  • find for finding the files. For eg:
    rashid@LAPTOP-G15TMEFH:~/assignments$ find -type f -mtime +15
    ./test2.txt
    ./New Rich Text Format.rtf
    ./test1.txt
    here, we are trying to find files which are more than 15 days old.

  • rashid:~$ find ~/Downloads -type f -name "*.zip" -mtime +30
    Finds ZIP files in the download directory that are older than 30 days.

  • awk program is used to parse data

  • ls -l file.sh give more details about the file including its permission.

  • chmod +x file.sh means, change the mode, make it executable.

The shell language (bash)

The pipes ( | ) let you string together output of one program with the input of another.

The command >file let you take the output and write it to file. The command »file let you take the output and append it to file.

#!/bin/bash is the shebang and specifies that the script should be executed using the Bash shell located at the path /bin/bash.

29 views