Cheatography
https://cheatography.com
Cheat Sheet of Linux for #90DaysofDevops
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Basic Commands
| |
Pipe command (to redirect output) |
sudo |
Run commands as root user |
cd dir |
Change directory to dir |
cd .. |
Go up a directory |
!! |
Repeat the last command |
w |
Display who is online |
history |
Displays all the commands run in the terminal by the user in the current session |
File commands
ls -al |
Display all information on files/directories |
pwd |
path of current working directory |
mkdir [dir_name] |
Create directory |
rmdir [dir_name] |
Remove directory |
rm -r [dir-path] |
Remove directory recursively |
touch [file-name] |
Create file |
mv file1 file2 |
Move/Rename source to destination |
cat > file |
Place standard input into file (Rewrite) |
cat >> file |
Append standard input into file |
wc |
Print number of bytes, words and lines in file |
head -n file |
Output beginning of file |
tail -n file |
Output ending of file |
more (or less) |
Output the contents of a file, one page at a time |
ln -s file link |
Create symbolic link "link" to file |
|
|
System info
date |
Show current date/time |
cal |
Show present month's calender |
uptime |
Show uptime |
whoami |
Prints current user id |
free |
Show memory and swap usage |
man |
Manual for any command |
df |
Show disk usage |
du |
Show directory space usage |
Process management
ps |
Display currently active processes |
kill pid |
kills process with id "pid" |
fg |
Brings most recent job to foreground |
bg |
Lists stopped/background jobs |
File permission
chmod |
Change file permission |
Add number / acronym |
User |
2 / w |
Write |
1 / x |
Execute |
4 / r |
Read |
chgrp |
Change group |
chown |
Change ownership |
chmod 777 |
rwx for all |
User management
sudo useradd username |
Add new user |
sudo passwd -l username |
Change password of user |
sudo userdel -r username |
Delete user |
sudo usermod -a -G groupname user |
To add a user to a group |
sudo deluser user groupname |
Remove user from group |
|
|
Network
ifconfig |
Displays IP addresses |
ping host |
ping host and output results |
wget file |
download file |
wget -c file |
continue a stopped download |
dpkg -i pkg.deb |
install a package (debian) |
Searching
grep pattern file |
Search for the pattern in the file |
grep -r pattern dir |
Search recursively for pattern in dir |
locate file |
find all instances of file |
command | grep pattern |
search for the pattern in the output of the command |
Compression
tar cf file.tar files |
Create a tar named file.tar containing files |
tar xf file.tar |
Extract the files from file.tar |
tar czf file.tar.gz files |
Create a tar with Gzip compression |
tar xzf file.tar.gz |
Extract a tar using Gzip |
Terminal
Ctrl+C |
Halt current command |
Ctrl+Z |
Pause Current command |
Ctrl+D |
Logout |
Ctrl+W |
Remove a word from current line |
Ctrl+U |
Remove current line |
Ctrl+A |
Go to the beginning of the current line |
Ctrl+E |
Go to the end of the current life |
|