A shell is simply the outermost layer of an operating system. It's designed to provide a way for you to interact with the tools and services that your operating system provides. There are two types: graphic shell and text shell
windows start menu, mac finder are graphic shells where you interact with the operating system through things like windows and buttons. They are also called the GUI or Graphical User Interface.
Bash shell is a text shell used by unix systems by default (linux and mac). Its also called command line interface or CLI. Text shells allows ou to enter text commands to perform tasks instead of clicking on buttons
echo
to print something on the cli
variables
to get the value assigned to a variable
notice there's no spaces around '=' because bash deplays an error x command not found
In e.g Python, we could optionally include those spaces or not, and it worked fine either way. But in BASH, x=100 and x = 100 mean different things.
navigating directories
ls to list the content of the current directory in a shell
ls name-of-direcotry to list the content of another directory
cd change directory
cd .. go back one directory
; lets yo run two commands in one line
ls .. list the contents of parent directory
pwd print working directory
.. parent directory
. current directory
~ home directory
unix uses forward slash '/' to separate directories while windows cmd uses backslash '\' (wastemen)
absolute v relative path
relative
when you specify a path relative to the current location
absolute
when the path specified starts from the home directory or 'c' directory in windows
options
options or flags turn on extra behaviour or extra features.
ls -l -l stands for long .longer more detailed
.pdf all pdfs in a directory
ls *poem * lists all files whose names containes the word poem
organising your files
mkdir make a new directory
mv move file: mv name of file destination you want it to go eg mv .epub /Documents/Books
bash commands cant be undone? : they can but I pray I never have to is all I'm saying on this.
downloading files from the web: curl
curl to download files. c url ==> see url
curl 'url'
If you add the -L option to curl, it will first follow any redirects, and then download the file from wherever the redirects ultimately go.
curl -L 'url' displays source code to the actual url homepage to the terminal
curl -o 'file name' -L 'url' to save the source code to a file
viewing files
cat displays the full content of the file
less shows less of the file at once. you can use the arrow keys to navigate, 'q' to quit, '/' to search, 'b' or up arrow to scroll up, spacebar or down arrow to scroll down
/zebra searches for the word 'zebra'
removing things
rm remove file. deletes permanently. -i flag prompts you for every file you want to remove.
rmdir remove directory. it only removes an empty directory
Top comments (0)