Linux notes

Various uncategorized Linux notes

Shell, consoles, environment

man searches for files under $MANPATH
Files under $MANPATH can be displayed on the screen with
nroff -man filename

MAILCHECK=300
shell checks for new e-mails every 5 minutes

echo $SECONDS
How long shell has been running

MAIL=””
turn off mail call

fgconsole
Display console number

Alt+
Switch to left or right console

Alt + Print Screen
Switch to the previous console

chvt N
Switch to console N

reset
Resets terminal

last
Reads information from file /var/log/wtmp

apropos keyword
Search for keyword in the documentation

apropos is an alias for man -k

whatis keyword
One line description of a program keyword

info files are located under /usr/info directory
If info file is located somewhere else it’s possible to use
info -f filename.info

To pass special characters as a string – add $ in front
Example:

echo Hello$'\n\n'

Special characters

\b backspace
\e escape
\n newline
\t horizontal tab
\v vertical tab
\NNN character whose ASCII code is NNN in octal (base 8)

Display .gz files on the fly without gunzip

zless filename.gz

EMACS style key bindings

Key Sequence Action
Ctrl + K Kill or cut all the text
Ctrl + U Kill everything on a command line to the left of the cursor
Ctrl + Y Paste the text that was killed
Ctrl + A Cursor to the beginning of line
Ctrl + E Cursor to the end of line
Alt + F Move cursor forward one word
Alt + B Move cursor backward one word

Undoing mistakes on command line

Key Sequence Action
Ctrl + T Transpose 2 characters before cursor
Alt + T Transpose 2 words before cursor

Changing prompt

Variable PS1 is responsible for prompt
\d current date
\h hostname
\n newline
\t current system time in 24 hour format
\@ current system time in 12 hour format
\w current working directory
\u user name
\! history number of this command

This entry was posted in Linux and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *