LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-02-2012, 10:33 PM   #1
dEnDrOn
Member
 
Registered: Jun 2011
Location: oMNipre$ent
Distribution: fedora
Posts: 511
Blog Entries: 12

Rep: Reputation: Disabled
what are the most common linux terminal shortcuts that you use ?


i'm not so good with linux terminal...

please elaborate some useful shortcuts that may improve my terminal working experience...
 
Old 01-02-2012, 11:38 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
These are the ones I use absolutely all of the time:

<Ctrl>-<Shift>-t -- new tab in gnome-terminal
<Ctrl>-a -- go to start of line
<Ctrl>-e -- go to end of line
<Ctrl>-k -- kill till end of line
 
2 members found this post helpful.
Old 01-02-2012, 11:40 PM   #3
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
http://lmgtfy.com/?q=bash+shortcuts

That being said...
Some of my most used are
-> tab autocompletion
-> shell variables
-> bang (!) and its variants
-> ctrl + r
and
-> alias'

Last edited by fukawi1; 01-02-2012 at 11:42 PM.
 
1 members found this post helpful.
Old 01-02-2012, 11:59 PM   #4
kabish
LQ Newbie
 
Registered: Dec 2011
Location: Alaska
Posts: 5

Rep: Reputation: Disabled
Ctrl+A – move to the start of the line
Ctrl+E – move to the end of the line

Ctrl+U – delete/cut from the cursor to the beginning of the line.

Ctrl+K – delete/cut from the cursor to the end of the line

Ctrl+W – delete/cut from the cursor to the start of the word, space delimited
 
1 members found this post helpful.
Old 01-03-2012, 12:43 AM   #5
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
for commands that require a lot of arguments that need to be issued the same way every time i do

$ history | grep command (minus the arguments)
for instance
$ $history | grep vlc
Code:
   27  vlc *.avi
   29  vlc *.avi
  259  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen cho.xspf
  264  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen cho.xspf
  270  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen cho.xspf
  281  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen cho.xspf
  284  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen cho.xspf
  286  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen cho.xspf
  302  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen *
  305  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen *
  306  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  318  vlc sniper.avi
  408  vlc *Duck*
  425  vlc *.avi
  608  history| grep vlc
  609  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  610  history| grep vlc
  611  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  613  history| grep vlc
  615  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  639  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  641  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  757  killall -9 vlc
  877  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  879  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  882  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  883  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  886  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  888  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  891  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  893  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  894  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  895  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  897  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 .avi
  898  vlc
  900  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  901  killall -9 vlc
  902  sudo killall -9 vlc
  905  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  907  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  909  COLUMNS=132 DISPLAY=:0.1 vlc --extraintf=curses --fullscreen  --aspect 16:9 *
  912  COLUMNS=132 DISPLAY=:1.1 vlc --extraintf=curses --fullscreen --aspect 16:9 *
  913  DISPLAY=:1.1 vlc
  914  DISPLAY=:1.1 vlc *
  915  DISPLAY=:1.1 vlc *.avi
  917  DISPLAY=:1.1 vlc *.avi
  919  DISPLAY=:0.1 vlc --extraintf=curses *
  932  vlc *.webm
  941  vlc *
  942  DISPLAY=:0.1 vlc *
  943  DISPLAY=:1.1 vlc *
  964  cd vlc
 1019  history | grep vlc
node the number, in my case it would be 912 would be the last time i issued the command

then

$ !912
will re-issue that command
 
Old 01-03-2012, 12:49 AM   #6
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
Quote:
Originally Posted by frieza View Post
for commands that require a lot of arguments that need to be issued the same way every time i do

$ history | grep command (minus the arguments)
for instance
$ $history | grep vlc
frieza, you may be interested to know, you can use "ctrl + r" and type "vlc" to reverse incremental search the history.
Pressing ctrl+r repeatedly again, to scroll through the matched entries, until you find the one you want.
 
Old 01-03-2012, 01:32 AM   #7
linux-freak
LQ Newbie
 
Registered: Jan 2012
Posts: 10

Rep: Reputation: Disabled
Terminal tip - brace exapansion

Code:
mkdir -p Months/{Jan,Feb,Mar,Apr,May,June,Jul,Aug,Sep,Oct,Nov,Dec}/{Week1,Week2,Week3,Week4}/{Mon,Tues,Wed,Thu,Fri,Sat,Sun}
This will create a folder called Months with subfolders of the months
and each sub month folder will have subfolders from Week1 through Week4
and each Week* folder will have subfolders of the days of the week

This is good for making folders that each would have things in common

Try it out and you see what I mean.

Bet no GUI file manager could top that

Last edited by linux-freak; 01-03-2012 at 02:36 AM.
 
Old 01-03-2012, 02:32 AM   #8
linux-freak
LQ Newbie
 
Registered: Jan 2012
Posts: 10

Rep: Reputation: Disabled
Terminal tip - Repeat a word without re-typing

for example type

ls /etc/fstab

Suppose you want to work on this file, then type vi and then a space. Press the ESC key, then the period '.'

/etc/fstab will appear next to vi
 
3 members found this post helpful.
Old 01-03-2012, 02:55 AM   #9
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Quote:
Originally Posted by linux-freak View Post
Terminal tip - Repeat a word without re-typing

for example type

ls /etc/fstab

Suppose you want to work on this file, then type vi and then a space. Press the ESC key, then the period '.'

/etc/fstab will appear next to vi
You could do the same with:
Code:
vi $_
 
Old 01-04-2012, 07:05 PM   #10
linux-freak
LQ Newbie
 
Registered: Jan 2012
Posts: 10

Rep: Reputation: Disabled
Terminal tip - brace expansion 2 Backup and Copy

Most people make a backup copy of a file this way

cp foo.bar foo.bar.bak

With brace expansion you can get the same result

cp foo.bar{,.bak}

If your file has no extension like foo for example

cp foo{,.bak}

To copy a file with a different extension

cp foo{.bar,.ext}

Last edited by linux-freak; 01-04-2012 at 07:13 PM.
 
Old 01-04-2012, 08:22 PM   #11
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 148Reputation: 148
Here's what's in my cheat-sheet.txt right now for Bash. I don't use all of these regularly, but they have all been useful on some occasions.

Code:
** CURSOR MOVEMENT **
C-f, C-b	forward, backward one character
M-f, M-b	forward, backward one word
C-a, C-e	start, end of line
C-], M-C-]	search next, previous occurrence of character in line

** DELETING **
<Backsp>	character left of cursor
<Del> | C-d	character under cursor

** MISCELLANEOUS EDITING **
C-_ | C-x C-u | C-/	undo last edit
C-t	transpose character left of cursor
M-t	transpose word left of cursor
M-u	uppercase word
M-l	lowercase word
M-r	undo all changes to this line
C-l	clear screen and continue editing current line
C-x C-e	edit the current line in the $EDITOR

** COMPLETION **
<Tab>	complete text before point
M-?	list all completions
M-*	insert all completions
M-~	force tilde completion

** KILLING AND YANKING TEXT **
C-k	kill from cursor to end of line
C-u	kill from cursor to start of line
M-- C-k	kill from cursor to start of  line
M-d	kill from cursor to end of word
M-<Backsp>	kill from cursor to start of word
C-w	kill from cursor to previous whitespace
C-y	yank most recently killed text at cursor
M-y	rotate kill-ring and yank
	
** RECALLING FROM HISTORY **
C-p, C-n	recall previous, next line from history
M-<	recall first line from history
M->	recall last line from history
M-p, M-n	reverse, forward search (non-incremental)
C-r, C-s	reverse, forward i-search
<Return>	accept and execute line
C-a | <Esc>	accept and edit at start of line
C-e	accept and edit at end of line
C-g	abort i-search and restore original line

** REPEATING COMMANDS **
<Esc> n	(where n represents an integer)
M-n	(only first digit need be metafied)
C-x (	begin keyboard macro definition
C-x )	end keyboard macro definition
C-x e	execute keyboard macro
HTH

EDIT
In the absence of further documentation, the list above may seem quite arcane to the uninitiated. As this is a cheat sheet intended for my personal use I only recorded enough information to remind myself. Here's the full documentation:

Command Line Editing - Bash Reference Manual

I use Bash in its default Emacs mode. If you have configured Bash for vi mode or otherwise customized its key-bindings then none of the shortcuts above apply to your configuration.

The notation C-p means to press and release the p key while holding the Ctrl (control) key.

The notation M-f means to press and release the f key while holding the Meta key. Typical modern PC keyboards don't have a key labeled Meta. Use the Alt key instead.

Last edited by Telengard; 01-04-2012 at 11:23 PM. Reason: more information
 
1 members found this post helpful.
Old 01-04-2012, 11:05 PM   #12
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
I barely know how to use Emacs. But several of the hotkeys I mentioned earlier do work there, too. I wonder -- to what extent do Emacs shortcuts carry over into the Bash shell?
 
Old 01-04-2012, 11:54 PM   #13
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by jhwilliams View Post
to what extent do Emacs shortcuts carry over into the Bash shell?
A great deal of the most common Emacs keyboard shortcuts work similarly in Bash's default Emacs mode. If you learn the shortcuts in Bash, as I did, then Emacs becomes that much easier to learn.
 
Old 01-05-2012, 12:05 AM   #14
polpak
Member
 
Registered: Jan 2011
Location: Planet Earth, Australia, NSW
Distribution: GNOME openSUSE Leap/Ubuntu
Posts: 189

Rep: Reputation: 21
Being Technically-Challenged, rarely use shortcuts, also make enough typing errors typing commands, so need learn and remember them first ;-)
 
Old 01-05-2012, 02:24 AM   #15
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
Thumbs up

Quote:
Originally Posted by linux-freak View Post
Terminal tip - Repeat a word without re-typing

for example type

ls /etc/fstab

Suppose you want to work on this file, then type vi and then a space. Press the ESC key, then the period '.'

/etc/fstab will appear next to vi
That is possibly the most useful thing I will learn all week!
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] XFCE Terminal cannot bind shortcut keys, how do I disable all shortcuts ? H_TeXMeX_H Linux - Software 1 06-05-2011 04:54 AM
changing keyboard shortcuts for switching tabs in gnome-terminal and/or tilda ssgosh Linux - Desktop 4 06-16-2010 11:21 PM
Keyboard shortcuts within terminal? hippiejake Linux - Software 6 11-30-2009 10:41 AM
What are the common keyboard shortcuts lilkar Linux - Newbie 8 11-01-2009 05:18 AM
Why is my common account can't open Terminal in XFCE4 but root account? notsay Slackware 4 08-18-2007 11:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration