NECTES Global Media Technology Website.

Unix / Linux shortcut keys

0 75

Unix / Linux shortcut keys

Quick links
Introduction
Shortcuts are designed to help shorten the time required to perform frequently used commands or actions. In the below sections we have listed keyboard shortcut keys that can be performed by pressing two or more keys at once. In addition to keyboard shortcut keys, we have also listed command line shortcut keys that can be typed in at the shell.
Please note that the below shortcut keys and command line shortcuts will not work on all variants of Unix and/or Linux.
Keyboard shortcut keys
CTRL + B
Moves the cursor backward one character.
CTRL + C
Cancels the currently running command.
CTRL + D
Logs out of the current session.
CTRL + F
Moves the cursor forward one character.
CTRL + H
Erase one character. Similar to pressing backspace.
CTRL + P
Paste previous line and/or lines.
CTRL + S
Stops all output on screen (XOFF).
CTRL + Q
Turns all output stopped on screen back on (XON).
CTRL + U
Erases the complete line.
CTRL + W
Deletes the last word typed in. For example, if you typed ‘mv file1 file2’ this shortcut would delete file2.
CTRL + Z
Cancels current operation, moves back a directory and/or takes the current operation and moves it to the background. See bg command down the page for additional information about background.
Command line shortcuts

In addition to the below command line shortcuts, it is also helpful to use the alias command that allows you to specify a keyword for frequently used commands or mistakes.

~
Moves to the user’s home directory.
!!
Repeats the line last entered at the shell. See history command for previous commands.
!$
Repeats the last argument for the command last used. See history command for previous commands. down
reset
Resets the terminal if terminal screen is not displaying correctly.
shutdown -h now
Remotely or locally shuts the system down.
Linux / Unix background command
About bg
Continues a stopped job in the background. This function is not available on all Unix shell’s.
Syntax
bg [-l] [-p] [-x] [job]
-l
Report the process group ID and working directory of the jobs.
-p
Report only the process group ID of the jobs.
-x
Replace any job_id found in command or arguments with the corresponding process  group ID, and then execute command passing it arguments.
job
Specifies the job that you want to run in the background.
Examples
bg  – Lists the current running jobs.
Below is a listing of how to determine the type of job when looking at the job listing.
% or %+ or %%
for the current job.
%- or –
for the previous job.
Technical support
What causes stopped jobs?
Generally a stopped job will occur if the connection is interrupted or the commanded is interrupted with TSTP signals (typically CTRL + Z).
Linux / Unix face and history command
About fc and history
The ‘fc’ utility lists or edits and re-executes, commands previously entered to an interactive sh.
The ‘history’ utility allows you to use words from previous command lines in the command line you are typing. This simplifies spelling corrections and the repetition of complicated commands or arguments.
Syntax
CSH – C SHELL
history [-h] [-r] [n]
!
Start a history substitution, except when followed by a space character, tab, newline, = or (.
!!
Runs the last command that you ran.
!10
Re-run line number 10 in the history.
!-n
Refer to the current command line minus n.
!?str?
Refer to the most recent command containing str (string).
!str
Re runs the last command that you ran that starts with str (string).
KSH – KORN SHELL
fc [-e editor] [-n] [-l] [-r] [-s] [ first [ last ] ]
 
-e editor
Use the editor named by editor to edit the commands. The editor string is a utility name, subject to search via the PATH variable. The value in the FCEDIT variable is used as a default when -e is not specified. If FCEDIT is null or unset, ed will be used as the editor.
-n
Suppress command numbers when listing with -l.
-l
List the commands rather than invoking an editor on them. The commands will be written in the sequence indicated by the first and last operands, as affected by -r, with each command preceded by the command number.
-r
Reverse the order of printout to be most recent first rather than oldest first.
-s
Re-execute the command without invoking an editor.
first [last]
Select the commands to list or edit. The number of previous commands that can be accessed is determined by the value of the HISTSIZE variable. The value of first or last or both will be one of the following:
[+]number
 A positive number representing a command number; command numbers can be displayed with the -l option.
-number
A negative decimal number representing the command that was executed number of commands previously. For example, -1 is the immediately previous command.
string
A string indicating the most recently entered command that begins with that string. If the old=new operand is not also specified with -s, the string form of the first operand cannot contain an embedded equal sign.
Examples
Fc:
fc -l – Would list the history of commands on the computer similar to the following:
2 grep –help
3 bg
4 fg
5 pine
6 cd public_html
7 rm index.html
8 sz index.html
9 ls -laxo
10 chmod 755 index.htm
fc -e – ls – Would execute the last ls command.
History:
history – Typing history alone would give results similar to the following:
2 grep –help
3 bg
4 fg
5 pine
6 cd public_html
7 rm index.html
8 sz index.html
9 ls -laxo
10 chmod 755 index.htm
!ls – Would execute the last ls command.
!! – Would execute the last command executed.


Read More:
1 of 111
More Publications You Missed!
1 of 111