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

Posted: February 2, 2013. At: 2:08 PM. This was 5 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.

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: 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:

And this post has some even better 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_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.

[email protected]:~$ echo ${LOGNAME^}

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

[email protected]:~$ echo ${LOGNAME^^}

No comments have been made. Use this form to start the conversation :)

Leave a Reply