Cheatography
https://cheatography.com
asddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
This is a draft cheat sheet. It is a work in progress and is not finished yet.
File Commands
ls |
List files in the directory |
ls -a |
List files, include hidden files |
pwd |
Show current directory |
mkdir [name] |
Create a directory |
rm [file] |
Remove a file |
rm -r [directory] |
Recursively remove directory |
rm -rf [directory] |
Force remove directory |
cp [file1] [file2] |
Copy file1 to file2 |
cp -r [directory1] [directory2] |
Copy directory1 to directory2 |
mv [filename1] [filename2] |
Rename a file |
touch [file] |
Create a new file |
more [file] |
Show file contents |
head [file] |
Show first 10 lines of a file |
tail [file] |
Show last 10 lines of a file |
shred -u [file] |
Overwrite and delete a file |
ls | xargs wc |
Words/lines/bytes in directory |
diff [file1] [file2] |
Compare two files |
File Permission
chmod 777 [file] |
File read, write, execute permissions to everyone |
chmod 755 [file] |
Full permission to owner, read permissions for others |
chmod 766 [file] |
Full permission to owner, read and write for others |
chown [user] [file] |
Change file ownership |
chown [user]:[group] [file] |
Change file owner and group |
Process Management
ps |
Display your currently active processes |
pmap |
Show process memory usage |
top |
Display all running processes |
kill [process_id] |
Kill the process by ID |
pkill [process_name] |
Kill the process by name |
killall [process_name] |
Kill all processes by name |
bg |
List background processes |
fg |
Most recent suspended job to foreground |
Keyboard Shortcuts
Ctrl + C |
Kill current process |
Ctrl + Z |
Stop process (can be resumed) |
Ctrl + W |
Cut the word before the cursor |
Ctrl + U |
Cut part of the line before the cursor |
Ctrl + K |
Cut part of the line after the cursor |
Ctrl + Y |
Paste from clipboard |
Ctrl + R |
Recall last command |
Ctrl + O |
Run the recalled command |
Ctrl + G |
Exit command history |
!! |
Repeat the last command |
exit |
Log out of the session |
|
|
Directory Navigation
cd .. |
Move up one level |
cd |
Change directory to $HOME |
cd [/location] |
Change to a specified directory |
Users and Groups
id |
Show active user details |
last |
Show last system logins |
who |
Show who is logged in |
w |
Show logged users and activity |
groupadd [group] |
Add a new group |
adduser [user] |
Add a new user |
usermod -aG [group] [user] |
Add user to group |
userdel [user] |
Delete a user |
usermod |
Modify user information |
chgrp [group] [directory] |
Change directory group |
System Management and Info
uname -r |
Show system information |
uname -a |
Show kernel release info |
uptime |
Show uptime length/avg. load |
hostname |
Show system hostname |
hostname -l |
Show system IP address |
last reboot |
Show reboot history |
date |
Show current time and date |
cal |
Show current day and month |
whoami |
Show the current user |
finger [username] |
Show user information |
shutdown [hh:mm] |
Schedule a system shut down |
df |
Show disk usage |
du |
Show directory space usage |
free |
Show memory and swap usage |
whereis app |
Show possible locations of app |
which app |
Show which app will be run by default |
Shell Command Management
alias [alias]='[command]' |
Create command alias |
watch -n [interval] [command] |
Set interval to run a command |
sleep [interval] && [command] |
Postpone command execution |
at [hh:mm] |
Schedule a job |
man [command] |
Display command manual |
history |
Print command history |
|