Cheatography
https://cheatography.com
NOS-120 Commands & Command Options (but for CPCC this time)
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Keyboard Shortcuts
Shortcut |
What It Does |
Notes |
Esc + . |
Insert last argument entered |
Repeat to go back to previous arguments |
Up Arrow |
Auto-fill last command entered |
Repeat to go back to previous commands |
Ctrl+D |
Logout / Exit |
Ctrl+L |
Clear terminal output |
Ctrl+Shift+T |
Open new terminal tab |
Ctrl+Arrow (Right/Left) |
Move to beginning/end of a word |
Wildcards & Shortcuts
Wildcard |
What It Represents |
Example |
|
Current user's home directory |
|
The directory you're currently in |
|
Parent directory of your current directory |
|
All files in current directory |
ls i*
= all files starting with "i" |
|
"Any character" |
f??e
matches anything with 4 characters that starts with "f" & ends with "e" |
|
Match to any one of the enclosed characters |
c[aou]t
matches to "cat", "cot", and "cut" |
|
"Last command run" (inserts into current command) |
sudo !!
= rerun command as root |
|
Rerun last command but replace x with y |
ls /usr
followed by ^usr^tmp
will run ls /tmp
|
|
Rerun 3rd command from command history |
|
Runs most recent command from history that had "ls" in it |
Important Directories & Files
Directory/File |
(Stands For) Purpose |
/root |
Root user's home directory |
/home |
Normal users' home directories |
/var |
(Variables) Database locations, spool files for mail, etc. |
|
/usr |
(User System Resources) System resources used by users |
— /usr/bin |
(Binaries) Executables usable by normal users |
— /usr/sbin |
(System Binaries) Executables only usable by root user |
— /usr/lib |
52-bit libraries |
— /usr/lib64 |
64-bit libraries |
|
/etc |
(Extended Text Configurations) Configuration files |
— /etc/passwd |
User account config files |
— /etc/group |
Group membership info & config files |
— /etc/shadow |
User password info & config files |
— /etc/sudoers |
Main file for sudo config |
— /etc/sudoers.d/ |
Destination for sudo config "dropping files" |
— /etc/login.defs |
Defines default properties used for new user accounts |
vim Editor Controls
--- Command Mode --- |
o |
Starts new line and switches to Insert mode |
cw |
"Change word" - deletes word and switches to Insert mode |
G |
Go to end of file |
dd |
Delete or cut entire line |
yy |
Copy entire line |
p |
Paste copied text |
x |
Delete character cursor is on top of |
dw |
Delete word cursor is on top of |
d$ |
Delete from cursor to end of line |
ZZ |
Save & quit (existing files) |
--- Extended Command Mode --- |
:w filename |
Save (new files) |
:wq |
Save & quit (existing files) |
|
|
Misc. Commands
|
|
|
|
|
|
|
Show current processes & which user started them |
|
|
verbose; shows in detail what's happening while establishing connection |
|
enables graphical application support |
|
connect to ssh service not listening on default port 22 |
Basic File/Directory Commands
|
List contents of dir1 |
|
additional info (owner, perms, etc.) |
|
lists all, including hidden files |
|
adds file inode to info displayed |
|
info for directory itself (rather than its contents) |
|
Create a new directory |
|
creates full path (multiple directories if needed) |
|
verbose (output shows action taken) |
|
|
Copy dir1 into dir2 |
|
recursively ("and its contents") |
|
|
Removes (deletes) an empty directory |
|
recursively ("and it's contents"), including special files |
|
|
Move file1 into dir1 |
|
verbose (output shows action taken) |
|
|
Creates a hard link from file "link" to file "target" |
|
makes a symbolic link instead of a hard link |
Users & Groups
Command |
Options |
What It Does |
|
Show UID, GID, & secondary groups (current user if not specified) |
|
Find out if usr1 is known to the system |
|
Add a new user |
|
set a specific UID |
|
|
create a user without a login shell |
|
Change properties of existing user |
|
adds text to comment field |
|
changes primary group to group1 |
|
replaces supplementary group with group1 |
|
appends group1 to supplementary groups |
|
locks user1's account (instead of deleting) |
|
Change current user's primary group (temporary; current session only) |
|
Deletes user1 but not their home directory |
|
deletes both user and home directory |
|
Displays simple list of groups user1 is a member of |
|
Set password for user1 |
|
Change password aging properties for user |
|
minimum # of days between password changes |
|
maximum # of days between password changes |
|
warning period before password expires |
|
inactivity period (password usable after expiration) |
|
require password change on next login |
|
date when account expires |
|
Find out if grp1 is known to the system |
|
Create a new group |
|
set a specific GID |
|
create a system group |
|
Change properties of existing group |
|
change GID to specified number |
To set the number of days from today when user's account expires:
chage -E $(date +days %Y-%m-%d)
To give full admin privileges to a user or group:
echo "[user1|%group1] ALL=(ALL) ALL" >> /etc/sudoers.d/name
|