Git And Linux Cheatsheet

Git And Linux Cheatsheet

Git Cheatsheet

CommandDescription
git initInitialize a new git repository
git clone [url]Clone a remote repository
git statusCheck the status of the repository
git add [file]Add changes to the staging area
git commit -m "[message]"Commit changes with a message
git push [remote] [branch]Push changes to a remote repository
git pull [remote] [branch]Pull changes from a remote repository
git branchList all local branches
git branch [name]Create a new branch
git checkout [name]Switch to a different branch
git merge [branch]Merge changes from another branch
git logShow commit history
git reset --hard [commit]Reset the repository to a previous commit
git revert [commit]Create a new commit that reverses the changes of a previous commit
git stashSave changes without committing
git stash applyApply the saved changes
git tag [name]Create a new tag for a commit
git remote add [name] [url]Add a new remote repository
git remote -vList all remote repositories
git remote set-url [name] [new-url]Change the URL of a remote repository

Linux cheatsheet

CommandDescriptionExamples
cdChange directorycd /home/user/, cd ..
lsList directory contentsls, ls -l, ls -a
mkdirCreate a new directorymkdir new_dir
rmdirRemove a directoryrmdir dir_to_remove
rmRemove filesrm file_to_remove, rm -r dir_to_remove
cpCopy files/directoriescp file_to_copy new_file, cp -r dir_to_copy new_dir
mvMove/rename files/directoriesmv old_file new_file, mv dir_to_rename new_dir_name
touchCreate an empty file or update modification time of a filetouch new_file, touch existing_file
catDisplay contents of a filecat file_to_display
headDisplay first few lines of a filehead file_to_display
tailDisplay last few lines of a filetail file_to_display
grepSearch for a pattern in a filegrep "pattern" file_to_search, grep -i "pattern" file_to_search
psDisplay information about active processesps, ps -ef
topDisplay information about active processes in real-timetop
killTerminate a processkill process_id, kill -9 process_id
chmodChange permissions of a file/directorychmod u+x file_to_modify, chmod 755 dir_to_modify
sudoExecute a command with superuser privilegessudo command_to_execute
pingTest network connectivityping host_to_ping
ifconfigDisplay network interface informationifconfig
sshConnect to a remote system over SSHssh user@host

Advanced Linux

CommandDescription
awkA programming language used for text processing and data extraction
sedA stream editor used for manipulating text
grepSearches for a pattern in a file or input
findSearches for files and directories in a specified location
xargsExecutes commands based on standard input arguments
cutCuts specified columns from a file
sortSorts a file
uniqFilters out repeated lines in a file
tarCompresses and archives multiple files
gzipCompresses a single file
zipCompresses and archives multiple files
ddCopies and converts data from one file or block device to another
screenA terminal multiplexer that allows multiple sessions in a single terminal window
cronA scheduling daemon that executes commands at specified intervals