############# GNOME #############
Ctrl+Alt T — Terminal
Ctrl+Alt F — Firefox
Ctrl+Alt H — Home
Ctrl+Alt G — Gedit
Alt F12 — Run command
Alt F1 — Minimize window
Alt F2 — Toggle maximize window
Alt F3 — Toggle full screen
Ctrl+Alt D — Minimize all windows
Ctrl+Alt F1-F6 — Terminals (tty-s)
Ctrl+Alt F7-F12 — Xwindows
Ctrl+Alt Bksp — Restart X
Ctrl+Alt Del — Log out
Ctrl+Alt End — Shutdown
Super PgUp/PgDn — Switch workspace
Middle mouse button — Paste selected textNAUTILUS/NEMO:
Ctrl L — Location, show path
Ctrl+Shift N — New folder
Ctrl H — Show hidden filesGEDIT:
Ctrl G — Find next
Ctrl+Shift G — Find previous
Ctrl+Shift K — Clear highlightsTERMINAL:
Ctrl+Shift C — Copy
Ctrl+Shift V — Paste
Ctrl+Shift T — New tab
Ctrl+Shift W — Close tab
Ctrl PgUp/PgDn — Switch tab
Ctrl +/- — Zoom
Ctrl D — Close terminal
Ctrl S — Scroll lockBASH:
Keys when in emacs mode. You can switch to `vi` mode with `set -o vi` command.
Ctrl C — Interrupt, erase line
Ctrl A — Go to beginning of line
Ctrl E — End of line
Ctrl U — Copy line
Ctrl Y — Paste line
Alt . — Last argument
Ctrl R — Search trough history
Alt * — Show all matches for regular expression
Ctrl+Alt E — Show current line passed through alias, history and shell expansion
Ctrl X, Ctrl E — Edit command in editor
Ctrl P — Show last command (same as up arrow)################################# AWESOME TERMINAL COMMANDS #################################
========
PACKAGES:
========
dpkg — Low level package manager for Debian.
-l — Lists installed packages.
-i <package> (sudo) — Installs package from a package file.
apt-get — Advanced Package Tool built on top of `dpkg`. New command called
simply `apt` is also available. It merges the functionalities of
`apt-get` and `apt-cache`.
update — Updates local list of existing packages.
-u dist-upgrade — Upgrades by intelligently handling changing dependencies
with new versions of packages. To regularly update put this line
in `crontab`:
`apt-get update && apt-get -u dist-upgrade`.
upgrade — Same as dist-upgrade, but will not remove installed packages or
install new ones.
install <package> — Also updates single package.
remove <package> — Removes package but leaves its configurations.
remove apt-listchanges — Useful when Debian can't find a package.
purge <package> — Removes package and its configurations. Run `apt-get
autoremove` after to remove all dependencies that are not needed
anymore.
autoremove — Removes unneeded packages.
source <package> — Downloads code.
build-dep <package> — Installs the build dependencies.
--yes — Answers with 'yes' to most questions (Except the ones that can have
potentially harmful consequences).
--force-yes — Answers 'yes' to all questions (Not recommended).
apt-cache — Queries the APT's internal database.
search <keyword> — Searches packages like `apropos`, but globally.
show <package> — Shows package info like version, dependencies, etc.
showpkg <package> — Similar, but also shows the packages that depend on the
searched package (reverse dependencies).
policy <package> — Shows installed and remote version.
apt-file — APT package searching utility.
search <file> — Search in which package a file is included.
update — Updates local list of package contents.
aptitude — Enables package browsing (skin for apt-get).
search '~i!~M' — Lists installed packages that were not installed as a
dependency, with short description of each.
search <package> — Package search.
winetricks — Installs wine applications.
update-alternatives — Maintains symbolic links determining default commands.
unattended-upgrade — Automatic installation of security upgrades.COMMANDS:
apropos <cmd> — Searches the manual page names and descriptions (use quotes
for phrases).
-a — Matches all keywords.
whatis <cmd> — Displays one-line manual page description.
whereis <cmd> — Locates the binary, source, and manual page files for a
command.
which <cmd> — Locates only the binary of a command.
wtf — Translates acronyms and filename suffixes.INSTALL MANTRA:
```shell
./configure --help
./configure
make
sudo make install
=======
GENERAL:
=======
su — Switches user.
- — Switches to user.
- — Switches to root.
man — Help on commands.
<section> — Section numbers: 1. Programs, 2. System calls, 3. Library calls,
4. Special files, 5. File formats, 7. Miscellaneous, 8. System
administration commands
echo — Prints passed text.
-n — Does not add newline at the end.
-e — Enables interpretation of backslashed letters.
xargs — Passes output from one command to arguments of another:
`echo -a | xargs ls`
-t — Echoes the command before executing it.
-p — Echoes command and asks for confirmation before execution.
-0 — Input items are separated by null character instead of space.
tee — Sends output of a program to specified file and to standard
output:
` | tee out_1.txt | `
/dev/tty — Sends output to terminal and to standard output
expr — Evaluates passed expression.
1 + 1 — Prints `2`.
bc — Evaluates input. It's basically a calculator, but also provides some
control commands.
echo 1 + 1 | bc — Prints `2`.
echo "scale=5;3/4" | bc — Prints `.75000`.
sh — Runs command interpreter (shell). Can run a script even if not executable.
-c '' — Starts new non-interactive shell and reads commands from
arguments instead of `stdin`.
To append lines to system configuration file run:
`sudo sh -c 'echo "" >> '`
bash — Runs bash command interpreter (shell).
-c — Reads commands from arguments instead of `stdin`.
-n
FILES:
ls -d — List directory names instead of contents
-S — Sort by size
-t — Sort by time
-1 — One file per line
./* — Ls one level deep
-i — Get inode number of file (file id). Use sudo find / -inum <number> to find all links that point to same file.
cp -i — Interactive (Prompts before overwrite)
-v — Verbose (Explains what is being done)
-R — Copy directories recursively
-p — Preserve mode, ownership and timestamps
–preserve=all — Also preserves context, links and xattr
rm -i — Interactive (Prompts before every removal)
-v — Verbose (Explains what is being done)
-f — Force remove (Does not prompt, useful if rm is aliased with -i)
-R — Removes directories and their content recursively
mkdir -p — Make parents if needed
ln — Makes links to the files
-s — Makes symbolic link. If you want to use relative paths you must be in links directory !!!!!!!!!!!!!!!!!!!!!!
df -h — Displays humanly readable free disk space
du -s — Directory size
mc — Midnight commander
Alt o — Open parent dir in another panel
Ctrl o — Switch to bash
find -name — Search by name
-regex — Use regex for name search
-not — Insert before other options to negate
-maxdepth — Descend only to levels deep
-samefile — Find all hard links of a file
-xdev — Don't descend directories on other filesystems
-inum — Find files with the inode number
-type <f|d|b|...> — Find files of type
-delete — Delete found files
-exec {} \; — Find files and execute command for every found file. `{}` is replaced with filename
-exec {} + — Find files and execute command with all filenames in place of `{}`
-atime +/-n — Find files that were last accessed less or more than n days.
-print0 | xargs -0 — Sends found files to a command as parameters. Uses `NUL` character as separator, necessary for filenames with spaces
locate — Similar as `find` but using index
-i — Ignore case
--regex — Interprets all patterns as extended regex
-0 | xargs -0 — Sends found files to a command as parameters.
updatedb (sudo) — Update locate index
md5sum — Prints md5 sum hash of a file
read — Read single line from standard input
-n 1 — Print after reading one character
-s — Do not echo input coming from terminal
shred — Securely remove files
file — Determine file's type
tree — Ls in a tree-like (hierarchical) format
install — Copy files and set attributes
gpg — Decrypt file with password
-c — Encrypt
mktemp — Create a temporary file or directory in `/tmp` and returns it's name.
rename s// — Renames multiple files using `sed` syntax
rsync — A fast, versatile, remote (and local) file-copying tool
-Hbaz -e ssh — `@:` - Backs up the 'src-dir':
`-H` preserves hard links, `-b` renames preexisting destination files (back up), `-a` preserve everything except hard links and `-z` compresses.
cmp — Compares two files, similar to diff but also for binaries
stat — Displays files status
-c%X — Time of last modification of the file
readlink -f — Follow link recursively and print files path
xdg-open — Open file with default application for the file type
dialog — Display dialog box from shell script
watch — Execute command periodically
ARCHIVES:
dtrx — Universal archive extractor
tar — xvzf .tar.gz (.tgz) — Decompress and detar
xvjf .tar.bz2 — Decompress and detar
-cf .tar — Compress
unzip \*.zip — Backslash is necessary so that bash doesn't expand the `*`
-d — Extract into directory (create if doesn't exist)
zip -r — Compress whole directory recursively.
-g — Add files to existing archive (grow).
unrar e — Extract files from rar archive
zcat — Cats gziped file
TERMINAL MULTIPLEXERS:
screen — Switch between multiple virtual terminals (useful in ssh). Prefix for
a command is Ctrl a.
c — New terminal,
n — Next,
p — Previous,
a — Go to beginning of line,
| — New region vertically,
S — New region horizontally,
tab — Move to next region,
Q — Close all but selected region,
X — Kill the current region,
esc — Enter copy/scrollback mode -> space: start/stop marking,
] — Paste,
k — Kill window,
t — Show time and avg CPU load
tmux — Terminal multiplexer, better screen. Prefix for a command is Ctrl b.
Most commands are the same as in screen.
ls — Shows running sessions
attach [-t ] — Attach to running session
d — Detach from currently attached session
pgup — Enter in copy mode and pageup,
[ — Copy mode,
] — Paste,
" — Split horizontally,
% — Split vertically
====
BASH:
====
“$x” — ALWAYS PUT DOUBLE QUOTES AROUND VARIABLE!!!!!!!!!!!!!!!
All variables in bash are global!!!!!!!
“$” — Combines all the arguments into single word, separating them with first character of IFS variable. If IFS is not set, space is used. If IFS is null, no separator is used!!!!!!!!! No args provided will result in one empty string being passed on!!!
“$@” — Use this instead!!!!! Will retain arguments as-is, so no args provided will result in no args being passed on. This is in most cases what you want to use for passing on arguments.
Google: “$@” is right almost everytime, and $ is wrong almost everytime.
“$#” — Number of arguments
“$1” — First argument
“$0” — Name of the script
$’\n’ — String literal with escape sequences (there is a backslash before n)
If you want IFS to be a new line (useful with for loop) you need to: IFS=$'\n' - The dollar forces substitution!!!!!
Also if you want ‘while read line; do…’ to preserve leading spaces and tabs, you need to set IFS=””
$? — Exit code of last command (0 - Success)
Ctrl-Z, kill %% — Kill looping bash script
test — Same as `[ ]`. Returns zero exit status if true.
-n — Is string non empty
-z — Is string empty
-a — And
-o — Or
= — Strings are equal
-nt — File newer than
-ot — Older then
-d — Directory exists
-e — File exists
-f — Is a regular file
-h — Its a symbolic link
-r — Has read permission
-w — Has write permission
-x — Has execute permission
[[ ]] — Same as `[`, but without word splitting and filename expansion. And with additional operators: `&&`, `||`, `<`, `>` (lexicographic less, more), and also regular expression matching.
=~ — Regex comparison operator: `[[ "$HOST" =~ ^user.* ]]`
let — Executes expression: let a="$b"+2
$(command) — Same as command
eval — Execute string as command
$RANDOM — 0 - 32767
input=`cat` — Getting standard input
— In place of a file name means standard in or out
set -o vi — Set line editing to vi mode
pushd . — Put current dir on stack
popd — Pop dir from stack
cd - — go to last dir
source
SAFETY:
set — -e — Exit if any command fails
-u — Exit if referencing undefined variable
-o pipefail — If any command in a pipeline fails, its return code is used as the return code of the whole pipeline
IFS=$’\n\t’ — Remove space from the default Internal Field Separator
HISTORY:
sudo !! — Run the last command as root
␣ — Execute a command without saving it in the history
! — Run last command that starts with cmd
REDIRECTIONS:
2> /dev/null — Redirect error output to `null`
&> /dev/null — Redirect both standard and error output to `null`
>&2 — Write to stderr
2>&1 | less — Add stderr to stdout and print it with less (useful for gcc)
ARRAYS AND LINES:
Reads line by line from variable. To preserve spaces use `IFS=`.
while IFS= read -r line; do
echo "... $line ..."
done <<< "$list" —
${a[1]} — Value of the second element of the array
for c in ${a[@]} — Iterate over array
${varname:offset:length} — Get substring: `s="aeiou"; ${s:3:1} -> o`
${#var} — Length of a var
${#name[subscript]} — Length of the element
${#name[@]} — Length of the array
ALIASES AND FUNCTIONS:
alias — Print all aliases
— Print alias
='cmd' — Set alias
command — Executes original command, bypassing any aliases or shell functions that may be defined for command
\ — Temporarily disable alias (call original)
type — Will tell you what is command aliased to or if it is a builtin, function or a command
-P just check commands
declare -F — Print function names
declare -f — Print functions
====
TEXT:
====
PRINT:
head — -n- — Print all lines but the last n
-c — Print first c characters
tail — -n+ — Start at line number
-f — Do not stop printing (follow)
cat — -n — Number all lines
>> file — Simplest text editor (great for pasting)
less & — Display only lines with pattern
-N — Show line numbers
-~ — Do not show `~` after `EOF`
+G — Tells less to start at the end of the file
+F — Follow the input (to scroll up first press ctrl+c)
-F — Or --quit-if-one-screen
v — Opens editor defined in `$VISUAL` or `$EDITOR`
:n — Examine the next file
<, > — Go to home, end
wc — Count lines, words and characters
EDIT:
sudo -e — Edit file as sudo
tr — Translate characters
-d — Delete characters
cut — Removes columns from each line of files
-d ':' -f 1,7 /etc/passwd — Only show the username and the shell
sort — Sorts lines
-u — Uniq, removes duplicates
-t — Set delimiter for fields (default is space)
-k — Select by which field to sort
uniq — Removes adjacent duplicates
-c — Count
-d — Intersection
-u — Difference
column — Columnate text
-t — Create a table
shuf — Shuffle input lines
tac — Concatenate and print files in reverse (reverse `cat`)
join — Join lines of two files on a common field
colrm [from [to]] — Removes columns
seq — Output numbers from 1 to number
ispell, aspell — Interactive spell checker
basename — Strips directory from path
-s . — Also strip suffix
-a — Process multiple filenames
dirname — Strip last component from path
fmt — Produce roughly uniform line lengths
fold — Wrap each input line to fit in specified width
paste — Glue two documents side by side
sed — 's///g' — Substitute every occurrence in line, not just the first one
's///I' — Ignore case
-r — Extended syntax, for `+`, `?`, ... Also you shouldn't escape the parenthesis
-r 's###e' — Execute match as a command
-i — Will make changes directly to the file (in place)
-u — Unbuffered mode (processes input immediately)
-n l — Print escape sequence (keycode) of a pressed key
expand — Convert tabs to spaces
-t — Set number of spaces (default is 8)
-i — Do not convert tabs after non blanks
DIFF:
diff — -u — Unified format
--brief -r — Compare two directory trees
colordiff — Version of diff with colors
sdiff — Two files side by side
comm — Compare two sorted files line by line
patch — Apply a diff file to original
patch < patch.diff — Apply patch
diff -u > patch.diff — Create patch
SEARCH:
grep — -v — Inverse
-n — Line numbers
-w — Whole word
-A — Print also num lines after
-B — Print also num lines before
-r — Recursive
-o — Print only matching part
-P — Perl notation with additional operators such as: `\\t`, `+` and `?` (non-greedy!!!!).
-i — Ignore case
-I — Do not process binary files
-l — Just print files with matches
-L — Just print files without matches
-e — Necessary to put before pattern if it starts with `-`!!!!!!! or if you want multiple patterns.
| wc -l — Count occurrences
--line-buffered — Processes input line by line instead of in bigger chunks
look — Display lines beginning with a given string
strings — Print all text parts of binary file
CONVERT:
todos, fromdos — Convert line endings form/to windows format (package tofrodos)
enscript — Converts text files to postscript, rtf, HTML
gs — Ghostscript: postscript and PDF language interpreter and previewer
pdftohtml — Pdf to html
pdftotext — Pdf to text
libreoffice — New Openoffice
figlet — Display large characters made up of ordinary screen characters (Ascii art)
toilet — Similar (Ascii art)
cproto — Generates C function prototypes (declarations)
EDITORS:
nano — Simple text editor.
/etc/nanorc — Config file.
/usr/share/nano/.nanorc — Syntax highlight files.
Alt + / or ? — Go to last line.
fte — Cool text editor with CUA (IBM)-shortcuts
diakonos — Simple terminal text editor with ctrl-c for copy
pyroom — Distraction free writing (gui)
=======
NETWORK:
=======
whois — Info about domain
host <ip/hostname> — DNS lookup utility
nslookup — Same interactively
dig — Same, lot of options
hostname — Prints/sets computer name, to set it permanently edit `/etc/hostname` and `/etc/hosts`
netstat — Displays contents of /proc/net files, status of ports...
-r — Show routing table
-i — Show interfaces
arp — Manipulate the system ARP cache (IP -> mac)
route — Tool used to display or modify the routing table
add default gw — Change the default gateway
should DNS not be configured correctly on your machine, you need to edit `/etc/resolv.conf` to make things work
ifconfig eth0 down/up (sudo) — Turn network interface on/off
netmask up — Set ip and mask
ifup eth0 — Will bring eth0 up if it is currently down.
ip link show — List network interfaces
link set dev eth0 up — Bring interface eth0 up or down
addr show — List addresses of interfaces
route add default via — Set default gateway
traceroute, traceroute6, traceroute6.iputils — Traces route
tracepath, tracepath6 — Similar (iputils package)
mtr — Combines the functionality of the traceroute and ping
findsmb — List info about machines that respond to SMB name queries - Windows based machines sharing their hard disks
/etc/services — List of internet services with their port numbers
NetworkManager — Network management daemon, configuration file is in /etc/NetworkManager/NetworkManager.conf
nm-tool — Prints info
nm-online — Is network connected
nmcli — Command-line tool for controlling NetworkManager
nc — (netcat) It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning...
ncat — Concatenate and redirect sockets
ethtool eth0 — Show status of eth0
-S — Statistics
-s — Change settings (speed, duplex,...)
ss -tupl — List internet services on a system
-tuo — List active connections to/from system
WIRELESS:
iwconfig — Sets the wireless configuration options basic to most wireless devices
iwlist wlan0 —