Key/ Comm and Description: Wednesday, 9 September 2020
Key/ Comm and Description: Wednesday, 9 September 2020
Key/
Comm Description
and
Go to the beginning of the line you are currently
typing on. This also works for most text input
Ctrl + A
fields system wide. Netbeans being one
exception
Go to the end of the line you are currently
typing on. This also works for most text input
Ctrl + E
fields system wide. Netbeans being one
exception
Ctrl + L Clears the Screen
Cmd +
Clears the Screen
K
Ctrl + U Cut everything backwards to beginning of line
Ctrl + K Cut everything forward to end of line
Ctrl + Cut one word backwards using white space as
W delimiter
Paste whatever was cut by the last cut
Ctrl + Y
command
Ctrl + H Same as backspace
Kill whatever you are running. Also clears
Ctrl + C
everything on current line
Exit the current shell when no process is
Ctrl + D
running, or send EOF to a the running process
Puts whatever you are running into a
Ctrl + Z
suspended background process. fg restores it
1
Wednesday, 9 September 2020
CORE COMMANDS
Key/
Comman Description
d
cd [folder] Change directory e.g. cd Documents
cd Home directory
cd ~ Home directory
cd / Root of drive
cd - Previous directory
ls Short listing
2
Wednesday, 9 September 2020
ls -l Long listing
ls -a Listing incl. hidden files
ls -lh Long listing with Human readable file sizes
ls -R Entire content of folder recursively
sudo
Run command with the security privileges of
[command
the superuser (Super User DO)
]
open [file] Opens a file ( as if you double clicked it )
top Displays active processes. Press q to quit
nano [file] Opens the file using the nano editor
vim [file] Opens the file using the vim editor
clear Clears the screen
reset Resets the terminal display
CHAINING COMMANDS
Key/Command Description
[command-a]; Run command A and then B,
[command-b] regardless of success of A
[command-a] &&
Run command B if A succeeded
[command-b]
[command-a] ||
Run command B if A failed
[command-b]
[command-a] & Run command A in background
PIPING COMMANDS
3
Wednesday, 9 September 2020
Key/
Description
Command
[command-a] Run command A and then pass the
| [command- result to command B e.g ps auxwww |
b] grep google
COMMAND HISTORY
Key/
Description
Command
Shows the stuff typed – add a number to
history n
limit the last n items
Interactively search through previously
Ctrl + r
typed commands
Execute the last command typed that starts
![value]
with ‘value’
Print to the console the last command typed
![value]:p
that starts with ‘value’
!! Execute the last command typed
!!:p Print to the console the last command typed
FILE MANAGEMENT
Key/
Description
Command
touch [file] Create a new file
pwd Full path to working directory
. Current folder, e.g. ls .
4
Wednesday, 9 September 2020
DIRECTORY MANAGEMENT
Key/
Description
Command
mkdir [dir] Create new directory
mkdir -p [dir]/
Create nested directories
[dir]
5
Wednesday, 9 September 2020
SEARCH
Key/Command Description
find [dir] -name Search for files, e.g. find /Users
[search_pattern] -name "file.txt"
grep
Search for all lines that contain the
[search_pattern]
pattern, e.g. grep "Tom" file.txt
[file]
grep -r Recursively search in all files in
[search_pattern] specified directory for all lines that
[dir] contain the pattern
grep -v
Search for all lines that do NOT contain
[search_pattern]
the pattern
[file]
grep -i
Search for all lines that contain the
[search_pattern]
case-insensitive pattern
[file]
6
Wednesday, 9 September 2020
mdfind -onlyin
Spotlight search for files named like
[dir] -name
pattern in the given directory
[pattern]
HELP
Key/Command Description
[command] -h Offers help
[command] --help Offers help
info [command] Offers help
Show the help manual for
man [command]
[command]
Gives a one-line description of
whatis [command]
[command]
apropos [search- Searches for command with
pattern] keywords in description
•