User Tools

Site Tools


devop:terminal

Linux Terminal / bash

Shutdown later (at)

https://www.computerhope.com/unix/uat.htm

when leaving office with running processes

sudo at 20:55
shutdown -h now
  # press Ctrl + d

# relative:
sudo at now + 2 hours
sudo at now + 30 minutes

Lock screen (usually Windows key + L) and leave

Bash Console tricks

Tab key

try tab for autocompletion - sometimes even twice

to previous directory

cd -

to home directory

cd ~
# or simpler:
cd

browse/search history

  • simply use arrow up/down

or

  • Ctrl + r and continue with search term
  • Ctrl + r again for multiple/next match
  • Ctrl + c to abort

or

history |grep term

keyboard shortcuts

check all with bind -p

  • Alt + . prints last argument from previous command
  • Ctrl + x + * expand glob/star
  • Ctrl + arrow move by word
  • Alt + f move to next word
  • Alt + b move to prev word
  • Ctrl + u to delete line to begin of line
  • Ctrl + k to delete line to end of line
  • Ctrl + l clear screen (lower L)

aliases and functions

reuse/insert last item from previous command

  • write !$
  • Alt + .

reuse/insert full last command line, e.g. for sudo

sudo !!

combine multiple commands

  • ; execute sequentially
  • && execute next on success
  • || execute next on fail - until first success

following command prints just “hello”

false || false || echo hello || echo world

display output as table

cat /etc/passwd | column -t -s :

history handling with multiple terminals

nano: delete line(s)

https://monovm.com/blog/how-to-delete-line-in-nano-delete-all/

  • Ctrl + Shift + 6 starts mark
  • Ctrl + K deletes marked region
devop/terminal.txt · Last modified: 2023/12/26 (external edit)