Linux Basics/Terminals, command prompt, alias, history

From Wikibooks, open books for an open world
Jump to navigation Jump to search

What's a terminal?[edit | edit source]

  • 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.)
  • 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

History[edit | edit source]

  • 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[edit | edit source]

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: printenv, set
  • but particular environment variables can be displayed too: printenv PATH
  • to set up an environment variable: set VAR1=”something” where VAR1 is an arbitrary variable
  • to delete an environment variable: unset var1
  • displaying a particular one(same as printenv basically): echo $VAR1
  • to have the setting in the system permanently: export VAR1=”valami”
  • we can create an own command under /home/bin folder, 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[edit | edit source]

top in man help under Sparky Linux
  • help for using a command: help
  • command for the manual (detailed help): man, info
  • usage:
    • man <switches> <command>
    • info <switches> <command>