Cheatography
https://cheatography.com
Summary of basic UNIX concepts and commands
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Shell
Definition |
Command line interpreter program that functions as the default interface when you connect to a server over a network |
bash |
Default shell on Ubuntu and OSX. "Bourne-again shell." |
Terminal Prompt |
|
|
Logged in user name |
|
Machine name |
|
File system position |
|
|
Commands
About |
|
|
|
One-line explanation of cmd
|
|
Manual for cmd
if available |
|
Info about cmd
; use if man
is unavailable |
|
List commands with str
prefix |
History |
|
|
|
Repeat last command |
|
Repeat last command with str
prefix |
|
Scroll through history list |
Directing Output |
|
Append output of cmd
to file
|
|
Overwrite file
with output of cmd
|
|
Direct output of cmd1
to cmd2
|
Example$ echo "My new note" >> notes.txt $ cat notes.txt # My new note
|
Manuals
|
|
|
|
Navigate |
|
Help |
|
Quit |
|
Up |
|
Down |
|
Beginning |
|
End |
Search |
|
Start |
|
Stop |
|
Next |
|
Prev |
Directory Hierarchy
Absolute Path |
Route to desired dir. Always starts w slash or tilde, e.g. /home/john/myfile.txt
|
Relative Path |
From working dir. Never starts w slash, e.g. john/myfile.txt
|
Shortcuts |
|
Path of parent dir of current working dir |
|
Path of current working dir |
|
Path of home dir, e.g. $ echo ~ # user@host:/home/user/
|
|
Another user's home dir |
|
Root |
Environmental Variables |
|
Previous working dir |
|
Ordered, colon-delimited list of dirs in search when call is made from working dir |
|
ParsingColon-delimited; use tr
to replace, e.g. $ echo $PATH | tr ":" "\n"
|
|
Home DirectoryHome dir (e.g. /home/john
) is never in path, but its subdirs may be if working dir is a subdir of home. |
|
Python modules |
Useful Commands |
|
Print working dir |
|
|
|
To previous wd (i.e. $OLDPATH
) |
|
|
|
Get a long list - permissions, links count, |
|
Indicate file type *
exe /
dir |
|
Print special chars, including - | & ' ; ( ) < > space tab
|
|
All including hidden files with .
prefix |
|
All output in one column |
|
Recursive; include subdirs and contents |
|
Reverse sort order |
|
Sort by most recent modified |
|
Dirs only |
|
Search dir
and its subdirs for file specified by opts
expression, e.g. $ find . -name 'chap*' $ find . -mtime -2 $ find . -user john
|
|
|
Account
Configuration |
Update hidden programs run at login/shell start. |
|
Run with interactive bash shell |
|
Run at bash login before .profile
|
|
Run at login by most UINX shells |
Example |
Add lib to $PYTHONPATH
in ~/.bashrc
with export PYTHONPATH=/home/john/module/lib$PYTHONPATH
|
Useful Commands |
|
|
|
who you are logged in as |
|
set password |
|
logout of session and close terminal |
Permissions
Useful Commands |
|
Change permissions mode |
|
Usage |
|
$ chmod [ugoa][+-=][rwx], …, [path]
|
|
Groups |
|
|
User owner |
|
Other/system |
|
|
Group |
|
All |
|
Change Operator |
|
|
Add |
|
|
Remove |
|
|
Set Explicit |
|
Mode |
|
|
Read |
|
Execute file |
|
|
Write |
|
Access dir |
|
Octal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Examples |
|
Both the following examples grant all permissions to the owner of bin and read + execute permissions to the owner's group and others. $ chmod u=rwx,go=rx /home/john/bin
$ chmod 755 /home/john/bin
|
|