terminal tricks

About this page

This page differs a lot from another subjects that can be found in this gitbook, the use of this page is to make the user more comfortable with the Linux bash shell. Some things will differ in some cases, for example copying and pasting text within a linux shell. In this page, all the tips and tricks i've found can be seen here.

Tricks

Copy and paste in terminal

ctrl + shift + c # copy text selected with mouse cursor
ctrl + shift + v # paste text selected with mouse cursor
# in some terminal environments, just a normal usage of ctrl + c & ctrl + v is sufficient

Copy output from a tool to your clipboard

##### store temporary
root@Corrosie:~# alias setclip="xclip -selection c"
root@Corrosie:~# alias getclip="xclip -selection c -o"

##### store permanent
##### in order to store this parmanent edit the file ~/.bashrc  and add the following lines underneath the file:

# alias for setting something in the clipboard, and for getting the content out again with "getclip". It is also
# possible to use ctrl + v, or when in terminal ctrl + shift + v
alias setclip="xclip -selection c"
alias getclip="xclip -selection c -o"

##### usage
cat /etc/passwd | setclip
getclip

# this alias and the tool xclip can also be used if linux is not your native OS (for example if you got Linux installed as a VM)

Reference

this link will show you how to create permanent aliases in linux

Message all users on the system

lets say you are 1 of the 10 employees that is working on a remote Linux server and you want to message all other 10 employees directly through the linux terminal.

In this case/scenario you can make use of the linux tool wall

how to use wall

# syntax 
wall <message>

##### examples
wall hey
wall 'hey mate, how are you doing?'

Getting back to the start or end of your terminal line

You can use Ctrl+A to go to the beginning of the line and Ctrl+E to go to the end.

reverse search used commands

Within Linux it is possible to reverse-search for a command you have previously used. You can do this by going to your terminal and clicking ctrl + r. Once that is done you can type in the searchterm and it will autofill to complete the command! Hit enter to use the command

Example

Last updated