#90 DaysOfDevOps Challenge Day 12: Cheat Sheet for Linux & Git-GitHub

Basic Linux Commands

Listing and directory commands

ls -l: list the files and directories in a list format

ls -a: list all including hidden files and directories

ls *.sh list all the files having .sh extension

ls -d */: list only directories

pwd: print work directories i.e gives the present working directory

cd path_to_directory: change the directory to the directory provided

cd ~: change the path to the home directory

cd -: go to the last working directory

mkdir directoryName: to make a directory in a specific location

File Permissions

To view what's written in a file:

  • cat filename

To change access permission of files:

  • chmod 777 folder_name

To grant full permissions to a directory and its contents:

  • chmod -R 777 directory_name

To remove the execution permission of any file:

  • chmod -x filename

User Management

To create new user:

  • sudo useradd newuser

To set a password for a user:

  • sudo passwd newuser

To view user information:

  • id username

To delete a user:

  • sudo userdel username

Package Management

To install a package for Debian/Ubuntu-based systems:

  • sudo apt install package_name

To update a package for Debian/Ubuntu-based systems:

  • sudo apt update

To remove a package for Debian/Ubuntu-based systems:

  • sudo apt remove package_name

Git & GitHub Cheat Sheet

Git Repository

To initialize a new git repository:

  • git init

To clone an existing git repository:

  • git clone <repository>

To add a file to the staging area:

  • git add <file>

To commit changes:

  • git commit -m "commit message"

To push changes to a remote repository:

  • git push origin <branch_name>

To pull changes from a remote repository:

  • git pull origin <branch_name>

Branching and Merging

To create a new branch:

  • git branch <new_branch>

To merge branches:

  • git merge <branch>

To list branches:

  • git branch

To check the status of your repository:

  • git status

To view commit history:

  • git log

Thanks for reading!