Unix was released in October 1973. Today there are many different versions based on Unix. The most prominent are GNU/Linux and MacOS. 90% of all cloud infrastructure is powered by Linux and 74% of smartphones in the world are Linux-based.
If you want to see whats going on an EC2 instance or filter some log files you can always use the command line tools.
Using the command line tools for administrative work or lookups will save a lot of time and increase the productivity significantly compared to using only graphical interfaces.
As a web developer we use the following commands on a daily basis. If you are new to this topic, I hope this will help you increase productivity.
|history||displays the history of the last used commands|
|pwd||print working directory|
|echo||echoes an argument|
Navigating in the terminal
When we keep our hands on the keyboard we are always faster, than when use the mouse or similar to navigate around. So we should make use of the following commands, when we are in a terminal.
ctrl + a: jump to the beginning of a line
ctrl + e: jump to the end of a line
ctrl + w: remove word
ctrl + c: remove whole line
option + left arrow: jump to the end of a word
option + right arrow: jump to the beginning of a word
arrow up: show last used command
cmd + k: clear terminal screen
Navigating in the file system
|ls||list – lists all files in the current directory|
|ls -a||lists all but also shows the .hidden files|
|ls -la||lists all files in the long file format|
|cd /||navigate to the root directory|
|cd ~||navigate to the home directory|
|cd ..||navigate one directory level up|
|cd –||navigate to the previous directory|
|mkdir [directory_name]||make directory|
|rmdir||removes a directory|
|touch [file_name]||creates a file|
|cp old_file_name new_file_name||copy|
|mv old_file_name new_file_name||move|
|rm -r||removes recursive, ie a Folder with all contents|
|vi [file_name]||opens file with vi|
|nano [file_name]||opens file with nano|
|code [file_name]||opens file with vs code|
|program_name||to start a program simply type the name, ie python|
|ctrl + c||stop a program|
|head [file_name]||show the first 10 lines of a file|
|tail [file_name]||show the las 10 lines of a file|
|sort [file_name]||sorts the file alphabetically|
|sort [unsorted_file_name] > [sorted_file_name]||sorts the content of the unsorted file and stores it in a new sorted file|
|cat [options] [file_names]||reads files sequentially, writing them to standard output|
|grep [options] pattern [file_names]||globally search for regular expression and print|
|the pipe||The pipe send the output of one command as input of another command.|
| are powerful tools I recommend having a look at this awesome tutorial.
In Unix Systems there are three groups of ownership.
- USER: the one who created the file
- GROUP: a group with assigned users
- OTHER: any other who has not created the file and does not belong to a group.
The UNIX system has 3 permissions defined for the 3 different owner groups:
r = read permission
w = write permission
x = execute permission
– = no permission
d = directory
@ = extended attributes on macOS
Detailed information for the permission system can be found here.
This post is outlining the most important commands (for me). If you want to see all commands you might want to have a look at this list or use the
man in the terminal.