We have completed the Linux & Git-GitHub hands-on, let's make a cheat sheet of all the commands we have learned so far.
Linux commands:
whoami -> It is used to display the current username.
man -> It is used to display the user manual of any command.
echo -> It is used to display the line of text or strings that are passed as an argument.
tree -> It is used to display the file system's directory structure in a tree-like format.
sudo -> It is used to run commands with administrative privileges.
date -> It is used to display the date and time.
history-> It is used to display the history of the commands executed by the user.
clear -> It is used to clear the terminal screen.
File and Operations Commands
ls -> It shows available files and directory lists in the present working directory.
ls -l -> It is used for knowing the details of files and directories.
ls -a -> It is used for showing the list of all the hidden files.
touch -> It is used to create empty files.
cp -> It is used to copy files from one directory to another.
mv -> It is used to rename and replace the files and directory.
rm -> It is used to remove the file and directory.
rm -r -> It is used for recursive deletion of files and directories.
ln -> It is used to create links between files.
Viewing and editing the file system
cat -> It is used to display file content on the terminal.
head -> It is used for printing the first ten lines(by default) of a text file.
tail -> It is used to display the last ten lines(by default) of a text file.
nano -> It is used for as an editor to create or edit a text file.
vim -> It is used as an editor to create or edit a text file.
less -> It is used to view file contents interactively.
Directory navigation
cd -> It is used for changing the directory.
mkdir -> It is used for creating a new directory.
pwd -> It displays the present working directory.
File permission
chmod -> It is used to change file and directory permissions.
chown -> It is used to change file ownership.
chgrp -> It is used to change the group ownership of files and directory.
Searching for files and directories
find -> It is used to search files and directories.
grep -> It is used to search for specified patterns or text in files.
which -> It is used to display the full path of a specified command.
locate -> It is used to quickly find files using a database.
Network Operations
ifconfig -> It is used to display or configure network interfaces.
ping -> It is used to send ICMP echo requests to a host.
ssh -> It is used to securely access remote systems over SSH.
hostname -> It is used to set and view the hostname of the system.
wget -> It is used to download files and interact with REST APIs.
curl -> It is used to transfer data to or from a server.
User Management and Group management
useradd -> It is used to add a new user.
passwd -> It is used to change the user password.
usermod -> It is used to modify user properties.
userdel -> It is used to delete a user.
groupadd -> It is used to add a group.
groupdel -> It is used to delete a group.
id -> It is used to identify if a user is created.
System Information
df -> It is used to display disk space usage.
du -> It is used to display file and directory space usage.
top -> It is used to display real-time system stats.
uname -> It is used to show system information.
Package Management
Apt -> It is a package management system for Debian, Ubuntu, and other similar Linux distributions.
Yum -> It is a package management tool for a variety of older RHEL-based distributions (such as CentOS 7) and older versions of Fedora.
DNF -> It is used to install, update, remove, and manage software packages on their Linux systems.
File compression
tar -> It is used to create, extract, and manipulate archive files.
gzip or gunzip -> It is used to compress or decompress files.
zip or unzip -> It is used to compress or extract files in ZIP format.
Git-GitHub commands
Git is a version-control system used for tracking changes in computer files. Git is a version-control system used for tracking changes in computer files.
Setting up Git:
git config --global
user.name
"Your Name"
git config --global
user.email
"
your@email.com
"
Creating Repositories:
git init
: It will initialize the git repo in our local system.git clone <repository_url>
: It will clone a remote repository to your local machine.
Managing Changes:
git add <file>
: It will add the file to the staging area.git commit -m "Commit message"
: It will commit the code with the message first commit.git rm <file name>
: It will remove the file/folder.git status
: It will check the status.git diff
: It will show the changes between the working directory and the staging area.git diff --staged
: It shows the changes between the staging area and the last commit.git reset <file>
: It will unstage changes for a file, removing them from the staging area.git revert <commit>
: It will create a new commit that undoes the changes from a specific commit.
Branching and Merging:
git branch
: It will list all branches in the repository.git branch -a
: it will list all branches.git branch <branch_name>
: It will create a new branch.git checkout <branch_name>
: It will switch to a different branch.git branch -M main
: It will push to the branch we want.git merge <branch_name>
: It will merge changes from one branch into another.git checkout -b <branch_name>
: It will create a new branch and switch to it.git branch --delete <branch_name>
: It will delete the branch.
Viewing History:
git log
: It is used to display commit history.git-show
: It is used to see log messages.
Updating and Publishing:
git pull
: It is used to fetch and merge changes from a remote repository.git push origin <branch_name>
: It is used to push local changes to a remote repository.git push -u origin <branch_name>
: It pushes changes to the remote repository.
Temporary changes:
git stash
: It will temporarily save changes that are not ready to be committed.git stash apply
: It will apply to the most recent stash.git stash save "message"
: Changes can be stashed with a message.git stash list
: It will list all stashed changes.Git stash changes
: This command shows the changes in the most recent stash.git stash branch <branch name>
: Create a new branch from your latest stash.Git stash pop:
This command retrieves the most recent stash, applies the changes to your working directory, and removes it from the stash list.Git stash drop
: This command discards the most recent stash without applying its changes to your working directory. It's like throwing away the stash.Git stash clear
: This command removes all stashes. Use it with caution as it removes all stashes permanently.git cherry-pick <commit>
: Apply changes from a specific commit to the current branch.
Summary
In this blog, we see all the major Linux and git commands that we used as a DevOps engineer. Whatever commands we have covered in our blogs and those which we have missed and are important for DevOps we add all the commands in this single cheatsheet.