Skip to content

Instantly share code, notes, and snippets.

View codedeep79's full-sized avatar

Nguyễn Trung Hậu codedeep79

View GitHub Profile
@codedeep79
codedeep79 / Format USB FAT32 in Ubuntu.md
Last active August 9, 2022 01:35
Format USB FAT32 in Ubuntu

Step 1: Locate USB Drive

Open the terminal and run the following command: df

Step 2: Unmount and Format USB Drive

Unmount the USB drives before formatting. To do so, run this command:

sudo umount /dev/sdb1

After unmounting, format the USB drive using the preferred file system (replace sdb1 with the name of your device):

@codedeep79
codedeep79 / Cài đặt Elasticsearch trên Ubuntu 20.04.md
Created August 9, 2022 01:07
Cài đặt Elasticsearch trên Ubuntu 20.04

Installing Elasticsearch

First, update the packages index and install the dependencies necessary to add a new HTTPS repository:

sudo apt update
sudo apt install apt-transport-https ca-certificates wget

Import the repository’s GPG key:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
@codedeep79
codedeep79 / Create Groups in Linux (groupadd Command).md
Created August 9, 2022 00:48
Create Groups in Linux (groupadd Command)

To create a new group named mygroup you would run:

groupadd mygroup

If the group with the same name already exist, the system will print an error message like the following:

groupadd: group 'mygroup' already exists

To suppress the error message if the group exist and to make the command exit successfully, use the -f (--force) option:

@codedeep79
codedeep79 / Change Root Password in Ubuntu Linux.md
Created August 9, 2022 00:41
Change Root Password in Ubuntu Linux

To switch to the root account in the current login session, you can use either the sudo su or sudo -i command and enter the user password:

sudo su -

To change the password of the root user in Ubuntu, run the following command as a sudo user:

sudo passwd root
@codedeep79
codedeep79 / Change a Git Commit Message.md
Created August 9, 2022 00:31
Change a Git Commit Message

Changing the Most Recent Commit

The git commit --amend command allows you to change the most recent commit message.

To change the message of the most recent commit that has not been pushed to the remote repository, commit it again using the --amend flag.

  • Navigate to the repository directory in your terminal.
  • Run the following command to amend (change) the message of the latest commit:
    git commit --amend -m "New commit message."
    
@codedeep79
codedeep79 / Active Windows 11 CMD bằng Script.md
Created August 8, 2022 03:05
Active Windows 11 CMD bằng Script

Create file "active.cmd" and run as Administrator:

@setlocal DisableDelayedExpansion
@echo off
goto MAS_Start
@codedeep79
codedeep79 / Pidof Command in Linux.md
Created August 7, 2022 10:56
Pidof Command in Linux

pidof is a command-line utility that allows you to find the process ID of a running program.

Let’s say the Chrome browser has become unresponsive, and you need to kill the Chrome processes. First, find the PIDs, with pidof:

pidof chrome

Once you know the Chrome processes PIDs, send the SEGTERM signal to terminate all of them:

sudo kill -9 8846 8580 8534 8516 8510 8500 8470 8178 8098 8085 8048 8015 7999 7972 7531 7453 4442 4420 4390 4371 4352 4334 4322 4288 4281 4256 4244 4232 4207 4192 4182 4163 4162 4160 4145 4131 4096 4080 4065 4040 3987 3718 2768 2736 2631 2618 2589 2566 2541 2448 2311 2308 2214 2210 2209 2193
@codedeep79
codedeep79 / Pstree Command in Ubuntu.md
Created August 7, 2022 10:48
Pstree Command in Ubuntu

When working on a Linux machine, sometimes you might need to find out what processes are currently running. The Pstree is a convenient way to displays a hierarchical tree structure of all running processes:

pstree

If a user name is given as an argument, pstree shows only the processes owned by that user. For example, the following command will show only those processes that have been started by a user named "ubuntu":

pstree ubuntu