Cheatography
https://cheatography.com
Cheatsheet including important commands used in Linux and Git
Linux basic commands
pwd |
shows Present working directory |
cd |
changes Directory |
cd ~ |
changes directory to home |
cd .. |
goes one directory behind |
ls |
shows list of directories and files in current working directory |
ls -l |
shows list of directories in long format |
ls -a |
shows all files and directoies including hidden ones |
ls <directory name> |
shows list of directories and files in specified directory |
ls -lS > file.txt |
saves list in long form to txt file in pwd |
cat |
Echoes input |
cat <textfilename> |
Displays content of file or files |
|
|
Linux redirection
cat > test.txt |
Creates a file named test.txt and records data given below |
cat > test.txt (again) |
Overwrites previous data |
cat >> test.txt |
appends data |
cat [textfile1] [textfile2] > [new or existing file] |
concatenates textfile1 and textfile2 and saves to new file |
mkdir [directoryname] |
creates a directory |
mkdir -p [dir]/[subdir] |
creates a path of directories |
mkdir -p [dir]/{subdir1,subdir2,subdir3} |
Create multiple subdirectories in one directory |
rmdir |
Remove directory |
rmdir -p a/b/c/d/e |
removes entire directory path |
rmdir pv (verbose) |
Shows how removal will work |
rm |
removes file |
cp [file1.txt] [dirname] |
copies file1.txt to the specified directory |
cp -r |
copies recursively |
man <any command> |
Displays manual for that command |
mv [file1.txt] [dirname] |
move file1.txt from current dir to specified directory |
touch <filename> |
creates file quickly |
touch <existingfile> |
updates time stamp of file |
nano |
opens file editor |
vim |
opens vim file editor |
sudo |
executes command as superuser |
|
|
Linux advanced
top |
displays processes running on the computer |
s (in top menu) |
changes refresh rate |
i (in top menu) |
shows idle processes |
k (in top menu) |
kills process using PID |
pid of |
finds process id of process using name |
kill [PID] |
kills process for given process id |
kill -9 [PID] |
Force stop |
ps -ux |
Gives list of running processes and finds PIDs |
ps -aux |
Gives list of all running processes and finds PIDs |
ps -U [user] |
displays list of running processes for given user |
ps -C |
to know the instances of that program |
echo |
displays whatever we type (useful in bash scripting) |
chmod |
Utility to change permission of the file |
wget |
get(just reads) |
sudo apt -get update |
updates system |
exit |
Exits superuser or terminal |
ssh -i ./[file] [username]@[ip] |
establishes ssh connection |
vmstat |
prints a summary of key server statistics, processes, cpu, disk space |
|
|
git commands
apt-get install git |
installs git on linux |
git init |
initializes empty git repository in folder |
git add <file name> |
stages file for commitment |
git add . |
stages all files for commitment |
git commit -m "<note>" |
commits staged files |
git status |
shows status of files |
git branch |
shows all branches |
git branch <branch name> |
creates new branch |
git switch <branch name> |
switches branch |
git checkout <branch name> |
switches branch |
git merge <branch name> |
merges the specified branch with current branch |
git rebase <branch name> |
merges the specified branch with current branch and adds commit ahead of present commits |
git stash |
used to store changes when we want to move to a different directory without committing current changes |
git push -u origin master |
pushing changes to central github repository |
git --help |
shows all commands |
git restore --<staged file name> |
untrack file |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by RohitKadolkar