Hints and tricks¶
This section contains some hints that might make working with Linux easier.
Tab auto-complete¶
If you press TAB on the keyboard after starting to type a command or a file, it will auto-complete if no other matches or else suggest possible matches.
Short-cuts on the CLI¶
CTRL-SOMEKEY refers to pressing down the CTRL key and then another key while continuing to hold down CTRL.
Examples:
- CTRL-a: Go to the beginning of the line
- CTRL-e: Go to the end of the line
- CTRL-l: Clear the terminal
- TAB: Auto-complete (i.e. start write a command or file name and then press TAB to auto-complete as far as possible
- ARROW-UP: Pressing the arrow-up key repeatedly will let you cycle through recent commands
- CTRL-r: you will get a prompt to write text to search in the list of recent commands. The list is saved in
.bash_history
in your $HOME. On some systems it might be called.bash.history
Finding help¶
You can often get more info on the usage of a Linux command. This includes options and flags. Depending on the setup of your system either or both of the following should succeed:
COMMAND --help
man COMMAND
where COMMAND is the Linux command you want information about, like ls
, mkdir
, gcc
, etc.
Misc¶
- Type
clear
to clear the terminal - Type
history
to see a list of the recent commands used in the terminal- You can change the number of saved commands by setting the environment variable HISTSIZE in your
.bashrc
file in your home directory. - Example: Open
.bashrc
withnano
. Somewhere (at the end for instance) add:export HISTSIZE=NUMBER
whereNUMBER
is the number of commands to save, for instance 500.
- You can change the number of saved commands by setting the environment variable HISTSIZE in your
Warning
Passwords in the history file
If you enter a password (e.g. login password for a computer or website) at the command prompt and hit return, the password will be included into the .bash_history
file once you log off. Neither the password nor the history file are encrypted in any way. In particular when using a shared system such as offered by NAISS, it is best to reset the password on the computer or website where you have been using it, to a new value.