terminal
Open a terminal from another (e.g. VSCode) terminal
Add to path on Mac
Using pipe and grep
Open current directory in finder
Find and kill process on a port
Recursively remove node_modules
node_modules
Location of a command in PATH
The following will return something along the lines of hie is /Users/username/.local/bin/hie
:
Common commands
clear
- clear the terminalpwd
- print working directorymkdir
- make directorytouch
- create a file (e.g. touch example.txt)cp
- copy (e.g. cp file.txt target_directory)mv
- move (e.g. mv file.txt target_directory), can also rename a file (e.g. mv old_file_name.txt new_file_name.txt)rm
- remove (e.g. rm file.txt), can also remove files recursively (e.g. rm directory_name)echo
- send to stdoutcat
- read content of a filealias
- set aliases (e.g. alias pd="pwd" means pd can be used interchangably with pwd)export
- set environment variables!env
- return list of environment variables>
- redirect stdout to a file (e.g. echo "Hello" > hello.txt)>>
- append stdout to a file<
- redirct stdin to a command (e.g. cat < file.txt)|
- pipe stdout of LHS as stdin to RHSwc
- word count (of a text file)uniq
- unique the contents of a file (on a line-wise basis?)grep
- global regular expression print (-i adds case insensitivity, -R recursive, e.g. within directory)sed
- 'streams editor', can be used for find and replacenano
- text editorsource
- source ~/.bash_profile makes all aliases available in the current sessionhistory
- command history
Environment settings
Stored in:
(where ~ is an alias for $HOME and . represents a hidden file)
How cmd line works
Most commands are stored in
/bin
/bin
is a directory on the path (...and hence is available in a terminal session)Hence you can see all commands using:
cd /bin
,ls
Last updated