Shell

  • $SHELL tells you the current shell you are using

  • To find if the default location is just a symlink, go the directory containing the shell and run ls -lah to see if your shell is just a symlink to another shell, very common for sh → bash

  • To see the working directory, you can use the environment variable $PWD which stands for print working directory

  • To create a symlink, use ln -s FILE DESTINATION

  • If you want to see all registered shells (important for using another default shell), you can cat the content of /etc/shells

  • To get a list of all environment variables, use export -p

  • The $ sign in the terminal stands for a variable, as example if you want to write the following in the terminal: echo that is the path for brew which brew will not work because which brew is part of the command now but with the use of a variable: echo that is the path for $(which brew) it will work

  • To change the default shell to zsh as example. Use chsh -s $(which zsh)

  • To check the directories that are registered in your path, use echo $PATH

  • If a directory containing a binary file is registered in your path, you can directly access it from everywhere

  • An alternative to see the location of a command: command -v brew is which brew

  • TODO

  • The .profile file is loaded once you login in the system

  • The .rc file is loaded on every new terminal

  • There are a lot of different shells. The Bourne Shell (sh) created by Stephen Bourne was the default shell in UNIX 7.

  • The Bourne Shell does not load the .rc file

  • The Bourne shell is mostly dead by now and was replaced with bash (Bourne Again Shell) or on newer linux versions, with dash

  • Another very popular shell is zsh (Z Shell)

  • If you want to add a path to your PATH variable you need to do it in either the .profile or .rc file, otherwise it will get lost once you restart the terminal

  • To add a new alisas, go into your .rc file and add it with alias aliasname=command

robot