Posted: . At: 2:08 PM. This was 11 years ago. Post ID: 5318
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

More useful bash shell tricks. How to use keyboard shortcuts to navigate the shell easily.

Anime screenshot firewall logs.
Anime screenshot firewall logs.

Ubuntu surely is a popular desktop Linux distribution, shown around the world in television shows and on sale in China preloaded onto computers. Advertised more than Linux Mint even though that is a good Windows and Macintosh alternative as well and performs on the desktop just as well as Ubuntu. To clear the terminal window, press Ctrl-l. This will clear the screen just as if you had typed the clear command. There is a full listing of the bash keyboard shortcuts here: http://dev-ops.net/2011/02/02/bash-shortcuts-on-the-command-line/. Another one is Ctrl-m, this executes commands that you have typed at the bash prompt instead of pressing RETURN. I am not sure how useful this is but it is there if you need it.

There are more examples here: http://www.securitronlinux.com/bejiitaswrath/how-to-create-a-dot-matrix-banner-with-linux-and-many-other-cool-tricks/.

And this post has some even better tricks: http://www.securitronlinux.com/bejiitaswrath/cispa-bill-still-a-threat-and-awesome-linux-shell-tricks/.

There are many useful tips that you can use with the bash shell that comes with Ubuntu. One is to list all the environment variables that are available on the shell. Simply type the $ character and then press the TAB key twice. This will print out all of the possible candidates. This is very useful when you want to find a certain environment variable and you are not sure what it is called.

ubuntu@ubuntu:/media/Stuff/Media$ $
$_                           $DEFAULTS_PATH               $LANG                        $PWD
$BASH                        $DESKTOP_SESSION             $LESSCLOSE                   $RANDOM
$BASH_ALIASES                $DIRSTACK                    $LESSOPEN                    $RUNNING_UNDER_GDM
$BASH_ARGC                   $DISPLAY                     $LINENO                      $_scp_path_esc
$BASH_ARGV                   $EUID                        $LINES                       $SECONDS
$BASH_CMDS                   $GDM_KEYBOARD_LAYOUT         $LOGNAME                     $SESSION_MANAGER
$BASH_COMMAND                $GDM_LANG                    $LS_COLORS                   $SHELL
$BASH_COMPLETION             $GDMSESSION                  $MACHTYPE                    $SHELLOPTS
$BASH_COMPLETION_COMPAT_DIR  $GNOME_DESKTOP_SESSION_ID    $MAILCHECK                   $SHLVL
$BASH_COMPLETION_DIR         $GNOME_KEYRING_CONTROL       $MANDATORY_PATH              $SSH_AGENT_PID
$BASH_LINENO                 $GROUPS                      $OLDPWD                      $SSH_AUTH_SOCK
$BASHOPTS                    $GTK_MODULES                 $OPTERR                      $TERM
$BASHPID                     $HISTCMD                     $OPTIND                      $UID
$BASH_SOURCE                 $HISTCONTROL                 $ORBIT_SOCKETDIR             $USER
$BASH_SUBSHELL               $HISTFILE                    $OSTYPE                      $USERNAME
$BASH_VERSINFO               $HISTFILESIZE                $PATH                        $WINDOWID
$BASH_VERSION                $HISTSIZE                    $PIPESTATUS                  $WINDOWPATH
$COLORTERM                   $HOME                        $PPID                        $XAUTHORITY
$COLUMNS                     $HOSTNAME                    $PS1                         $XDG_CONFIG_DIRS
$COMP_WORDBREAKS             $HOSTTYPE                    $PS2                         $XDG_DATA_DIRS
$DBUS_SESSION_BUS_ADDRESS    $IFS                         $PS4                         $XDG_SESSION_COOKIE

Pressing Ctrl-p will print the last executed command back to the bash prompt ready to be executed once again. To print the first character of the contents of an environment variable, use this syntax.

ubuntu@ubuntu:~$ echo ${LOGNAME^}
Ubuntu

And this syntax will convert all of the text into uppercase.

ubuntu@ubuntu:~$ echo ${LOGNAME^^}
UBUNTU

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.