DAY - 12 
Linux & (Git +GitHub) Ultimate Cheat Sheet

DAY - 12 Linux & (Git +GitHub) Ultimate Cheat Sheet

1.Basic Linux commands :

Commands

Description

ls

Lists all files and directories in the present working directory

ls -R

Lists files in sub-directories as well

ls -a

Lists hidden files as well

ls -al

Lists files and directories with detailed information like permissions, size, owner, etc.

cd ~

Navigate to the HOME directory

cd . .

Move one level up

cd

To change to a particular directory

cd /

Move to the root directory

cat > filename

Creates a new file

cat filename

Displays the file content

cat file1 file2 > file3

Joins two files (file1, file2) and stores the output in a new file (file3)

mv file "new file path"

Moves the files to the new location

mv filename new_file_name

Renames the file to a new filename

sudo

Allows regular users to run programs with the security privileges of the superuser or root

rm filename

Deletes a file

man

Gives help information on a command

history

Gives a list of all past commands typed in the current terminal session

clear

Clears the terminal

mkdir directory-name

Creates a new directory in the present working directory or an at the specified path

rmdir

Deletes a directory

mv

Renames a directory

apt-get

The command used to install and update packages

File Permission commands :

Command

Description

ls -l

to show file type and access permission

r

read permission

w

write permission

x

execute permission

-=

no permission

Chown user

For changing the ownership of a file/directory

Chown user: group filename

change the user as well as a group for a file or directory

Environment Variables command :

Command

Description

echo $VARIABLE

To display the value of a variable

env

Displays all environment variables

VARIABLE_NAME=variable_value

Create a new variable

Unset

Remove a variable

export Variable=value

To set the value of an environment variable

User management commands of Linux :

Command

Description

sudo adduser username

To add a new user

sudo passwd -l 'username'

To change the password of a user

sudo userdel -r 'username'

To remove a newly created user

sudo usermod -a -G GROUPNAME USERNAME

To add a user to a group

sudo deluser USER GROUP NAME

To remove a user from a group

finger

Shows information of all the users logged in

finger username

Gives information about a particular user

Networking commands :

Command

Description

SSH username@ip-address or hostname

login into a remote Linux machine using SSH

Ping hostname="" or =""

To ping and Analyze network and host connections

dir

Display files in the current directory of a remote computer

cd "dirname"

change the directory to “dirname” on a remote computer

put file

upload ‘file’ from local to remote computer

get file

Download the ‘file’ from the remote to the local computer

quit

Logout

Process commands :

Command

Description

bg

To send a process to the background

fg

To run a stopped process in the foreground

top

Details on all Active Processes

ps

Give the status of processes running for a user

ps PID

Gives the status of a particular process

pidof

Gives the Process ID (PID) of a process

kill PID

Kills a process

nice

Starts a process with a given priority

renice

Changes the priority of an already running process

df

Gives free hard disk space on your system

free

Gives free RAM on your system

2.Cheat sheet on Git-GitHub.

  1. git init: To Initialize a new Git repository in the current directory.

  2. git --version: To confirm that you have installed Git.

  3. git clone <repository-url>: To clone the remote repo to the local repo.

  4. git status: To check the current status of the repo.

  5. git add <file_name>: To add a file to the staging area to be included in the next commit.

  6. git commit -m <Commit Message>: Make a commit by taking the updated working tree contents of the paths specified on the command line.

  7. git push -u origin main: To push the local commits to a remote repository.

  8. git revert <commit-id>: To remove or edit changes you’ve made in the code in previous commits.

  9. git rebase <branch name>: To remove or edit changes you’ve made in the code in previous commits.

  10. git merge: Git merge is a command that allows developers to merge Git branches while the logs of commits on branches remain intact.

  11. git stash: Use git stash to save the changes without committing them.

  12. git log --oneline: To print a single commit in a single line as output when the git log command is executed using this option.

  13. git checkout <branch_name>: Command lets you navigate between the branches created by git branch.

  14. git cherry-pick <commit_id>: To apply changes from a specific commit to the current branch.

  15. git push origin --delete <branch>: To fully delete a remote branch on GitHub.

If you find my blog valuable, I invite you to like, share, and join the discussion. Your feedback is immensely cherished as it fuels continuous improvement. Let's embark on this transformative DevOps adventure together! 🚀 #devops #90daysofdevop