There are books and whole courses designed around the Unix Shell. It is an integral part of the OS and has been helping Engineers and Technicians since computers started. Since I use it a lot in my day to day work as a Software Engineer, I thought it’d be good to write a post on it.
What is the Shell?
Wikipedia defines it as follows (Wiki Page)
A Unix shell is a command-line interpreter or shell that provides a traditional Unix-like command line user interface. Users direct the operation of the computer by entering commands as text for a command line interpreter to execute, or by creating text scripts of one or more such commands. Users typically interact with a Unix shell using a terminal emulator; however, direct operation via serial hardware connections, or networking session, are common for server systems. All Unix shells provide filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration.
Where did the shell come from?
The first Unix Shell came out in the 1970s when the Unix operating system was first created. Since then it has been added onto and updated with each new OS and upgrade. There are Shells on Unix, Linux, Windows, and even mobile devices. The usefulness and efficiency of the shell continue to make it one of the best tools in an Engineers toolkit.
The shell provides a vast amount of power in that you can quickly and easily control functions on your computer. A lot of times as a Software Engineer it is the main way I communicate with the systems I work with.
Each OS has different variations in the same basic commands. Typically Unix and Linux follow the same patterns. The Windows “Command Prompt” and PowerShell have some of the same, but a lot of their own Windows versions of the same Unix and Linux commands. So as a small caveat, you may have to do some googling on your specific shell if the command you’re trying to run isn’t working.
I most often work with a Macbook Pro. Here are some common commands that I use in the OSX terminal:
How to show what directory you’re currently in
How to create a directory
How to copy a file
How to delete a file
How to move a file
How to output a file’s contents on screen
How to create a zip file
(The -r above forces the command to go into subdirectories. If you do not provide that and you provided a directory, it will only create a blank copy of the directory in the output zip file.)
How to kill a process on port 8080
kill $(lsof -t -i:8080)
(If you want to kill a different port then just change the 8080 to that port)