Linux Basics/Terminals, command prompt, alias, history
What's a terminal?
- Terminal = command prompt → shell = command-line interpreter
- Text-mode, DOS-like
- There are several terminals
- Gnome-terminal, Xfce4-terminal, xterm, etc.
- There are many shells (e.g. bash, fish, ksh, zsh etc.)
- you can also customize the shells, for example this video on YouTube shows it: [GNOME 3.28] PowerLevel9k - The Most Cool Linux Shell EVER!
- commands can be executed
- command list: https://ss64.com/bash/ (and also the Linux Basics/Basic commands chapter)
- alias: we can shorten a complex command with an alias or we can create our own one.
- Location of definition (in case of bash shell): ~/.bashrc
- Global aliases: /etc/bashrc
- It can be recalled by pressing up and down arrows on keyboard
- you can switch tabs on terminal by pressing ctrl+page up or ctrl+page down
- ~/.bash_history shows the commands before login
Environment variables: it stores information of the operating system or programs. Environment variables get set automatically after startup. For example, PATH environment variable tells the shell where to search the executable files.
- Printing them to terminal:
- but particular environment variables can be displayed too:
- to set up an environment variable:
set VAR1=”something” where VAR1 is an arbitrary variable
- to delete an environment variable:
- displaying a particular one(same as printenv basically):
- to have the setting in the system permanently:
- we can create an own command under
/home/binfolder, but it works only if we added the folder to PATH environment variable:
export PATH=$PATH:~/bin, and to make it permanent in .bashrc:
echo "export PATH=$PATH:~/bin" >> ~/.bashrc
Thottee explained it on his website in more detail that what we do exactly (his website is in hungarian so you may need to translate it with a translator program: http://linuxkezdoknek.hu/articles.php?article_id=33 (the article's second half)
- help for using a command:
- command for the manual (detailed help):
man <switches> <command>
info <switches> <command>