Day 12 Task: Linux and GitHub Cheat-Sheet
## Finally!! π
I have completed the Linux & Git-GitHub hands-on and I hope you also have learned something interesting from it.ππβοΈ
In the previous tasks, I have uploaded the DevOps basics, Linux, shell Scripting, Git & GitHub. Now in these tasks, we are learning Linux and GitHub commands.
Linux Commands:
# To check your present working directory :-
# List all the files or directories :-
# Lists hidden files or directories :-
# Long listing format :-
# Create a new directory :- mkdir <directory_name>
# Multiple directory creation :- mkdir -p A B C D
# Remove directory :- rmdir <directory_name>
# Remove multiple directories :- rm -rf <directory_name>
# Remove files :- rm <file_name>
# change directory :- cd <path_where_to_navigate>
# create an empty file :- touch <file_name>
# Copy file :- cp <source_path> <destination_path>
# Move file :- mv <source_path> <destination_path>
# To write some content inside a file :-
echo <some msg> > <file_name>
# display contents of a file :- cat <file_name>
# show previous commands/operations performed in shell :-
# To search a word (string in a file) :- grep "string" <filename>
# Return the specified number of lines from the top :- head
# Return the specified number of lines from the bottom :- tail
# To show disk space :- df - H
File permissions:
# To change permission of the file :-
chmod <permission> <file_name>
Example :- chmod 700 a.txt #readwriteexeute
to user only.
Now, we are changing the permission of abc.txt1
# To change file or directory ownership :- sudo chown <username> <filename>
# To change group ownership :- chgrp <group_name> <file_name>
Access Control List:
setfacl and getfacl are used for setting up ACL and showing ACL respectively.
# For checking ACL permission :- getfacl <name of file or directory>
# For set ACL permission to user :- setfacl -m u:user:permissions /path_to_file
User management:
# To create a new user :- sudo useradd <user_name>
# To set a password for user :- sudo passwd <user_name>
# To delete a Linux user :- sudo userdel <user_name>
# For add group account :- sudo groupadd <group_name>
After Linux cheat sheet, now let us discuss the Git cheat sheet
# Initialize an empty git repository: transforms the current directory into a Git list of all remote repositories that are currently connected to your local repository.
git init
# Clone an existing git repository:
git clone <repository_url>
# Add files and Moves changes from the working directory to the staging area:
git add <file_name>
# Add all current directory files to git :
git add .
# Commit all the staged files to git.
git commit -m "commit_message"
# To show the status of your git repository:
git status
Git Branch :-
# To list all of the branches:
git branch
# Create a new branch:
git branch <branch_name>
# For going to specific branch:
git checkout <branch_name>
# for creating and going to that branch:
git checkout -b <branch_name>
# For deleting branch:
git checkout -d <branch_name>
Remote origin :-
# list of all remote repositories that are currently connected to local repository:
git remote -v
# To add remote origin URL:
git remote add origin <remote_git_url>
# To remove remote origin URL:
git remote remove origin
# To upload local repository content to a remote repository:
git push origin <branch_name>
# To pull your remote repository content to local repository:
git pull origin <branch_name>
# To fetch down all the branches from that Git remote:
git fetch
# To check your git commits and all logs:
git log
git configuration :-
# To set author name to be used for all commits by the current user :
git config --global user.name <your_username>
# To set author email to be used for all commits by the current user:
git config --global user.email <your_email>
# to merge two branches in Git:
git merge <branch_name>
Cherry-pick :-
# Merge just one specific commit from another branch to your current branch:
git cherry-pick [commit_id]
git revert :-
# Undo a single given commit, without modifying commits that come after it:
git revert <commit_id>
git reset :-
# Go back to specific commit:
git reset <commit_id>
git rebase :-
# To rebase all the commits between another branch and the current branch state:
git rebase <other_branch_name>
Temporary commits :-
# To save modified and staged changes:
git stash
# list stack-order of stashed file changes:
git stash list
# write working from top of stash stack :-
git stash pop
Thank you for reading! Hopefully this help someone out there!
Happy Learning (Sajid Perwaiz) π